Open
Description
We get this error Cannot read property 'expression' of undefined
as eslint output when using
const a = {};
const foo = () => (
<Link
to={{
pathname: '/bar',
query: { ...a },
}}
/>
);
and .eslintrc:
{
"extends": [
"eslint:recommended",
],
"plugins": ["jsx-a11y"],
"env": {
"browser": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"experimentalObjectRestSpread": true,
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"no-unused-vars": "warn",
"jsx-a11y/anchor-is-valid": ["warn", {
"components": ["Link"],
"specialLink": [ "to" ],
"aspects": ["noHref", "invalidHref", "preferButton"]
}]
}
}
here's a passing test:
{
code: '<Anchor hrefLeft={{ foo: { test: 1 } } }} />',
options: componentsAndSpecialLinkAndNoHrefAspect,
},
and a failing test, when object spread is used (even with experimentalObjectRestSpread
in parserOptions
or babel-eslint
as parser with the right .babelrc..):
{
code: '<Anchor hrefLeft={{ foo: { ...{ test: 1 } } }} />',
options: componentsAndSpecialLinkAndNoHrefAspect,
},
Message:
A fatal parsing error occurred: Parsing error: Unexpected token ...
I reported the error in eslint originally: eslint/eslint#9960 (comment)
@AlmeroSteyn I can try to solve it, if you have any advices maybe?