You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This option causes ESLint to report directive comments like `// eslint-disable-line`when no errors would have been reported on that line anyway.
576
+
This option causes ESLint to report disable directive comments like `// eslint-disable-line`as errors when there are no violations present.
576
577
577
578
***Argument Type**: No argument.
578
579
@@ -581,7 +582,7 @@ This can be useful to prevent future errors from unexpectedly being suppressed,
581
582
::: warning
582
583
When using this option, it is possible that new errors start being reported whenever ESLint or custom rules are upgraded.
583
584
584
-
For example, suppose a rule has a bug that causes it to report a false positive, and an `eslint-disable` comment is added to suppress the incorrect report. If the bug is then fixed in a patch release of ESLint, the `eslint-disable` comment becomes unused since ESLint is no longer generating an incorrect report. This results in a new reported error for the unused directive if the `report-unused-disable-directives` option is used.
585
+
For example, suppose a rule has a bug that causes it to report a false positive, and an `eslint-disable` comment is added to suppress the incorrect report. If the bug is then fixed in a patch release of ESLint, the `eslint-disable` comment becomes unused since ESLint is no longer generating an incorrect report. This results in a new reported error for the unused directive if the `--report-unused-disable-directives` option is used.
585
586
:::
586
587
587
588
##### `--report-unused-disable-directives` example
@@ -590,6 +591,16 @@ For example, suppose a rule has a bug that causes it to report a false positive,
Same as [`--report-unused-disable-directives`](#--report-unused-disable-directives), but allows you to specify the severity level (`error`, `warn`, `off`) of the reported errors. Only one of these two options can be used at a time.
597
+
598
+
##### `--report-unused-disable-directives-severity` example
Copy file name to clipboardExpand all lines: docs/src/use/configure/configuration-files-new.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ Each configuration object contains all of the information ESLint needs to execut
45
45
*`parserOptions` - An object specifying additional options that are passed directly to the `parse()` or `parseForESLint()` method on the parser. The available options are parser-dependent.
46
46
*`linterOptions` - An object containing settings related to the linting process.
47
47
*`noInlineConfig` - A Boolean value indicating if inline configuration is allowed.
48
-
*`reportUnusedDisableDirectives` - A Boolean value indicating if unused disable directives should be tracked and reported.
48
+
*`reportUnusedDisableDirectives` - A severity string indicating if and how unused disable directives should be tracked and reported. For legacy compatibility, `true` is equivalent to `"warn"` and `false` is equivalent to `"off"`. (default: `"off"`)
49
49
*`processor` - Either an object containing `preprocess()` and `postprocess()` methods or a string indicating the name of a processor inside of a plugin (i.e., `"pluginName/processorName"`).
50
50
*`plugins` - An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
51
51
*`rules` - An object containing the configured rules. When `files` or `ignores` are specified, these rule configurations are only available to the matching files.
@@ -208,20 +208,22 @@ export default [
208
208
209
209
#### Reporting unused disable directives
210
210
211
-
Disable directives such as `/*eslint-disable*/` and `/*eslint-disable-next-line*/` are used to disable ESLint rules around certain portions of code. As code changes, it's possible for these directives to no longer be needed because the code has changed in such a way that the rule is no longer triggered. You can enable reporting of these unused disable directives by setting the `reportUnusedDisableDirectives` option to `true`, as in this example:
211
+
Disable directives such as `/*eslint-disable*/` and `/*eslint-disable-next-line*/` are used to disable ESLint rules around certain portions of code. As code changes, it's possible for these directives to no longer be needed because the code has changed in such a way that the rule is no longer triggered. You can enable reporting of these unused disable directives by setting the `reportUnusedDisableDirectives` option to a severity string, as in this example:
212
212
213
213
```js
214
214
exportdefault [
215
215
{
216
216
files: ["**/*.js"],
217
217
linterOptions: {
218
-
reportUnusedDisableDirectives:true
218
+
reportUnusedDisableDirectives:"error"
219
219
}
220
220
}
221
221
];
222
222
```
223
223
224
-
By default, unused disable directives are reported as warnings. You can change this setting using the `--report-unused-disable-directives` command line option.
224
+
You can override this setting using the [`--report-unused-disable-directives`](../command-line-interface#--report-unused-disable-directives) or the [`--report-unused-disable-directives-severity`](../command-line-interface#--report-unused-disable-directives-severity) command line options.
225
+
226
+
For legacy compatibility, `true` is equivalent to `"warn"` and `false` is equivalent to `"off"`.
Copy file name to clipboardExpand all lines: docs/src/use/configure/rules.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,8 +302,8 @@ To report unused `eslint-disable` comments, use the `reportUnusedDisableDirectiv
302
302
```json
303
303
{
304
304
"rules": {...},
305
-
"reportUnusedDisableDirectives": true
305
+
"reportUnusedDisableDirectives": "error"
306
306
}
307
307
```
308
308
309
-
This setting is similar to [--report-unused-disable-directives](../command-line-interface#--report-unused-disable-directives) CLI option, but doesn't fail linting (reports as `"warn"` severity).
309
+
This setting is similar to [--report-unused-disable-directives](../command-line-interface#--report-unused-disable-directives) and [--report-unused-disable-directives-severity](../command-line-interface#--report-unused-disable-directives-severity) CLI options.
* @property {boolean|string} [reportUnusedDisableDirectives] `true` or `error` adds reports for unused eslint-disable directives
87
87
* @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
88
88
* @property {string} [resolvePluginsRelativeTo] The folder where plugins should be resolved from, defaulting to the CWD
89
89
*/
@@ -215,7 +215,7 @@ function calculateStatsPerRun(results) {
215
215
* @param {ConfigArray} config.config The config.
216
216
* @param {boolean} config.fix If `true` then it does fix.
217
217
* @param {boolean} config.allowInlineConfig If `true` then it uses directive comments.
218
-
* @param {boolean} config.reportUnusedDisableDirectives If `true` then it reports unused `eslint-disable` comments.
218
+
* @param {boolean|string} config.reportUnusedDisableDirectives If `true` or `error`, then it reports unused `eslint-disable` comments.
219
219
* @param {FileEnumerator} config.fileEnumerator The file enumerator to check if a path is a target or not.
220
220
* @param {Linter} config.linter The linter instance to verify.
Copy file name to clipboardExpand all lines: lib/eslint/eslint-helpers.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -675,7 +675,7 @@ function processOptions({
675
675
overrideConfig =null,
676
676
overrideConfigFile =null,
677
677
plugins ={},
678
-
reportUnusedDisableDirectives =null,// ← should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that.
678
+
reportUnusedDisableDirectives =null,// ← should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that. TODO: should anything change based on this comment?
Copy file name to clipboardExpand all lines: lib/eslint/eslint.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -165,7 +165,7 @@ function processOptions({
165
165
overrideConfig =null,
166
166
overrideConfigFile =null,
167
167
plugins ={},
168
-
reportUnusedDisableDirectives =null,// ← should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that.
168
+
reportUnusedDisableDirectives =null,// ← should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that. TODO: should anything change based on this comment?
169
169
resolvePluginsRelativeTo =null,// ← should be null by default because if it's a string then it suppresses RFC47 feature.
0 commit comments