Skip to content

Commit

Permalink
fix: crash in no-controller-access-in-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Aug 17, 2021
1 parent d0a7a73 commit a10df4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rules/no-controller-access-in-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ module.exports = {
return;
}

if (node.init.type !== 'ThisExpression' || node.id.type !== 'ObjectPattern') {
if (
!node.init ||
node.init.type !== 'ThisExpression' ||
!node.id ||
node.id.type !== 'ObjectPattern'
) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/no-controller-access-in-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ ruleTester.run('no-controller-access-in-routes', rule, {
const { foo } = this;
const { controller } = bar;
},
myAction2() {
const controller = this;
},
myAction3() {
let controller4;
},
},
});
`,
Expand Down

0 comments on commit a10df4a

Please sign in to comment.