Question

I find that JSLint produces lots of warnings of the form:

Expected 'foo' to have an indentation at X instead at Y.

The JSLint options documentation describes an indent option that recognizes a numerical value representing the amount of space for each level of indentation. This option allows me to say things like use 2 spaces per level of indentation. I just write something like this at the top of my JavaScript file:

/*jslint indent: 2 */

OK, great. Now JSLint knows how much to indent for each level of indentation, but JSLint seems to be hardcoded to decide what level of indentation each line should have.

Suppose I want to indent my code differently than the way JSLint prescribes. Can I do this with some JSLint option? If not, can I at least turn off the indentation warnings? I tried:

/*jslint indent: false */

but that did not cause indentation warnings to be elided; it caused a JSLint error.

Was it helpful?

Solution

What a difference that morning coffee makes:

/*jslint white: true */

OTHER TIPS

If you don't want to disable JSLint, you can remove the double indentations (e.g. when defining multiple var's in a javascript file) by adjusting this setting:

Options > Editor > Formatting > Language: Javascript > Continuation Indentation - set to 4.

Now you can use ctrl shift f to format code, and JSLint doesn't freak out...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top