eslint-plugin-ember-best-practices
eslint-plugin-ember-best-practices copied to clipboard
ExperimentalSpreadProperty nodes break rules
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!
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.