Skip to content

Commit 58e1ddd

Browse files
authored
Add @eslint-community/eslint-comments dependency (#26)
@eslint-community/eslint-comments can replace eslint-plugin-bestpractices as it is a community-wide eslint plugin. https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/ to see the rules. The rule that specifically replaces the old bestpractices/no-eslint-disable is require-description. It does basically the same. The difference is that it only affects real eslint-disable directives. For example, it doesn't affect `// eslint-disable-next` as that doesn't actually disable any linting rules. See https://eslint.org/docs/latest/use/configure/rules. The plugin adds its recommended rules automatically. Those rules are: disable-enable-pair, no-aggregating-enable, no-duplicate-disable, no-unlimited-disable, no-unused-disable, no-unused-enable. They are all treated as errors. The only way to turn them off is to turn them off individually as the plugin doesn't allow consumers to just get the plugin and define which rules to turn on. I do think those rules are nice to have though, so I think it is fine to keep them. I particularly like the no-unlimited-disable to make developers be specific on what they are disabling. I updated the example test to do a common eslint disable directive (eslint-disable-next-line) that actually disables a eslint rule on the next line. This triggers both the @eslint-community/eslint-comments/require-description and @eslint-community/eslint-comments/no-unlimited-disable rules.
1 parent 0fa1036 commit 58e1ddd

File tree

6 files changed

+108
-73
lines changed

6 files changed

+108
-73
lines changed

demo/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
rules: {
3-
'bestpractices/no-eslint-disable': 'error',
43
'sonarjs/no-duplicated-branches': 'error',
54
'deprecate/function': ['error', { name: 'deprecatedFunction', use: 'function x from package y' }],
65
'deprecate/import': ['error', { name: 'path/to/legacyModule', use: 'module x' }],

demo/example.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
/*
66
* Since developers have the ability to disable linting in-line, we keep track of the times where this is done, because if done irresponsibly, this is a significant code smell.
77
*/
8-
// eslint-disable-next
8+
// eslint-disable-next-line
9+
let unusedVariableThatTriggersLintingRule
10+
11+
// eslint-disable-next-line no-unused-vars -- A comment to remove the warning of "require-description"
12+
let unusedVariableThatTriggersLintingRule2
913

1014
// fixMe: Actually make this work
1115
// todo: Add documentation

0 commit comments

Comments
 (0)