Skip to content

Commit

Permalink
fix(eslint-plugin): no-unused-vars: mark declared statements as used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 authored and JamesHenry committed Jan 20, 2019
1 parent b321736 commit 2df5e0c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/eslint-plugin/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ module.exports = Object.assign({}, baseRule, {
},
'TSEnumMember Identifier'(node) {
context.markVariableAsUsed(node.name);
},
'*[declare=true] Identifier'(node) {
context.markVariableAsUsed(node.name);
}
});
}
Expand Down
16 changes: 16 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 @@ -525,6 +525,22 @@ import * as fastify from 'fastify'
import { Server, IncomingMessage, ServerResponse } from 'http'
const server: fastify.FastifyInstance<Server, IncomingMessage, ServerResponse> = fastify({})
server.get('/ping')
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/61
`declare function foo();`,
// https://github.com/typescript-eslint/typescript-eslint/issues/61
`
declare namespace Foo {
function bar(line: string, index: number | null, tabSize: number): number;
var baz: string;
}
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/61
`
declare var Foo: {
new (value?: any): Object,
foo(): string
}
`
],

Expand Down

0 comments on commit 2df5e0c

Please sign in to comment.