[Solved] One esLint error I can't overcome

I’m trying to upgrade the Meteor Mantra Kickstarter to Meteor 1.3.4.1.

I have cleaned up all but one linting errors.

The problem is on line 13 of this file.

The error message is :

 13:22  error  Parsing error: Unexpected token .. 

Column 22 is the spread operator ( . . . ).

I have tried, unsuccessfully, to recreate the problem outside the app. It seems to be illegal JavaScript, but it works in jsx. Inspecting line 13 with browser developer tools, I see it has been redacted from . . .

  onData(null, {...user.profile, role, user, email, error});

. . . to . . .

  onData(null, (0, _extends3['default'])({}, user.profile, { role: role, user: user, email: email, error: error }));

I have searched the web for solutions and applied the following suggested settings to my .eslintrc file :

"env": {
  "es6": true,
"plugins": [
  "react"
],
"ecmaFeatures": {
   "objectLiteralShorthandMethods": true,
   "objectLiteralShorthandProperties": true,
   "restParams": true,
   "spread": true,

My package.json has the following relevant settings (not yet committed) :

"devDependencies": {
  "eslint": "^2.13.1",
  "eslint-plugin-react": "^5.5.2",

What else can I do ?

Make sure this is in your .eslintrc:

  "parserOptions": {
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true
    },
    "sourceType": "module"
  },

parser: "babel-eslint" will allow you to use the spread operator as well.

1 Like

Yep. Just make sure you do npm i --save-dev babel-eslint.

@ffxsam. Bullseye! In fact, I did have a parserOptions section with all of that … except "experimentalObjectRestSpread" : true. Putting that in fixed it immediately.

@aaronjudd, Sorry, I failed to mention that I was getting the same error in my Sublime Text 3 linting so I assumed I had all the right packages. I tried adding react-eslint anyway, but it did not solve the problem.

Thanks very, very much to both of you.

1 Like