Consider `argsIgnorePattern` for `no-unused-vars` rule
joshuacurtiss opened this issue · 1 comments
There are instances, such as implementing/extending a class with a function that has an argument that your implementation won't use, which will trigger the no-unused-vars eslint rule.
Typically, we may just disable no-unused-vars
when this occurs, such as here:
https://github.com/silvermine/service-web/blob/77db28f0/service-web-core/src/model/Web.ts#L48
In these cases, we nearly always use a prepended underscore by convention to signify the arg is unused, but still have to disable the rule.
If we modify the rule like this:
'no-unused-vars': [ 'error', { 'argsIgnorePattern': '^_' } ],
Then the convention we are already using will automatically be ignored by the rule and we'll no longer have to explicitly disable the rule with an eslint-disable-line
comment.
diff --git a/index.js b/index.js
index f8b966b..25051e9 100644
--- a/index.js
+++ b/index.js
@@ -140,7 +140,7 @@ module.exports = {
'no-shadow-restricted-names': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
- 'no-unused-vars': 'error',
+ 'no-unused-vars': [ 'error', { 'argsIgnorePattern': '^_' } ],
'no-use-before-define': [ 'error', { 'functions': false } ],
'callback-return': [ 'error', [ 'callback', 'cb', 'next', 'done' ] ],
@@ -284,7 +284,7 @@ module.exports = {
// The standard ESLint `no-unused-vars' rule will throw false positives with
// class properties in TypeScript. The TypeScript-specific rule fixes this.
'no-unused-vars': 'off',
- '@typescript-eslint/no-unused-vars': 'error',
+ '@typescript-eslint/no-unused-vars': [ 'error', { 'argsIgnorePattern': '^_' } ],
// For TypeScript code, `const`/`let` should be used exclusively
'no-var': 'error',
// new-cap throws errors with property decorators
I like it. @onebytegone thoughts?