How to set jslint ES6 directive in brackets?
I am getting this error: "I was expecting an identifier and saw 'const' instead, I am using a parenthesis text editor. I found this answer:" You need to specify the es6 directive. See JSLint Help. But I cannot figure out how to specify the es6 directive in parentheses. 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 great if I use var.
source to share
One file
If I remember correctly, you put the following at the very top of the file:
/*jslint es6:true*/
Wide project coverage
If you want all files in your project to be ES6 compliant, you can add the file .brackets.json
to the root of your project.
Wide brackets
If you want all files to be ES6 compliant, you can change your custom global settings by clicking the following menu items: Debug -> Open Preferences
and then adding the property jslint.options
to your preference.
For more information, see "Usage-Brackets: Preferences" .
However, I just tried to do this with my brace setup, with all extensions disabled and the brackets not understanding the directive. I think Brackets has a very old version of jslint installed by default. You can use some extensions to try and complement the older version.
I ended up installing brackets-jshint and changing the brackets settings file to use the default jshint with the following parameter:
{
"language": {
"javascript": {
"linting.prefer": [
"JSHint"
],
"linting.usePreferredOnly": true
}
}
}
source to share
Try tagging the comment at the top of the file like this as described in the 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;
source to share