[英]arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6')
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文件没有被读取,因为我已经添加了这个条件。
.jshintrc .jshintrc
{
"esversion": 6
}
Gruntfile.js 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.无法在每个/*jshint esversion: 6 */
文件中添加/*jshint esversion: 6 */
。
Instead of above, please do below changes if you are using Visual Studio Code: -如果您使用的是 Visual Studio Code,请不要进行以上更改:-
"jshint.options": {},
寻找"jshint.options": {},
"jshint.options": {"esversion": 6},
by clicking on Edit on the left将其更改为"jshint.options": {"esversion": 6},
点击左侧的 EditYou can do more project-specific settings by following these steps.您可以按照以下步骤进行更多特定于项目的设置。
.vscode
at the root of your project directory在项目目录的根目录创建一个名为.vscode
的文件夹settings.json
创建一个名为settings.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
}
}
Add the following into your package.json
:将以下内容添加到您的package.json
:
"jshintConfig": {
"esversion": 6
}
I have this problem after I installed JSHint.我安装 JSHint 后遇到了这个问题。 The process for me to solve this problem as below: Preference -> setting -> Extensions -> JSHint Configuration -> options -> add "jshint.options": {"esversion": 6} Done.我解决这个问题的过程如下:首选项 -> 设置 -> 扩展 -> JSHint 配置 -> 选项 -> 添加 "jshint.options": {"esversion": 6} 完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.