JSHINT error: Expected 'combine' to have an indentation at 9 instead at 13

I like the idea behind JSLINT but sometimes it is a little too strict, in my opinion needlessly so.

Recently I found JSHINT. It's a little more flexible, allows more options to be turned on or off.

But JSHINT is throwing an error on code that I think looks right. For example, JSHINT barfs on its own code. If I run JSHINT on JSHINT.js, it gives me this:

JSHINT error: Expected 'combine' to have an indentation at 9 instead at 13

I don't understand that. See the error message near the bottom of that image? JSHINT seems to want the indentation to be different than it is. It's not complaining about the lack of the curly. I have curly:false which says to not require curlies around one-liner if statements.

The odd thing is, JSHINT.js source code uses a 4-space indent everywhere, but it throws errors about the indent only for these few lines. Why?

Am I doing this wrong? Is there something else I should be configuring?



EDITED - originally I had been playing around with JSHINT, and I put the combine() call on the same line as the if statement. I've reverted the JSHINT code back to what it was originally, to show that the errors remain.

JSHINT error: Expected 'combine' to have an indentation at 9 instead at 13

This is done with JSHINT using these options:

options = { curly : false, // no curly fascism wsh : true, // WScript is allowed white : true, // true: 'sloppy' whitespace is ok plusplus : false, // false == ok to use ++ passfail : false // do not stop after first error //radix : true // do not puke on parseInt() with no radix };


EDIT2

Here's a gif that shows what JSHINT, in its original form, really wants. When the red highlights disappear, it means JSHINT is happy for that particular line. (This is using flymake-for-jslint in emacs).

JSHINT error: Expected 'combine' to have an indentation at 9 instead at 13

As you can see, if I indent the line in an odd way, JSHINT relaxes.

Answer

I think the answer is in this github issue. I modified JSHINT, line 2264, like this:

*************** *** 2256,2262 **** --- 2261,2270 ---- nexttoken, '{', nexttoken.value); noreach = true; + // cheeso - fix for https://github.com/jshint/jshint/issues/87 + indent += option.indent; a = [statement()]; + indent = old_indent; noreach = false; }

...and it stopped complaining about its own formatting.

-------------Problems Reply------------

JSHint maintainer here. Based on your screenshot, it errors because the combine is on the same line as your if clause which is against white option's rules.

Are you sure that your copy of JSHint was not modified by anybody? We have unit tests for JSHint and one of the tests checks JSHint's own source code with itself. And, as you can see from the attached example, everything passes just fine.

JSHINT error: Expected 'combine' to have an indentation at 9 instead at 13

I think the answer is in [this github issue][4]. I modified JSHINT, line 2264, like this:

***************
*** 2256,2262 ****
--- 2261,2270 ----
nexttoken, '{', nexttoken.value);

noreach = true;
+ // cheeso - fix for https://github.com/jshint/jshint/issues/87
+ indent += option.indent;
a = [statement()];
+ indent = old_indent;
noreach = false;
}

...and it stopped complaining about its own formatting.

Category:emacs Views:0 Time:2011-09-15

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.147 (s). 11 q(s)