Skip to content

Commit

Permalink
fix: crash with dynamic/variable route name in no-shadow-route-defini…
Browse files Browse the repository at this point in the history
…tion rule
  • Loading branch information
bmish committed Mar 22, 2021
1 parent 38c16f3 commit 859d17c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/rules/no-shadow-route-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ module.exports = {
if (!ember.isRoute(node)) {
return;
}

if (node.arguments.length > 0 && node.arguments[0].type !== 'Literal') {
// Ignore dynamic/variable route names.
return;
}

const routeInfo = getRouteInfo(node);
if (
routeMap.has(routeInfo.route.fullPathWithGenericParams) &&
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-shadow-route-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ ruleTester.run('no-shadow-route-definition', rule, {
this.route('viewcollections', { path: 'viewcollections/:viewCollectionId' });
});`,

// With dynamic/variable route or path name:
'this.route(someVariable);',
"this.route('views', { path: someVariable })",

// Not Ember's route function:
'test();',
"test('blog');",
Expand Down

0 comments on commit 859d17c

Please sign in to comment.