Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
[FIX] [no-this-alias] prevent crashes from declare statements (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher authored Jan 9, 2019
1 parent 4245290 commit c9d2227
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/rules/no-this-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ module.exports = {
)[0];

return {
VariableDeclarator(node) {
const { id, init } = node;
"VariableDeclarator[init.type='ThisExpression']"(node) {
const { id } = node;

if (init.type !== "ThisExpression") return;
if (allowDestructuring && node.id.type !== "Identifier") return;
if (allowDestructuring && id.type !== "Identifier") return;

if (!allowedNames.includes(id.name)) {
context.report({
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/no-this-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const [foo, bar] = this;
},
],
},
// https://github.com/bradzacher/eslint-plugin-typescript/issues/281
`
declare module 'foo' {
declare const aVar: string
}
`,
],

invalid: [
Expand Down

0 comments on commit c9d2227

Please sign in to comment.