admin管理员组文章数量:1334887
I am using eslint
for a javascript project. eslint
failed to parse spread operator and I got this error 11:18 error Parsing error: Unexpected token ..
.
The code for above error is:
return { ...render }
The eslint configuration is yml file:
env:
browser: true
es6: true
extends: 'eslint:remended'
parserOptions:
ecmaVersion: 2017
sourceType: module
experimentalObjectRestSpread: true
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-console:
- off
prefer-spread: "error"
I am using eslint
for a javascript project. eslint
failed to parse spread operator and I got this error 11:18 error Parsing error: Unexpected token ..
.
The code for above error is:
return { ...render }
The eslint configuration is yml file:
env:
browser: true
es6: true
extends: 'eslint:remended'
parserOptions:
ecmaVersion: 2017
sourceType: module
experimentalObjectRestSpread: true
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-console:
- off
prefer-spread: "error"
Share
Improve this question
edited Jan 19, 2019 at 4:51
Ry-♦
225k56 gold badges492 silver badges498 bronze badges
asked Jan 19, 2019 at 4:39
Joey Yi ZhaoJoey Yi Zhao
42.7k87 gold badges353 silver badges659 bronze badges
1
- Which version of ESLint are you using? – Ry- ♦ Commented Jan 19, 2019 at 4:52
2 Answers
Reset to default 6This is related to ESLint doesn't support spread operator in objects #10307, where full description of various alternatives on how to fix it is listed.
Essentially it boils down to changing to ecmaVersion: 2018
(or the equivalent ecmaVersion: 9
), which is when it first was officially supported. With this change there is also no need for the experimentalObjectRestSpread: true
any more.
The issue is fixed by add configuration: parser: 'babel-eslint'
本文标签: javascriptHow to enable eslint to parse spread operatorStack Overflow
版权声明:本文标题:javascript - How to enable `eslint` to parse spread operator? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742323593a2453282.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论