Reputation: 2338
I have my ESLint all set up and working, but I want it to throw errors whenever I don't use ES6 stuff like let
, const
or arrow functions (=>
).
{
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"semi": 2
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script",
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
"blockBindings": true,
"classes": true
}
}
}
Currently, this will not throw errors for:
var stars = [];
var speed = 20;
function setup() {
createCanvas(windowWidth, windowHeight);
// Create 1000 stars
for (var i = 0; i < 1000; i++) {
stars.push(new Star());
}
}
Upvotes: 2
Views: 5062
Reputation: 15019
You don't use i
in your for loop so it's not an error.
You can use the no-var
rule but it will effect everything, not only for loops.
If you would have used i
in your for loop, then the no-loop-func
rule is what you are looking for.
If you prefer arrow functions as callbacks you can use prefer-arrow-callback
.
Upvotes: 2
Reputation: 92579
You can use the prefer-arrow-callback
rule to enforce using arrow functions as callbacks.
Also the prefer-const
rule enforces using const
whenever possible (i.e. if the variable is never reassigned).
Upvotes: 6