Why does JSHint throw a warning if I am using const?

后端 未结 17 2964
眼角桃花
眼角桃花 2020-12-12 08:18

This is the error I get when using const:



        
相关标签:
17条回答
  • 2020-12-12 08:49

    In your package.json you can tell Jshint to use es6 like this

    "jshintConfig":{
        "esversion": 6 
    }
    
    0 讨论(0)
  • 2020-12-12 08:50

    You can add a file named .jshintrc in your app's root with the following content to apply this setting for the whole solution:

    {
        "esversion": 6
    }
    

    James' answer suggests that you can add a comment /*jshint esversion: 6 */ for each file, but it is more work than necessary if you need to control many files.

    0 讨论(0)
  • 2020-12-12 08:53

    If you are using Webstorm and if you don't have your own config file, then just enable EcmaScript.next in Relaxing options in in

    Settings | Languages & Frameworks | JavaScript | Code Quality Tools | JSHint

    See this question How-do-I-resolve-these-JSHint-ES6-errors

    0 讨论(0)
  • 2020-12-12 08:56

    In a new version of Dreamweaver to solve this error

    • Go to Edit->Preference->Linting
    • And the go-to js Edit rule set and past

      "jshintConfig":{ "esversion": 6 }

    0 讨论(0)
  • 2020-12-12 08:59

    I spent ages trying to fix this. Every solution talks about 'setting options'. I don't know what that means. Finally, I figured it out. You can just include a commented out line at the top of the file /*jshint esversion: 6 */.

    0 讨论(0)
  • 2020-12-12 09:00

    To fix this in Dreamweaver CC 2018, I went to preferences, edit rule set - select JS, edit/apply changes, find "esnext" and changed the false setting to true. It worked for me after hours of research. Hope it helps others.

    0 讨论(0)
提交回复
热议问题