Skip to content

Commit

Permalink
[evcohen/eslint-plugin-jsx-a11y#399] Accommodate ExperimentalSpreadPr…
Browse files Browse the repository at this point in the history
…operty in prop values
  • Loading branch information
jessebeach committed Mar 17, 2019
1 parent a1e5007 commit ffa911c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions __tests__/src/getPropValue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,15 @@ describe('getPropValue', () => {

assert.deepEqual(expected, actual);
});

it('should evaluate to a correct representation of the object, ignore spread properties', () => {
const prop = extractProp('<div foo={{ pathname: manageRoute, state: {...data}}} />');

const expected = { pathname: 'manageRoute', state: {} };
const actual = getPropValue(prop);

assert.deepEqual(expected, actual);
});
});

describe('New expression', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/values/expressions/ObjectExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import getValue from './index';
export default function extractValueFromObjectExpression(value) {
return value.properties.reduce((obj, property) => {
const object = Object.assign({}, obj);
if (property.type === 'SpreadProperty') {
// Support types: SpreadProperty and ExperimentalSpreadProperty
if (/SpreadProperty/.test(property.type)) {
if (property.argument.type === 'ObjectExpression') {
return Object.assign(object, extractValueFromObjectExpression(property.argument));
}
Expand Down

0 comments on commit ffa911c

Please sign in to comment.