Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExperimentalSpreadProperty nodes break rules #71

Open
mwpastore opened this issue Jul 7, 2017 · 1 comment
Open

ExperimentalSpreadProperty nodes break rules #71

mwpastore opened this issue Jul 7, 2017 · 1 comment
Labels

Comments

@mwpastore
Copy link

mwpastore commented Jul 7, 2017

Having ExperimentalSpreadProperty node properties in the tree seems to break at least no-2.0.0-hooks and no-side-effect-cp. The problem seems to be rooted in the assumption that each node property has a key property, but ExperimentalSpreadProperty node properties have neither key nor value properties. Is the fix as simple as modifying these rules to ignore node properties without key properties?

Node {
  type: 'ExperimentalSpreadProperty',
  start: 693,
  end: 718,
  loc: 
   SourceLocation {
     start: Position { line: 29, column: 6 },
     end: Position { line: 29, column: 31 } },
  range: [ 693, 718 ],
  argument: 
   Node {
     type: 'Identifier',
     start: 696,
     end: 718,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 696, 718 ],
     name: 'resolvedProjectPayload' } }
The Broccoli Plugin: [SimpleConcatConcat] failed with:
TypeError: Cannot read property 'name' of undefined
    at ObjectExpression.node.properties.forEach (/Users/mwp/Code/pow/juliet/node_modules/eslint-plugin-ember-best-practices/lib/rules/no-2.0.0-hooks.js:25:34)
    at Array.forEach (native)
    at Linter.ObjectExpression (/Users/mwp/Code/pow/juliet/node_modules/eslint-plugin-ember-best-practices/lib/rules/no-2.0.0-hooks.js:23:25)
// lib/rules/no-2.0.0-hooks.js
23: node.properties.forEach((property) => {
24:   console.log(property); // see above for output
25:   let name = property.key.name; // boom!
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Jul 7, 2017
@trentmwillis
Copy link
Member

Is the fix as simple as modifying these rules to ignore node properties without key properties?

This seems reasonable to me, though thorough test cases would help better confirm.

mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Aug 15, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Sep 1, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Sep 21, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Oct 3, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Oct 10, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Nov 8, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Nov 14, 2017
mwpastore added a commit to mwpastore/eslint-plugin-ember-best-practices that referenced this issue Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants