Atom Error: ‘Const’ is available in ES6 (use ‘esversion: 6’)

I recently upgraded to using the Atom editor to do a majority of my coding. I shied away from it at first because I experienced an error that caused it to eat up all of my memory constantly. Now, months later, they seem to have addressed that issue and it works great! I like it almost as much as Sublime Text now, and feel like I’m going to enjoy it even more soon.

But, as I was progressing through the SurviveJS book recently I found that the JSHint linter I was using didn’t play nice with ES6. Every time I would use something ES6-y like:

My linter would blow up, red all over.

Specifically the error said: “‘const’ is available in ES6 (use ‘esversion: 6’) or Mozilla JS extensions (use moz). (W104)”. Initiating Google-fu yielded unhelpful results. After digging though, here is the fix for this problem.

JSHint has to be configured with a .jshintrc file in the project’s root directory. Simply create a .jshintrc file there with the following object:

Save. Problem solved! Don’t know why this has to be so complicated but hopefully this will save you time going through your Atom package settings uselessly.

4 thoughts on “Atom Error: ‘Const’ is available in ES6 (use ‘esversion: 6’)

  1. Thanks. That was helpful.
    One thing I would like you to add in the article is to mention how to create a .jshintrc file. I thought it was an extension (like .json) and so I created es6.jshintrc and as expected that didn’t work. After fiddling a little, I created a simple .jshintrc file and that worked. It would be helpful for novice programmers like me.

      • I already have a .jshintrc file. Its contents are as follows
        {
        “curly”: true,
        “eqeqeq”: true,
        “immed”: true,
        “latedef”: true,
        “newcap”: true,
        “noarg”: true,
        “sub”: true,
        “undef”: true,
        “boss”: true,
        “eqnull”: true,
        “browser”: true,
        “smarttabs”: true,
        “globals”: {
        “jQuery”: true,
        “angular”: true,
        “console”: true,
        “$”: true,
        “_”: true,
        “moment”: true,
        “describe”: true,
        “beforeEach”: true,
        “module”: true,
        “inject”: true,
        “it”: true,
        “expect”: true,
        “xdescribe”: true,
        “xit”: true,
        “spyOn”: true
        }
        }

        When i try to add
        {
        “esversion”: 6
        }, it still gives me an error

        • You may be breaking the JSON structure, expected by jshint. Try putting a single line:
          “esversion”: 6,
          note the comma at the end, between smarttabs and globals.

          Also, creating the .jshintrc file in an user’s home directory enables it for all projects by that user.

          Cheers!

Comments are closed.