diff --git a/lib/rules/no-shadow-route-definition.js b/lib/rules/no-shadow-route-definition.js index 2ac901c8b8..e8fa151156 100644 --- a/lib/rules/no-shadow-route-definition.js +++ b/lib/rules/no-shadow-route-definition.js @@ -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) && diff --git a/tests/lib/rules/no-shadow-route-definition.js b/tests/lib/rules/no-shadow-route-definition.js index cb529de55e..693833bf2e 100644 --- a/tests/lib/rules/no-shadow-route-definition.js +++ b/tests/lib/rules/no-shadow-route-definition.js @@ -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');",