Take the 2-minute tour ×

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?

share|improve this question
Is it worth all this trouble to avoid having to type semicolons? –  Pointy Jul 17 '12 at 13:35
There are good reasons why avoiding automatic semi-colon insertion is recommended –  Quentin Jul 17 '12 at 13:36
The point of JSHint isn't just to validate that you are writing javascript that parses. You can just try running it for that. While there's certainly different philosophies on ASI, when it comes to writing one really ugly construct to avoid another one, is it really better? Putting a semicolon before a function def is a workaround in the first place, it seems legit that JSHint wouldn't validate it. –  Jamie Treworgy Jul 17 '12 at 13:39
guys i really care and understand your point of view, but this isn't a debate about the semicolon insertion, it's about a jshint warning =) –  Luke Jul 17 '12 at 13:39
Are you using any other JSHint options? Because I am not getting those errors when using jshint.com. –  George P Jul 17 '12 at 13:47
show 1 more comment

1 Answer

up vote 3 down vote accepted

The legacy white: true option in JSHint is used to enforce the coding style promoted by Douglas Crockford in his original JSLint tool. Semicolon-less javascript will not fit his coding style. If you don't want to be restricted to his style guidelines then don't use white: true.

This list of JSHint options shows no parameters to customize the coding style they enforce.

To prove that there is no answer to this, I went and found the relevant check in the jshint source:

function nonadjacent(left, right) {
    if (option.white) {
        left = left || token;
        right = right || nexttoken;
        if (left.line === right.line && left.character === right.from) {
            left.from += (left.character - left.from);
            warning("Missing space after '{a}'.",
                    left, left.value);

The only configuration option checked is option.white, so unfortunately there is no way to achieve your desired behavior. If you really wanted a tool that would do exactly what you want, you could easily fork jshint and add another option and check it in the nonadjacent function.

share|improve this answer
add comment

Your Answer


