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

[FIX] [no-this-alias] prevent crashes from declare statements #282

Merged
merged 2 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/no-this-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
VariableDeclarator(node) {
const { id, init } = node;

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

if (!allowedNames.includes(id.name)) {
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