Skip to content

Commit

Permalink
Merge pull request #932 from bmish/fix-spread-route-path-style
Browse files Browse the repository at this point in the history
Fix spread syntax crash in `route-path-style` rule
  • Loading branch information
bmish committed Sep 7, 2020
2 parents b51433c + 5aa81a6 commit e3746be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rules/route-path-style.js
Expand Up @@ -64,7 +64,12 @@ function hasPropertyWithKeyName(objectExpression, keyName) {
}

function getPropertyByKeyName(objectExpression, keyName) {
return objectExpression.properties.find((property) => property.key.name === keyName);
return objectExpression.properties.find(
(property) =>
types.isProperty(property) &&
types.isIdentifier(property.key) &&
property.key.name === keyName
);
}

function getStaticURLSegments(path) {
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/route-path-style.js
Expand Up @@ -16,6 +16,7 @@ const ruleTester = new RuleTester({
ecmaVersion: 6,
sourceType: 'module',
},
parser: require.resolve('babel-eslint'),
});
ruleTester.run('route-path-style', rule, {
valid: [
Expand Down Expand Up @@ -61,6 +62,7 @@ ruleTester.run('route-path-style', rule, {
'this.route("blog", { otherField: "/blog_posts" });',
'this.route("blog", { otherField: "/blog_posts", path: "/blog" });',
'this.route("blog-posts", { otherField: "/blog_posts" });',
'this.route("blog-posts", { ...foo });',

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

0 comments on commit e3746be

Please sign in to comment.