I’m linting my JavaScript with JSHint, and have this option enabled
"asi": true,
"white": true
to avoid semicolons in my code.
But I have to begin my new line with a bracket, so I have to put a semicolon before the opening of that one
;(function () {
})
JSHint give me two errors:
- Missing space after ‘;’
- If I put a space after ‘;’ I get: Expected ‘(‘ to have a different identation
I noticed that in this way JSHint is happy
;
(function () {
})
but I think is not a good solution.
Is there a way to solve this problem, without turning off JSHint or the white option?
The legacy
white: trueoption in JSHint is used to enforce the coding style promoted by Douglas Crockford in his original JSLint tool. Semicolon-less JavaScript code will not fit his coding style. If you don’t want to be restricted to his style guidelines then don’t usewhite: true.This list of JSHint options doesn’t show any parameters to customize the coding style they enforce.
To prove that there isn’t an answer to this, I went and found the relevant check in the JSHint source:
The only configuration option checked is
option.white, so unfortunately there isn’t any way to achieve your desired behavior. If you really wanted a tool that would do exactly what you want, you could easily fork JSHint, add another option, and check it in thenonadjacentfunction.