Skip to content

Commit

Permalink
fix(eslint-plugin): don’t mark declare class as unused (#110)
Browse files Browse the repository at this point in the history
fixes #106
  • Loading branch information
j-f1 committed Jan 22, 2019
1 parent 819b640 commit 5841cd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/eslint-plugin/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ module.exports = Object.assign({}, baseRule, {
},
'*[declare=true] Identifier'(node) {
context.markVariableAsUsed(node.name);
const scope = context.getScope();
const { variableScope } = scope;
if (variableScope !== scope) {
const superVar = variableScope.set.get(node.name);
if (superVar) superVar.eslintUsed = true;
}
}
});
}
Expand Down
7 changes: 7 additions & 0 deletions packages/eslint-plugin/tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ declare namespace Foo {
declare var Foo: {
new (value?: any): Object,
foo(): string
}
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/106
`
declare class Foo {
constructor(value?: any): Object;
foo(): string;
}
`,
`
Expand Down

0 comments on commit 5841cd2

Please sign in to comment.