How to set the jslint ES6 directive in Brackets?
Asked Answered
C

2

6

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.

Colley answered 21/6, 2017 at 20:57 Comment(0)
C
8

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
        }
    }
}
Crackleware answered 21/6, 2017 at 21:2 Comment(0)
L
0

Try putting a comment at the top of the file like this, as documented in JSLint Help...

/*jslint
    es6
*/

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;
Lymphangitis answered 21/6, 2017 at 21:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.