javascript - ES6 '...' notation gives error in jslint? - Stack Overflow

I get Unexpected token error whenever I run the code against jslint while using '...' notatio

I get Unexpected token error whenever I run the code against jslint while using '...' notation. I am using grommet-toolbox for Grommet UI (and UI/UX framework for React) and so when I run gulp dev mand I get this error, thereby not being able write code like below:

return {...state, fetching: true}

(The above code is in line 10 of this file: .js)

How to resolve this issue?

I get Unexpected token error whenever I run the code against jslint while using '...' notation. I am using grommet-toolbox for Grommet UI (and UI/UX framework for React) and so when I run gulp dev mand I get this error, thereby not being able write code like below:

return {...state, fetching: true}

(The above code is in line 10 of this file: https://github./learncodeacademy/react-js-tutorials/blob/master/5-redux-react/src/js/reducers/tweetsReducer.js)

How to resolve this issue?

Share Improve this question asked Jul 25, 2016 at 9:43 Harshith J.V.Harshith J.V. 8971 gold badge8 silver badges23 bronze badges 1
  • 1 It's not ES6/2015 and not ES2016 but not standardised syntax. You must use babel-eslint for it to work. – zerkms Commented Jul 25, 2016 at 9:53
Add a ment  | 

2 Answers 2

Reset to default 7

The Object spread operator is not a ECMASCRIPT STANDARD, while Array spread operator is. So, probably this is the reason of your lint-issue.

You can find further information here: https://github./sebmarkbage/ecmascript-rest-spread


Just a note, I suggest you to have a look at eslint because is the mon linter used for esnext (it is pluggable and maybe has a solution to avoid this issue).

Instead of using spread operator, please try to use Object.assign, they ought to acplish the same thing. Just without jshint outputting warnings/errors.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744980773a4604427.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信