Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the jslint ES6 directive in Brackets?

I get this error: "expected an identifier and instead saw 'const'", I'm using brackets text editor. I found this answer: "You need to specify the es6 directive. See JSLint Help". But I can't figure it out how to specity the es6 directive in brackets. Here's my code:

const singleQuotes = '<p>Single quotes</p>';
const doubleQuotes = "<p>Double quotes</p>";
const stringLiterals =  `<p>String literlas</p>`;

const result = singleQuotes + doubleQuotes + stringLiterals;
document.querySelector('.basic').innerHTML = result;

I appreciate any help. It works fine if I use var.

like image 799
Angel Avatar asked Jun 21 '17 20:06

Angel


1 Answers

One File

If I remember right, you put the following at the very top of your file:

/*jslint es6:true*/

Project Wide

If you want all files in your project to abide ES6, you can add a .brackets.json file to the root of your project.

Brackets Wide

If you want all files to abide ES6, you can modify your User-global preferences by clicking the following menu items: Debug -> Open Preferences and then adding the jslint.options property to your preferences.

See How-to-Use-Brackets: Preferences for more information.


However, I just tried to do this with my Brackets installation with all extensions disabled and Brackets doesn't understand the directive. I think Brackets has a very old version of jslint installed by default. You may want to use some extensions to try to supplement the old version.

What I ended up doing was installing the brackets-jshint and changing my brackets preferences file to use jshint by default with the following option:

{
    "language": {
        "javascript": {
            "linting.prefer": [
                "JSHint"
            ],
            "linting.usePreferredOnly": true
        }
    }
}
like image 199
zero298 Avatar answered Nov 08 '22 05:11

zero298