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

I am currently running my tests using protractor / grunt, but I am getting the following error message:

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

I think my .jshintrc file is not readable because I 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?

+8
source share
4 answers

I managed to solve this problem by adding this block of code to the beginning of each file.js file that blamed the error

 /*jshint esversion: 6 */ 

Example:

enter image description here

+27
source

Unable to add /*jshint esversion: 6 */ to each file.js.

Instead, please make the following changes if you are using Visual Studio code: -

  1. Open Visual Studio Code
  2. File β†’ Settings β†’ Settings
  3. Default user settings -> JSHint configuration
  4. look for "jshint.options": {},
  5. change it to "jshint.options": {"esversion": 6}, by clicking on Edit on the left
+16
source

If the IDE supports extensions, install jshint extension :)

0
source

You can make more project-specific settings by doing the following:

  1. Create a folder named .vscode in the root directory of your project.
  2. Create a file called settings.json
  3. Add the following content to it.
 { "jshint.options": { "esversion": 6 } } 

You can add a few more settings to maintain consistency in your team.

 { "editor.tabSize": 2, "editor.formatOnSave": true, "editor.formatOnType": true, "jshint.options": { "esversion": 6 } } 
0
source

Source: https://habr.com/ru/post/1265624/


All Articles