It’s not set up to lint ES6. Possibly adding /* jshint esversion: 6 */ at the top should fix it (not sure as been a very long time since I used jshint).
Ah, try adjusting the comment to /*jslint es6 */. I suspect it will still break, jslint is very old and has been superceded (first by jshint, now eslint), it isn’t commonly used at all. Although Douglas Crockford does still seem to be maintaining it, the test validator on his site doesn’t recognise several things for me (it completely blows up when I try to ise class for example).
JSLint intends arrow functions to be used for one-line expressions (parameters) => expression , source. So use a function here instead. Here’s the explanation.
If a function requires braces to contain its body, don’t use an arrow function. Save arrow functions for single expressions where the overloading of the brace character will never cause an error.
Ah, I missed that. That’s seems really bad rule if it’s not overridable, given that arrow functions are to avoid issues with this as well!
@javascriptcoding5678 don’t use jslint would be the best solution, if it isn’t configurable enough to deal with common usage, use something that is. It was really good and useful when it came out (2011 I think?), but it’s been completely superceded
I didn’t know that was a jslint rule, but that is my personal (usual) policy: an arrow for single line function for multi line. Granted I’m not hard and fast on that, and as you mentioned there are things like playing with this that make you want to change it up. Honestly, I mostly do it that way cause I think it’s prettier.
A bit “old man shouting at the kids to get off his lawn” now though. Doesn’t like [eg] classes (for fairly reasonable reasons!), but that means his linter just forbids using them, so it’s kinda useless unless you’re writing all of the code according to his fairly strict principles 🤷
Again, though, in the case of jslint, he invented the game, so he gets to set the rules. Coders in the trenches may see him as a crank, but management and others in the pseudo-know like the red tape he (and jslint) provides.
It’s summed up in this quote, I think, also from that page:
JSLint defines a professional subset of JavaScript, a stricter language than that defined by the ECMAScript Programming Language Standard (the strangely named document that governs JavaScript).
JSLint will reject most legal programs. It is a higher standard.
Anyway, we may be getting off-topic. In summary, jslint doesn’t like arrow functions in their expanded format, by the conscious choice of its creator.