Reputation: 2335
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?
Upvotes: 34
Views: 42160
Reputation: 46715
Add the following into your package.json
:
"jshintConfig": {
"esversion": 6
}
Upvotes: 6
Reputation:
I have this problem after I installed JSHint. The process for me to solve this problem as below: Preference -> setting -> Extensions -> JSHint Configuration -> options -> add "jshint.options": {"esversion": 6} Done.
Upvotes: 3
Reputation: 4524
You can do more project-specific settings by following these steps.
.vscode
at the root of your project directorysettings.json
{ "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
}
}
Upvotes: 19
Reputation: 725
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: -
"jshint.options": {},
"jshint.options": {"esversion": 6},
by clicking on Edit on the leftUpvotes: 57
Reputation: 2335
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:
Upvotes: 58