Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-unused-disable is redundant #249

Open
CruseCtrl opened this issue Jan 6, 2025 · 1 comment
Open

no-unused-disable is redundant #249

CruseCtrl opened this issue Jan 6, 2025 · 1 comment

Comments

@CruseCtrl
Copy link

Eslint already has the reportUnusedDisableDirectives setting, and starting in eslint v9, that setting is enabled by default: https://eslint.org/docs/latest/use/configure/rules#report-unused-eslint-disable-comments

It also has auto-fix, so running eslint --fix will automatically remove any unused disable directives. I don't think the no-unused-disable is adding anything extra, so it should be removed from this plugin

@Samuel-Therrien-Beslogic
Copy link

Samuel-Therrien-Beslogic commented Jan 21, 2025

Idk if that still true, but in #234 (comment) I mentioned that the ESLint option "Doesn't seem to be picked up by extending configurations".
But even if it is now:

There's one use-case where it's still not fully redundant: Flagging without autofixes. Which is especially sensical with this rules as you may not want a "disable removal" to slip through unnoticed due to a bad configuration change.

Using the https://www.npmjs.com/package/eslint-plugin-no-autofix plugin:

'@eslint-community/eslint-comments/no-unused-disable': 'off',
'no-autofix/@eslint-community/eslint-comments/no-unused-disable': 'error',

In VSCode settings:

"eslint.codeActionsOnSave.rules": [
  // Clearing imports, unused vars and comments because of commented code while testing is annoying
  ...
  "!@eslint-community/eslint-comments/no-unused-disable",
  "*"
],

There is a RFC to obsolete eslint-plugin-no-autofix and include the functionality in base ESLint, but I need help completing that

The RFC currently doesn't even mention linterOptions.reportUnusedDisableDirectives as I just learned about it. I'll have to add it.

However, this rule is currently broken on flat-configs anyway, unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants