arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6')

Rafael C. picture Rafael C. · Mar 17, 2017 · Viewed 27.2k times · Source

Currently I'm running my tests with protractor/grunt but I'm getting the follow error message:

'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

I think my .jshintrc file is not being read, because I've added this condition.

.jshintrc

{ 
  "esversion": 6 
}

Gruntfile.js

jshint : {
  all: ["tests/API/**/*.js"],
  options: {
    undef: true,
    mocha: true,
    node: true,
    jshintrc: true,
    esversion: 6,
    globals: {
      require: true,
      module: true,
      console: true,
      esversion: 6,
      }
  },
  ui: ["tests/UI/**/*.js"],
  options: {
    undef: true,
    mocha: true,
    node: true,
    jshintrc: true,
    esversion: 6,
    globals: {
      require: true,
      module: true,
      console: true,
      esversion: 6,
      jshintrc: true,
    }
  }
}

Any idea to solve this problem?

Answer

Rafael C. picture Rafael C. · Mar 18, 2017

I was able to resolve this issue by adding this block of code at the top of each file.js that accused the error

/*jshint esversion: 6 */

Example:

enter image description here