Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

FR: Error codes, for disabling specific errors, and for explaining errors #224

Closed
pickhardt opened this Issue · 5 comments

4 participants

@pickhardt

Request to use error codes, like Closure.
https://code.google.com/p/closure-linter/source/browse/trunk/closure_linter/errors.py

Then have a command to map from error codes to responsible rule(s) along with an explanation or two of why the rule may be important.

Example:
"jscs explain E101"
E101: Line too long.
This error is thrown by ruleset(s): maximumLineLength, [anything else would go here]

Rationale:
Long line can be hard to read and understand. Most projects require 80 characters, although some modern projects increase that to 120 characters.

If your code starts to get indented way to the right, consider breaking your code into more methods.

If you need a longer line for some reason, use parentheses or multiple strings.

BAD: if (condition1 && (condition2 || condition3) && condition4 && condition5)
GOOD: if (condition1 && (condition2 || condition3) &&
                condition4 && condition5)
BAD:  x = "some really really really really really really really long line";
GOOD:  x = "some really really really really " +  
                  "really really long line"

Finally, allow disabling specific errors temporarily, such as:

var x = "reallyreallyreallylonglinegoeshere"; // jscs ignore E101

// Or, alternatively, this might be good:
/* jscs ignore E101 */
var x = "reallyreallyreallylonglinegoeshere"; // jscs ignore E101
/* jscs unignore E101 */
@markelog
Owner

So i suppose we should add --verbose argument to cli module too?

@jzaefferer

Disabling specific errors with code comments should be handled separately (if at all).

Providing more details for each rule seems like a good idea. CSSLint does this via its wiki: https://github.com/stubbornella/csslint/wiki/Rules - though they don't have "error codes".

The above example is fine, but most errors will be way too trivial to provide any details. If my code is function(){ and it should be function() {, what could you possibly be verbose about?

@jzaefferer

Disabling all validation was requested by #20.

@mikesherov mikesherov added this to the 1.6 milestone
@mikesherov mikesherov removed the cli label
@mikesherov mikesherov modified the milestone: 1.6
@mikesherov
Owner

Thanks for contributing! All of our rules are named, and therefore this should be satisfied with outputting the rule name if verbose is supplied. I'm going to file a new issue with that as the request. Thanks again!

@mikesherov mikesherov closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.