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

我只是一个虾纸丫 提交于 2019-12-03 06:10:18

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: -

  1. Open Visual Studio Code
  2. File -> Preferences -> 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

You can do more project-specific settings by following these steps.

  1. Create a folder with the name of .vscode at the root of your project directory
  2. Create a file with the name settings.json
  3. 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
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!