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?
It is not possible to add /*jshint esversion: 6 */
in each file.js file.
Instead of above, please do below changes if you are using Visual Studio Code: -
- Open Visual Studio Code
- File -> Preferences -> Settings
- Default User Settings -> JSHint configuration
- look for
"jshint.options": {},
- change it to
"jshint.options": {"esversion": 6},
by clicking on Edit on the left
You can do more project-specific settings by following these steps.
- Create a folder with the name of
.vscode
at the root of your project directory - Create a file with the name
settings.json
- Add the following content into it.
{ "jshint.options": { "esversion": 6 } }
You can add some more settings to keep things consistents across your team.
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"jshint.options": {
"esversion": 6
}
}
来源:https://stackoverflow.com/questions/42866159/arrow-function-syntax-is-only-available-in-es6-use-esversion-6