Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a list of JSHint numeric error codes?

I'm using JSHint for Visual Studio. It's not uncommon for JSHint to issue a warning about an issue that I know it safe to ignore. I have been putting // ignore jslint on the relevant line, but I see that we can also ignore specific error codes. From the 1.0.0 rc1 release notes:

This version adds a unique numeric code to every warning and error message produced by JSHint. That means that you can now ignore any warning produced by JSHint even when there is no corresponding option for it. You can do that using the special minus (-) operator. For example, here’s how you ignore all messages about trailing decimal points (W047):

/*jshint -W047 */

Seems cool, but try as I might, I cannot find a list of all the error codes. Visual Studio's warning list doesn't provide you with the numeric error code, just the error text.

Surely this list is out there somewhere, right? I've literally spent an hour Googling for this. But no success so far.

like image 293
Josh Avatar asked Jul 08 '13 20:07

Josh


2 Answers

The best place to look for things like that is the source (which is available on GitHub). The file you're looking for is messages.js (versions: current release (2.9.5, 2017-06-22), master branch, 2.1.4 (source for the code below)):

var warnings = {     W001: "'hasOwnProperty' is a really bad name.",     W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",     W003: "'{a}' was used before it was defined.",     W004: "'{a}' is already defined.",     // ... }; 
like image 148
James Allardice Avatar answered Oct 12 '22 15:10

James Allardice


Not So Final Edit: Looks like a new site has been stood up that covers all the previous functionality: http://linterrors.com/js

I would recommend: http://jslinterrors.com/

This isn't a side-by-side list of all the errors, but it has each error (broken out by JSLint, JSHint, and ESLint) which include the specific error code per item.

For just JSHint, you can scope the view: http://jslinterrors.com/?linter=jshint

Final Edit: Looks like the site has gone under and is up for sale.

Edit: The codes can be found at the bottom of each section, if it relates to a fatal syntax the code cannot be suppressed.

Edit 2: Looks like they've added ESLint as well.

like image 35
ClosedEyesSeeing Avatar answered Oct 12 '22 15:10

ClosedEyesSeeing