80

I am using atom, and I've tried several different jshint packages and they all give a warning which says

"template literal syntax' is only available in ES6 (use 'esversion: 6')"

I created a top level .jshintrc file (at root), and added the following json:

{
  "esversion":6
}

However, it is still throwing the same error. Any ideas how to resolve. I've included the link to the JSHint options page. I'd like to start playing around with ES6 syntax, but would prefer not to have extra warnings.

Thanks SO community!

Ron I
  • 4,090
  • 8
  • 33
  • 64

9 Answers9

131

The filename should be .jshintrc, and the content is

{
  "esversion": 6
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Micheal Vu
  • 1,478
  • 1
  • 11
  • 15
77

Instead of creating .jshintrc file, you can simply add at the top of your js file:

/*jshint esversion: 6 */ 
Noam Manos
  • 15,216
  • 3
  • 86
  • 85
11

We have two choices.

1. Using .jshintrc file.

Create .jshintrc file in root directory and type as below. It applies to all codes

{
    "esversion": 6
}

If you're still getting warning, close and re-open your editor.


2. Using hint.

Type as below at the top of the your code. It applies to just the code.

/* jshint esversion: 6 */
Tony
  • 403
  • 5
  • 7
2

Remember to close then reopen your JS file / text editor.

nobody
  • 329
  • 2
  • 8
  • How do I set a filetype to `JSON`? – Shimon Brandsdorfer Aug 02 '17 at 16:14
  • 2
    @ShimonBrandsdorfer It depends on the code editor you are using. There are 2 ways in SublimeText 3: 1. Save the file to *.json 2. Select file's type in the bottom right corner (on status bar): there's a button, select JavaScript -> JSON. If there's no status bar at the bottom of the screen, go View -> Show Status Bar. – nobody Aug 09 '17 at 03:19
  • @lvnam96 I believe this is wrong. File is not supposed to be named `.jshintrc.json` The options you mention are just for syntax highlighting. – Magne Aug 08 '18 at 20:06
  • @Magne Yes, my comment is out of this question's scope because I answered it too late. The main thing is the thread owner updated his question aand I didn't notice his answer too. The accepted answer missed only one thing: reopen the JS file or restart the text editor. I just want to make the solution more clearly ;) I updated my answer for later coming people. – nobody Aug 16 '18 at 13:11
2

Has to be the first entry of the jshintrc file. Doesn't make much sense but that's what fixed it for me.

{
"esversion": 6,
"browser": true,
    ...
    ...
    ...
"globals": {... }
}
Timar Ivo Batis
  • 1,861
  • 17
  • 21
2

Create a file .jshintrc with content

{
    "esversion": 6
}

Put this file to your project root directory. Reopen your js file (no need restart atom). It will work for your current project.

Put this file to your home directory (eg: C, D, E, Desktop, Lirary,...). Reopen your js.file (no need restart atom). It will work for all project inside home directory

Linh
  • 57,942
  • 23
  • 262
  • 279
2

The config file in which you have enabled es6 should be enabled through your IDE; eg:for Intellij there's a clear option for adding config files.JSHint for Intellij

Rege
  • 41
  • 3
1

Using the atom packages linter and linter-jshint, I got it to work by uninstalling and then reinstalling the packages and then restarting atom. I did download ESLint and installed it per people's suggestions, looking forward to testing it out.

Ron I
  • 4,090
  • 8
  • 33
  • 64
0

I tried everything, but nothing worked for me. Adding

jshintrc: true,

in my grunt config file under jshint options solved it for me

jshint: {
        options: {
            jshintrc: true
        }
    }

Or you can try this https://stackoverflow.com/a/42097941/9016028

Anand Bhushan
  • 765
  • 8
  • 18