Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
110 views
in Technique[技术] by (71.8m points)

javascript - 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.

question from:https://stackoverflow.com/questions/17535130/where-can-i-find-a-list-of-jshint-numeric-error-codes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.",
    // ...
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...