Skip to content

Commit

Permalink
Warn on unused ESLint disable directives in base config (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Jan 12, 2023
1 parent d6bac22 commit 2a998b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ Install alongside ESLint via yarn (or npm):
yarn add --dev eslint eslint-plugin-square npm-run-all
```

Edit your `.eslintrc.js` configuration file to extend one of the available configurations from this plugin and [detect unused disable directives](https://eslint.org/docs/latest/user-guide/configuring/rules#report-unused-eslint-disable-comments):
Edit your `.eslintrc.js` configuration file to extend one of the available configurations from this plugin:

```js
module.exports = {
reportUnusedDisableDirectives: true,
extends: ['plugin:square/base'], // Or other configuration.
};
```

Add the relevant lint scripts in `package.json` with [npm-run-all](https://github.com/mysticatea/npm-run-all):
Add the relevant lint scripts in `package.json` with [npm-run-all](https://github.com/mysticatea/npm-run-all) and include detection for [unused disable directives](https://eslint.org/docs/latest/user-guide/command-line-interface#--report-unused-disable-directives):

```json
{
Expand Down
1 change: 1 addition & 0 deletions lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This configuration is intended for use with JavaScript applications.

module.exports = {
reportUnusedDisableDirectives: true, // Warn on unused disable directives: https://eslint.org/docs/latest/user-guide/configuring/rules#report-unused-eslint-disable-comments
extends: [
'eslint:recommended',
'plugin:eslint-comments/recommended',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*",
"lint:docs": "markdownlint \"**/*.md\"",
"lint:eslint-docs": "npm-run-all \"update:eslint-docs -- --check\"",
"lint:js": "eslint --cache .",
"lint:js": "eslint --report-unused-disable-directives --cache .",
"lint:package-json": "npmPkgJsonLint .",
"lint:package-json-sorting": "sort-package-json --check",
"lint:package-json-sorting:fix": "sort-package-json package.json",
Expand Down

0 comments on commit 2a998b3

Please sign in to comment.