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?
Introduction. The 2015 edition of the ECMAScript specification (ES6) added arrow function expressions to the JavaScript language. Arrow functions are a new way to write anonymous function expressions, and are similar to lambda functions in some other programming languages, such as Python.
Arrow Function Syntax The syntax of the arrow function is: let myFunction = (arg1, arg2, ...argN) => { statement(s) } Here, myFunction is the name of the function. arg1, arg2, ... argN are the function arguments.
The arrow function concept was introduced in ES6. With the help of this, we can write a shorter and concise syntax for a normal function which we used to write in ES5. Note: In arrow function, if there is only one statement then we don't even need to use '{}' curly braces.
ES6 provides a feature known as Arrow Functions. It provides a more concise syntax for writing function expressions by removing the "function" and "return" keywords. Arrow functions are defined using the fat arrow ( => ) notation.
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:
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 leftIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With