diff --git a/.gitmodules b/.gitmodules index 2d913c4..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "jshint"] - path = res/jshint - url = git@github.com:jshint/jshint.git diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..26ea99b --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +jshint.com diff --git a/Makefile b/Makefile deleted file mode 100644 index be3abfe..0000000 --- a/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -DEPLOY_BRANCH ?= master -DEPLOY_REMOTE ?= upstream - -node_modules: package.json - npm install - -site: node_modules res - git submodule update - npm run build - -.PHONY: deploy -deploy: site - git checkout -B $(DEPLOY_BRANCH) - git ls-files * | xargs git rm - rmdir --ignore-fail-on-non-empty --parents */ - mv site/* . - rm -rf res/jshint/node_modules - echo "jshint.com" > CNAME - git add --all . - git commit -m "Build site." - git push --force $(DEPLOY_REMOTE) $(DEPLOY_BRANCH) - git checkout - diff --git a/about/index.html b/about/index.html new file mode 100644 index 0000000..3a5ab5d --- /dev/null +++ b/about/index.html @@ -0,0 +1,192 @@ + + + +
+This page's content is sourced from the JSHint project repository. If you spot an error, please open an issue or (better yet) make a pull request!
+ +[ Use it online • +Docs • FAQ • +Install • +Contribute • +Blog • Twitter ]
+ + + +JSHint is a community-driven tool that detects errors and potential problems in +JavaScript code. Since JSHint is so flexible, you can easily adjust it in +the environment you expect your code to execute. JSHint is open source and +will always stay this way.
+ +The project aims to help JavaScript developers write complex programs +without worrying about typos and language gotchas.
+ +Any code base eventually becomes huge at some point, so simple mistakes — that +would not show themselves when written — can become show stoppers and add +extra hours of debugging. So, static code analysis tools come into play +and help developers spot such problems. JSHint scans a program written in +JavaScript and reports about commonly made mistakes and potential bugs. The +potential problem could be a syntax error, a bug due to an implicit type +conversion, a leaking variable, or something else entirely.
+ +Only 15% of all programs linted on jshint.com pass the +JSHint checks. In all other cases, JSHint finds some red flags that could've +been bugs or potential problems.
+ +Please note, that while static code analysis tools can spot many different kind +of mistakes, it can't detect if your program is correct, fast or has memory +leaks. You should always combine tools like JSHint with unit and functional +tests as well as with code reviews.
+ +To report a bug simply create a +new GitHub Issue and describe +your problem or suggestion. We welcome all kinds of feedback regarding +JSHint including but not limited to:
+ +Before reporting a bug, please look around to see if there are any open or closed tickets +that discuss your issue, and remember the wisdom: pull request > bug report > tweet.
+ +Engineers from these companies and projects use JSHint:
+ +And many more!
+ +Most files are published using the standard MIT Expat +license. One file, +however, is provided under a slightly modified version of that license. The +so-called JSON license +is a non-free license, and unfortunately, we can't change it due to historical +reasons. This license is included as an in-line within the file it concerns.
+ +JSHint is currently maintained by Rick Waldron, +Caitlin Potter, Mike +Pennisi, and Luke +Page.
+ +Originating from the JSLint project in 2010, JSHint has been maintained by a +number of dedicated individuals. In chronological order, they are: Douglas +Crockford, Anton Kovalyov, and Mike Sherov. We appreciate their long-term +commitment!
+ +We really appreciate all kinds of feedback and contributions. Thanks for using and supporting JSHint!
+A huge [1] number of tweaks and bugfixes. New options: funcscope
, esnext
,
+multistr
and smarttabs
. To see what they do, refer to the docs.
Many thanks to our awesome contributors who participated in this release: +Wolfgang Kluge, Josh Perez, Ben Blank, Rob Friesel, Matt, Nicholas Zakas, +dionyziz, Ed Lui, Felix Gnass, Tom Rix, Dominic Barnes, Nick Goris, Nicolas +Ferrero, Ron DeVera, Sean Carpenter, shahyar, Aparajita Fishman, ckknight, +Jakub Suder and Dylan Smith.
+ +[1] — Since it's been a few months this release is too big to summarzie. +Future releases will be smaller and easier to summarize.
+This release contains significant improvements to the way JSHint +treats ES5 accessor functions:
+ +Getters no longer raise the “Don't make functions within a loop” +warnings.
JSHint no longer enforces value
as a parameter name for setter
+functions.
JSHint no longer requires setter functions to follow getters.
Improved checks for duplicate properties. For example, JSHint now +understands that this code is valid:
x = {
+ get x: function () {},
+ set x: function () {}
+ };
While this one is not:
x = {
+ get x: function () {},
+ x: true
+ };
Tests cover more use cases with ES5 accessors.
Fixed a bug with JSHint producing false warning for the following +code:
somevar.replace(/[0-9-]/g, "");
Thanks to Máté Farkas and Wolfgang Kluge.
+ +Please welcome new JSHint Core team members Wolfgang Kluge and Josh Perez! +I'm really excited to work with them on making JSHint the best code quality +tool for JavaScript.
+This is a bugfix release that also contains some improvements to our +test coverage.
+ +Fixes:
+ +JSHint now makes sure that null
references are not subscripted
+within typeof
and delete
operators.
JSHint now recognizes defensive semicolon technique:
; (function () { / ... / }());
But still warns in cases like this:
; function () {}
Fixed an issue with latedef
not working for a specific use
+of variable hoisting.
Fixed an intermittent bug with JSHint failing with an exception +instead of returning a Too Many errors message.
Fixed incorrect comments in JSC wrapper.
Fixed a bug with JSC wrapper not parsing options with spaces correctly.
Thanks to Mike Pennisi and Dan Vanderkam.
+This release improves JSHint's support for variable hoisting. JSHint +now fully understands variable hoisting:
+ +/*jshint undef:true */
+
+ function func() {
+ function innerOne() {
+ // Before: wrong error.
+ // Now: knows that innerTwo is defined below.
+ innerTwo();
+ }
+
+ function innerTwo() {
+ }
+ }
+
+We also added a new option, laxcomma
, that allows you to use
+comma-first coding style without turning on the laxbreak
option. See
+GH-340 for more information.
Thanks to Charlie Robbins.
+This is a minor bugfix release that fixes a couple of issues with +hoisting and IIFE.
+ +Thanks to Kyle Robinson Young.
+New globals for the browser
option.
WSH wrapper now supports recursive directories.
Support for \0
in strings.
+(GH-464)
Node environment now assumes globalstrict
.
Opt-in support for the with
statement.
Rhino wrapper is now runnable.
+ lot of bugfixes.
Thanks to Antal István Miklós, Brent Lintner, Domenic Denicola, +Fábio M. Costa, J-Griffin, Kevin Locke, Nikolay Frantsev, +Peter Wagenet and Rick Waldron.
+This release introduces a new option—quotmark
. This option allows
+you to enforce the consistency of quotation marks.
Other changes:
+ +New globals for the WebWorker API.
New globals for the browser
option.
New option camelcase
. If set to true, all identifiers are required
+to be either in camelCase or UPPER_CASE with underscores.
+ bugfixes.
Thanks for Jan Prachar, Jason More, Rick Waldron, Joel Brandt, Akshar Prabhu +Desai, Paul O'Shannessy and Rob Friesel.
+This release introduces a new option called unused
. This option
+allows you to quickly spot variables that were defined but never used.
Other changes:
+ +quotmark
from
+r08.Rhino wrapper now accepts shortcuts for predefined globals:
$ rhino jshint-rhino.js myfile.js undef:true myglobal
Also, it no longer assumes rhino=true
for all files.
JSHINT.report
(it used to generate HTML based on JSHint
+output).camelcase
to tolerate variables with leading underscores
+since it is one of the most common patterns for pseudo-private variables
+in JavaScript.nomen
now recognizes Underscore.js global.Thanks to Rod Vagg and Nikolay Frantsev.
+This release introduces lots of improvements to the unused
option from
+r09. For example, JSHint is now smart
+enough to not to warn about unused variable if that variable is followed
+by a used one:
fetch(function (err, msg) {
+ success(msg);
+ });
+
+We also fixed JSHINT.data().unused
to be consistent with this option.
Other changes:
+ +You can now exclude globals. For example, if you want to assume browser
+environment but disallow the use of event
you can do the following:
/jshint browser:true / + /global -event /
JSHint now recognizes (function () {})();
as well as
+(function () {}());
.
Thanks to Amir E. Aharoni and Carl Ekerot.
+This release adds new checks for excessive code! You can now use JSHint +to check number of parameters per function, nested block depth per function, +number of statements per function and function's cyclomatic complexity. +More information in our docs or in this brilliant +patch.
+ +Other changes:
+ +catch
blocks now has their own scope so if you define a function within
+a catch block and try to use it outside of said block—JSHint will warn you
+about undefined variable. JSHint also warns about cases when the catch
+scope leaks values into the outer scope in IE:
var e = 2;
try { + throw 'boom'; + } catch (e) { + // JSHint: 'e' may get overwritten in IE. + }
console.log(e + 2); // 'boom2' instead of 4
We no longer warn when Object is used as a function. Like Boolean, Number +and String, Object can be called as a function which provides scripts with +access to ECMAScript's internal ToObject logic.
JSHint can now check code within simple eval strings. For example, JSHint can +now spot typos like this one (this practice is still discouraged, though):
eval("oops("); // Expected ')' and instead saw ''.
+ other minor bugfixes.
Thanks to Josh Heidenreich, Rick Waldron, Nikolay Frantsev, shybyte.
+This is mostly a bugfix release:
+ +indent
behaved differently when passed as
+as an argument to JSHint.maxparams
check was failing on functions
+with no parameters.Thanks to Dav Glass, Mariusz Nowak and Brad Harris.
+Welcome to the official JSHint blog. This blog will serve two purposes. +First, it will replace our old Changelog page where we announce new JSHint +releases. Second, I will use this blog as a platform to share stuff about +static code analysis I find interesting.
+ +For example, Ariya Hidayat (of Esprima and PhantomJS) gave what seems to +be a very nice talk a few days ago at the EmpireJS. His slides are embedded +below.
+ +Oh and check out jshint.com, it has a cool new header.
+UPDATE: JSHint 1.0.0 RC3.
+ +After three months and 100+ commits, JSHint 1.0.0 is ready for release. +This is the biggest release for JSHint so far, and that's why I've decided to run it +through a release candidate phase first. I tried my best to make it as +backwards compatible as possible, but there might be a small number of +incompatibilities depending on how you use JSHint. Please keep that in mind +and test your integration before updating to 1.0.0.
+ +One of the biggest changes is that node-jshint is now part of the main JSHint +project, which means that there will no longer be lag time between releasing a +new version and publishing it on NPM. Node and NPM is now the main and +recommended way of using JSHint on all platforms. This also means that +starting with "1.0.0", JSHint will start using the +node-semver versioning system instead +of the old rN system.
+ +In addition, this version drops support for non-ES5 environments. This means that +JavaScript engines that don't support the ES5 syntax will not even parse +JSHint's source code. (For example, the online interface for JSHint will not +work in older versions of IE.)
+ +I'm very excited to finally release this version and I encourage everyone to try +out the release candidate and report any bugs and issues you encounter. The full +changelog is provided below, with examples and links to relevant issues.
+ +This version has a completely rewritten lexer. Since it's no longer a giant +regexp, the new lexer is more robust and easier to read. I'd like to thank the +authors of Esprima and Traceur since I borrowed some pieces from them.
+ +This version adds support for Unicode identifiers! +(#301 and +#716)
var π = 3.1415;
Adds support for the comma operator. (#56) +JSHint now parses code like the following (note the comma in the middle +expression):
for (var i = 0, ch; ch = channels[i], i < channels.length; i++) { + // ... + }
Improves support for numbers. JSHint now understands numbers with leading dots +(e.g. .12) and doesn't generate false positives on invalid numbers (e.g. 099). +In case of invalid numbers the parser still parses them but marks as +malformed and generates a nice little warning.
Adds support for more relaxed JSHint directive syntax. JSHint now recognizes
+space between /*
and jshint/global/etc. and allows you to use single-line
+comments for directives in addition to multi-line comments:
Before: + /jshint strict:true /
Now: + /jshint strict:true / + / jshint strict:true / (note the space) + //jshint strict:true + // jshint strict:true
One potentially breaking change is that all lists inside JSHint directives
+must be separated by commas from now on. So /*jshint strict:true undef:true */
+won't fly anymore but /*jshint strict:true, undef:true */
will (note the
+comma).
Adds better parser for regular expressions. Previously, JSHint would check +the grammar of regular expressions using its own internal logic. Now, JSHint +compiles the parsed expressions using the native RegExp object to check +for grammar errors.
Adds support for a defensive semicolon before [
. (Ticket
+#487)
Adds support for unclosed multi-line strings and removes warnings about
+unnecessary escaping for \u
and \x
in strings.
+(#494)
Bug fixes:
+ +Fixes a bug with JSHint not warning about reserved words being used as +variable and function declaration identifiers. (Ticket +#744)
Fixes a bug with JSHint generating a false positive Missing whitespace... +warning on trailing commas. +(#363)
Fixes a bug with JSHint not being able to parse regular expressions preceded
+by typeof (e.g. typeof /[a-z]/
) and, in some cases, *=, /=, etc.
+(e.g. if (x /= 2) { ... }
).
+(#657)
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 /
or
JSHINT(src, { "-W047": true });
Keep in mind that this syntax can't be used to ignore errors.
Due to popular demand, this version splits indent and white options +meaning that indent won't imply white anymore. +(#667)
Changes node option to not assume that all programs must be +running in strict mode. +(#721)
Adds new globals for the browser option: Element and Uint8ClampedArray. +(#707 and +#766)
Adds new global for the node option: DataView. +(#773 and +#774)
Removes option onecase.
Adds new directive: exported. Use /* exported ...
for global variables
+that are defined in the current file but used elsewhere to prevent
+unnecessary X is defined but never used warnings. As before, you need to declare those
+variables as global in the other files.
Removes a warning about missing break before default when default +is the first switch statement (#490):
switch (name) { + default: // No warning here + doSomething(); + break; + case "JSHint": + doSomethingElse(); + }
Improves support for future reserved keywords. +JSHint now properly recognizes future reserved keywords both for ES3 and ES5 +environments with their corresponding rules. +(#674)
Changes behavior for hasOwnProperty (#770):
var hasOwnProperty = ...; // No warning + var obj = { hasOwnProperty: ... }; // Warning + obj.hasOwnProperty = ...; // Warning + obj['hasOwnProperty'] = ...; // Warning
Adds ability to disable option unused per function! +(#639)
// jshint unused:true + var a; // Warning
function foo(b) { // No warning + // jshint unused:false + return 1; + }
foo();
Bug fixes:
+ +return o.a = 1
.
+(#670)This version removes support for the JavaScriptCore shell due to its +limited API. Note that this doesn't mean that JSHint no longer works in +Safari, it simply means that we removed the ability to use jshint via the command +line JSC shell.
This version also removes support for Windows Script Host. WSH support +was initially added due to Node not working well on Windows but, thanks to +Microsoft engineers, this is no longer true. So everyone is encouraged to +use JSHint with Node.
This version relies on ES5 syntax, so if you use JSHint with +Rhino, please make sure you have the latest version: 1.7R4.
This version includes several improvements to the Node version of JSHint:
+ +Adds a new flag, --verbose
, that changes output to display message codes:
$ jshint --verbose my.js + my.js: line 7, col 23, Extra comma. (...) (W070)
Makes --config
raise an error if it can't find provided file or if the
+file is invalid JSON.
+(#691)
Bug fixes:
+ +Fixes a bug with .jshintignore
globbing not working properly.
+(#777 and
+#692)
Fixes a bug with JSHint skipping over files with no extensions. +(#690)
I plan to test this release candidate for about a week before marking it +as stable and publishing on NPM. And, at the same time, I will be updating the +documentation and the jshint.com website. If you notice any +bugs or unexpected backwards-incompatible changes, please file a bug.
+ +RC3 is out: JSHint 1.0.0 RC3.
+ +Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc1.tar.gz
+
+For Rhino wrapper, you will need to clone our repo and build jshint-rhino:
+ +$ node make.js build
+$ rhino dist/jshint-rhino.js ...
+
+Thanks to Bernhard K. Weisshuhn, James Allardice, Mike MacCana, Stephen Fry, +Steven Olmsted, Leith Abdulla, Eric Promislow and Vlad Gurdiga for submitting +patches!
+JSHint 1.0.0 Release Candidate 2 is now out:
+ +Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc2.tar.gz
+
+For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+ +Big thanks to Samuel Cole for submitting patches and finding bugs!
+JSHint 1.0.0 Release Candidate 2 is now out:
+ +Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc2.tar.gz
+
+For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+ +Big thanks to Samuel Cole for submitting patches and finding bugs!
+ +After three months and 100+ commits, JSHint 1.0.0 is ready for release. This +is the biggest release for JSHint so far, and that's why I've decided to run it +through a release candidate phase first. I tried my best to make it as +backwards compatible as possible, but there might be a small number of +incompatibilities depending on how you use JSHint. Please keep that in mind and +test your integration before updating to 1.0.0.
+ +One of the biggest changes is that node-jshint is now part of the main JSHint +project, which means that there will no longer be lag time between releasing a +new version and publishing it on NPM. Node and NPM is now the main and +recommended way of using JSHint on all platforms. This also means that +starting with "1.0.0", JSHint will start using the +node-semver versioning system instead +of the old rN system.
+ +In addition, this version drops support for non-ES5 environments. This means +that JavaScript engines that don't support the ES5 syntax will not even parse +JSHint's source code. (For example, the online interface for JSHint will not +work in older versions of IE.)
+ +I'm very excited to finally release this version and I encourage everyone to +try out the release candidate and report any bugs and issues you encounter. The +full changelog is provided below, with examples and links to relevant issues.
+ +This version has a completely rewritten lexer. Since it's no longer a giant +regexp, the new lexer is more robust and easier to read. I'd like to thank the +authors of Esprima and Traceur since I borrowed some pieces from them.
+ +This version adds support for Unicode identifiers! +(#301 and +#716)
var π = 3.1415;
Adds support for the comma operator. (#56) +JSHint now parses code like the following (note the comma in the middle +expression):
for (var i = 0, ch; ch = channels[i], i < channels.length; i++) { + // ... + }
Improves support for numbers. JSHint now understands numbers with leading +dots (e.g. .12) and doesn't generate false positives on invalid numbers (e.g. +099). In case of invalid numbers the parser still parses them but marks as +malformed and generates a nice little warning.
Adds support for more relaxed JSHint directive syntax. JSHint now recognizes
+space between /*
and jshint/global/etc. and allows you to use single-line
+comments for directives in addition to multi-line comments:
Before: + /jshint strict:true /
Now: + /jshint strict:true / + / jshint strict:true / (note the space) + //jshint strict:true + // jshint strict:true
One potentially breaking change is that all lists inside JSHint directives
+must be separated by commas from now on. So /*jshint strict:true undef:true
+*/
won't fly anymore but /*jshint strict:true, undef:true */
will (note
+the comma).
Adds better parser for regular expressions. Previously, JSHint would check +the grammar of regular expressions using its own internal logic. Now, JSHint +compiles the parsed expressions using the native RegExp object to check +for grammar errors.
Adds support for a defensive semicolon before [
. (Ticket
+#487)
Adds support for unclosed multi-line strings and removes warnings about
+unnecessary escaping for \u
and \x
in strings.
+(#494)
Bug fixes:
+ +Fixes a bug with JSHint not warning about reserved words being used as +variable and function declaration identifiers. (Ticket +#744)
Fixes a bug with JSHint generating a false positive Missing whitespace... +warning on trailing commas. +(#363)
Fixes a bug with JSHint not being able to parse regular expressions preceded
+by typeof (e.g. typeof /[a-z]/
) and, in some cases, *=, /=, etc. (e.g.
+if (x /= 2) { ... }
).
+(#657)
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 /
or
JSHINT(src, { "-W047": true });
Keep in mind that this syntax can't be used to ignore errors.
Due to popular demand, this version splits indent and white options +meaning that indent won't imply white anymore. +(#667)
Changes node option to not assume that all programs must be running in +strict mode. (#721)
Adds new globals for the browser option: Element and Uint8ClampedArray. +(#707 and +#766)
Adds new global for the node option: DataView. +(#773 and +#774)
Removes option onecase.
Adds new directive: exported. Use /* exported ...
for global variables
+that are defined in the current file but used elsewhere to prevent
+unnecessary X is defined but never used warnings. As before, you need to
+declare those variables as global in the other files.
Removes a warning about missing break before default when default is +the first switch statement +(#490):
switch (name) { + default: // No warning here + doSomething(); + break; + case "JSHint": + doSomethingElse(); + }
Improves support for future reserved +keywords. +JSHint now properly recognizes future reserved keywords both for ES3 and ES5 +environments with their corresponding rules. +(#674)
Changes behavior for hasOwnProperty +(#770):
var hasOwnProperty = ...; // No warning + var obj = { hasOwnProperty: ... }; // Warning + obj.hasOwnProperty = ...; // Warning + obj['hasOwnProperty'] = ...; // Warning
Adds ability to disable option unused per function! +(#639)
// jshint unused:true + var a; // Warning
function foo(b) { // No warning + // jshint unused:false + return 1; + }
foo();
Bug fixes:
+ +return o.a =
+1
. (#670)This version removes support for the JavaScriptCore shell due to its +limited API. Note that this doesn't mean that JSHint no longer works in +Safari, it simply means that we removed the ability to use jshint via the +command line JSC shell.
This version also removes support for Windows Script Host. WSH support +was initially added due to Node not working well on Windows but, thanks to +Microsoft engineers, this is no longer true. So everyone is encouraged to use +JSHint with Node.
This version relies on ES5 syntax, so if you use JSHint with Rhino, please +make sure you have the latest version: 1.7R4.
This version includes several improvements to the Node version of JSHint:
+ +Adds a new flag, --verbose
, that changes output to display message codes:
$ jshint --verbose my.js + my.js: line 7, col 23, Extra comma. (...) (W070)
Makes --config
raise an error if it can't find provided file or if the file
+is invalid JSON. (#691)
Bug fixes:
+ +Fixes a bug with .jshintignore
globbing not working properly.
+(#777 and
+#692)
Fixes a bug with JSHint skipping over files with no extensions. +(#690)
I plan to test this release candidate for about a week before marking it as +stable and publishing on NPM. And, at the same time, I will be updating the +documentation and the jshint.com website. If you notice +any bugs or unexpected backwards-incompatible changes, please file a bug.
+ +RC3 is out: JSHint 1.0.0 RC3.
+ +Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc1.tar.gz
+
+For Rhino wrapper, you will need to clone our repo and build jshint-rhino:
+ +$ node make.js build
+$ rhino dist/jshint-rhino.js ...
+
+Thanks to Bernhard K. Weisshuhn, James Allardice, Mike MacCana, Stephen Fry, +Steven Olmsted, Leith Abdulla, Eric Promislow and Vlad Gurdiga for submitting +patches!
+JSHint 1.0.0 Release Candidate 3 is now out:
+ +new
and debugger
to
+appear after a comma. (#793)/*global global:true */
correctly.
+(#795)Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc3.tar.gz
+
+For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+JSHint 1.0.0 Release Candidate 3 is now out:
+ +new
and debugger
to
+appear after a comma. (#793)/*global global:true */
correctly.
+(#795)Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc3.tar.gz
+
+For full 1.0.0 changelog please see our 1.0.0 RC1 +announcement.
+JSHint 1.0.0 Release Candidate 4 is now out:
+ +/
after ]
.
+(#803)predef
when its value is an array,
+and not an object. (#800)if (name <) {}
. (#818)Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc4.tar.gz
+
+For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+JSHint 1.0.0 Release Candidate 4 is now out:
+ +/
after ]
.
+(#803)predef
when its value is an array,
+and not an object. (#800)if (name <) {}
. (#818)Here's how you can install this release candidate:
+ +$ npm install https://github.com/jshint/jshint/archive/1.0.0-rc4.tar.gz
+
+For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+JSHint 1.0.0 is now officially released. You can download it from this website +or install via NPM:
+ +$ npm install jshint
+
+Also, we have a new website with new up-to-date documentation! Check it out and +let us know what you think. For full 1.0.0 changelog please see our +1.0.0 RC1 announcement.
+JSHint 1.1.0 is out! This release contains important bug fixes for 1.0.0 and a +couple of new features.
+ +phantom
.
+(#814).jshintrc
file. (#850)gcl
to make JSHint style checks compatible with Google
+Closure Linter.
+(#812 and
+#811).jshintrc
file that mirrors defaults from the website.return "=";
would produce a false positive
+warning. (#878)Expands on the configurability of unused
. This option now accepts the
+following values:
false
: no checking is done.true
: checks all variables and parameters, unless unused parameter is
+followed by a used one:
function test(err, val) { + return val; +}
"vars"
: checks only variables but not function parameters."strict"
: checks all variables and all function parameters.
+(#778)\0
in strings would produce a false positive warning.unused
would generate false positive warnings on ES3
+future reserved words in the ES5 environment.// jshint
.
+(#881)I would also like to use this moment to say hi to my friends and family, and +remind everyone that we're running a fundraising campaign on BountySource. All money +donated will be used to pay contributors for fixing bugs and shipping new +features. So if you like JSHint donate today. And if you hate JSHint donate +tomorrow.
+WARNING: This release introduces backwards incompatible changes.
+ +JSHint 2.0.0 is out! This version hits a pretty big milestone for the +project: this is the first JSHint release for which I'm not the +biggest contributor. I personally believe this fact validates JSHint +as a successful open source project. And I'm extremely thankful to +all you who file bug reports and send patches—you're all awesome.
+ +The first and foremost: starting with this version JSHint will assume
+ES5 as the default environment. Before, JSHint was checking all the
+code per ES3 specification with an option to enable ES5 mode. Now ES5
+mode is the default mode and if you want to check your code against the
+ES3 specification (useful when developing for super old browsers such as
+Internet Explorer 6) you will have to use es3:true
.
Special thanks to Rick Waldron for championing this change.
+ +Thanks to our newest core contributor, Bernard Pratz, JSHint now has
+partial support for Mozilla JavaScript extensions (moz
option) and
+ES6 (esnext
option):
const
let
blocks and expressionsfor ... of
loopsWe have more patches in queue that add support for classes and other +nifty ES6 things. Stay tuned!
+ +.jshintrc
in the directory being linted.
+(#833)smarttabs
now ignores mixed tabs and spaces within single-
+and multi-line comments.Added a new pragma to unignore a warning:
/jshint -W096 /
// All warnings about keys producing unexpected results will + // be ignored here.
/jshint +W096 /
// But not here.
JSHint now ignores unrecognized JSLint options.
indent:false
was triggering indentation warnings.
+(#1035)unused
was not behaving correctly.
+(#996)And last but not least: starting with this version, I'm switching JSHint +to a more rapid release schedule. This simply means that I will be +publishing new versions of JSHint more often. I will try my best to +follow semver recommendations and ship working +software. But as our license says, no guarantees.
+ +Thanks to Bernarnd Pratz, Michelle Steigerwalt, Yuya Tanaka, Matthew Flaschen, +Juan Pablo Buritica, Matt Cheely, Steve Mosley, Stephen Sorensen, Rick Waldron, +Hugues Malphettes, Jeff Thompson, xzyfer, Lee Leathers, croensch, Steven Benner, +James Allardice, Sindre Sorhus, Jordan Harband, Stuart Knightley and Kevin Locke +for sending patches!
+WARNING: This release introduces backwards incompatible changes.
+ +JSHint 2.0.0 is out! This version hits a pretty big milestone for the project: +this is the first JSHint release for which I'm not the biggest contributor. I +personally believe this fact validates JSHint as a successful open source +project. And I'm extremely thankful to all you who file bug reports and send +patches—you're all awesome.
+ +The first and foremost: starting with this version JSHint will assume ES5 as
+the default environment. Before, JSHint was checking all the code per ES3
+specification with an option to enable ES5 mode. Now ES5 mode is the default
+mode and if you want to check your code against the ES3 specification (useful
+when developing for super old browsers such as Internet Explorer 6) you will
+have to use es3:true
.
Special thanks to Rick Waldron for championing this change.
+ +Thanks to our newest core contributor, Bernard Pratz, JSHint now has partial
+support for Mozilla JavaScript extensions (moz
option) and ES6 (esnext
+option):
const
let
blocks and expressionsfor ... of
loopsWe have more patches in queue that add support for classes and other nifty ES6 +things. Stay tuned!
+ +.jshintrc
in the directory being linted.
+(#833)smarttabs
now ignores mixed tabs and spaces within single-
+and multi-line comments.Added a new pragma to unignore a warning:
/jshint -W096 /
// All warnings about keys producing unexpected results will + // be ignored here.
/jshint +W096 /
// But not here.
JSHint now ignores unrecognized JSLint options.
indent:false
was triggering indentation warnings.
+(#1035)unused
was not behaving correctly.
+(#996)And last but not least: starting with this version, I'm switching JSHint to a +more rapid release schedule. This simply means that I will be publishing new +versions of JSHint more often. I will try my best to follow +semver recommendations and ship working software. But as +our license says, no guarantees.
+ +Thanks to Bernarnd Pratz, Michelle Steigerwalt, Yuya Tanaka, Matthew +Flaschen, Juan Pablo Buritica, Matt Cheely, Steve Mosley, Stephen Sorensen, +Rick Waldron, Hugues Malphettes, Jeff Thompson, xzyfer, Lee Leathers, croensch, +Steven Benner, James Allardice, Sindre Sorhus, Jordan Harband, Stuart Knightley +and Kevin Locke for sending patches!
+JSHint 2.1.0 is out. This releases adds support for ES6 class
syntax and fixes
+some issues with our parser.
class
syntax.
+(#1048)do
statement bodies that are not block
+statements.
+(#1062)switch
+conditionals.
+(#1064)esnext
and moz
modes turning off the
+default es5
mode.
+(#1068)Thanks to usrbincc, James Allardice, Iraê Carvalho, Nick Schonning and jklein +for sending patches!
+JSHint 2.1.0 is out. This releases adds support for ES6 class
syntax and
+fixes some issues with our parser.
class
syntax.
+(#1048)do
statement bodies that are not block
+statements.
+(#1062)switch
+conditionals.
+(#1064)esnext
and moz
modes turning off the
+default es5
mode.
+(#1068)Thanks to usrbincc, James Allardice, Iraê Carvalho, Nick Schonning and +jklein for sending patches!
+UPDATE: We just published another version, 2.1.7, which contains only one bugfix: #1199.
+ +In this release we added two new arguments to our CLI program: exclude
which allows
+you to exclude directories from linting and prereq
which allows you to specify a file
containing declarations of the global variables used throughout your project. In addition
to that, we added support for stdin. JSHint now follows a UNIX convention where if a
-given file path is a dash (`-`) the the program reads from stdin.
+given file path is a dash (-
) the the program reads from stdin.
We also extended our ES6 coverage by adding support for yield
statements and
+import/export
declarations. JSHint is still the only linter that can parse
+most ES6 and Mozilla-specific JavaScript code.
For more changes, see the changelog table below.
Thanks to Terry Roe, Sindre Sorhus, Thomas Boyt, Nikolay S. Frantsev, XhmikosR, Jacob Rask, Kevin Chu, Tim Ruffles, Stephen Mathieson, Lukas Domnick, usrbincc for sending patches!
+ +UPDATE: We just published another version, 2.1.7, which contains only one +bugfix: #1199.
+ +In this release we added two new arguments to our CLI program: exclude
which
+allows you to exclude directories from linting and prereq
which allows you to
+specify a file containing declarations of the global variables used throughout
+your project. In addition to that, we added support for stdin. JSHint now
+follows a UNIX convention where if a given file path is a dash (-
) the the
+program reads from stdin.
We also extended our ES6 coverage by adding support for yield
statements and
+import/export
declarations. JSHint is still the only linter that can
+parse most ES6 and Mozilla-specific JavaScript code.
For more changes, see the patch summary below.
+ +--exclude
argThanks to Terry Roe, Sindre Sorhus, Thomas Boyt, Nikolay S. Frantsev, +XhmikosR, Jacob Rask, Kevin Chu, Tim Ruffles, Stephen Mathieson, Lukas Domnick, +usrbincc for sending patches!
+A few months ago I started sending data from this website to Keen.IO, +a small San Francisco-based company specializing in the API for custom analytics. Last +weekend, I finally found some time to look at the numbers.
+ +In the past six months 169,000 JavaScript programs were linted through this
+website (we do not send any data from our our library or CLI progam in any way) and
+only 15% of them passed the checks. The average program consisted of 507
+lines of code while the largest program had 101,000 lines in it. This means
+someone copied one hunder and one thousand lines of code, pasted it into our
+editor and pressed lint
. In total, JSHint processed
+86,000,000 lines of code through this website exclusively. Only 40% of our users
+used default JSHint settings, while 60% of them tweaked the settings in one way or
+another.
As for our NPM module, the NPM website tells us that the package has been downloaded +211,000 times in the last month.
+ +That's it for now. I will continue to play with Keen.IO and our data to see if it gives +me any additional insight into JSHint and its users.
+Thanks to Dave Camp JSHint now supports list +comprehensions, a declarative way of transforming a list:
+ +[ for (i of [ 1, 2, 3 ]) i + 2 ]; // Returns [ 3, 4, 5 ]
+
+Note: SpiderMonkey currently implements a slightly different syntax for list +comprehensions which is also supported by JSHint.
+ +Thanks to Rob Wu, Ryan Cannon, Dave Camp, Amir Livneh, Josh Hoff, Nikolay +S. Frantsev, Lapo Luchini, Lukas Domnick for sending patches!
+singleGroups
(5fedda6), closes #2064elision
option to relax "Extra comma" warnings (cbfc827), closes #2062[1, , 3, , 5]
)singleGroups
(6003c83)singleGroups
(bc857f3)delete
(35df49f)doFunction
(06b5d40)get
and set
as ID properties (2ad235c)singleGroups
(896bf82)state
object (678da76)const
declarations in ForIn/Of loops (2b673d9), closes #2334 #2335enforceall
(6afcde4)Note This release was revoked shortly following its publication. Please
+refer to the release notes for version 2.9.1 for more information (found in the
+project's CHANGELOG.md
file and on the project's website).
This release was a long time in the making, but it may not be the most exciting +version we've published. Most of the changes are internal refactorings that +were necessary to properly fix bugs. And fix bugs we did! Special thanks go to +Luke Page, the newest addition to the JSHint team. Luke is a maintainer of the +Less CSS project, and he introduced himself to use by +overhauling JSHint's variable tracking logic.
+ +JSHint 3.0 is closer than ever. We're excited for the opportunity to break a +few things in order to make real strides forward. In fact, the hardest part +will be limiting ourselves (we don't want to make migrating to the new +version onerous). If you have any ideas along these lines, please submit them +on the project's issue tracker. +We'll mark them with the label "Breaking +Change", and as we +decide what's definitely "in" for 3.0, we'll add them to the "v3.0.0" +milestone.
+ +HTMLCollection
to browser environment. (e92d375), closes #2443window.performance
to browser vars (3ff1b05), closes #2461__proto__
when using ES6 (06b5764), closes #2371esnext
(b5ba7d6), closes #2519asi: true
(728c84b), closes #2530func
as a property of state
(3be8d36)ignore
directives as special (f14c262)for
as array comprehensions. (d70876c), closes #1413ignore
directive more consistently (0971608)__proto__
identifier (925a983)strict: func
have precedence over env options. (d138db8)module
option (56c19a5)new.target
(2fbf621)__iterator__
property is deprecated. (7780613)var
inside for (...)
when varstmt: true
(f1ab638), closes #2627Version 2.9.0 was revoked shortly after its release due to a number of +regressions. Although the underlying issues have been resolved, we are +sensitive to the possibility that there may be still more; as mentioned in +2.9.0's release notes, the variable tracking system saw a significant +refactoring.
+ +In an effort to minimize friction with a new version, we're publishing a +release candidate and requesting feedback from early adopters. Please give it a +try in your projects and let us know about any surprising behavior!
+ +latedef
shouldn't warn when marking a var as exported (c630994), closes #2662File
and FileList
to browser global variables (7f2a729), closes #2690newcap
within strict mode (acaf3f7)undefined
(0d87919), closes #2699Following the revocation of version 2.9.0, we observed an extended "release
+candidate" phase where we encouraged users to vet JSHint for undesirable
+changes in behavior. During that time, we identified and resolved a number of
+such regressions. This release comprises all changes from the release candidate
+phase along with the improvements initially released as version 2.9.0. This
+release does not itself contain any changes to the codebase. If you are
+upgrading from version 2.8.0 or earlier, please refer to the
+previously-published release notes for details on bug fixes and features--these
+can be found in the project's CHANGELOG.md
file and on the project's website.
This release contains a number of bug fixes. As always, we thank everyone who +reported issues and submitted patches; those contributions are essential to the +continuing improvement of the project. We hope you'll keep it up!
+ +await
keyword in ES6 module code (b1c8d5b)y
RegExp flag in ES2015 code (#2999) (a801433)yield
operand (#3011) (b646aea)null
value from errors
array (#3049) (f7eb3d7)If you're working on an NPM package you don't need to have a .jshintrc
+file anymore. Just put your JSHint options into your package.json file
+as a property named jshintConfig
and you're all set! The format
+is exactly the same as .jshintrc.
Example: package.json for JSHint itself.
+Yesterday, I decided to post a bounty on a feature request to add support +for ES6 parameter default values. +I put $50 and a few minutes later the bounty was increased to $150. Then I sent out this tweet and +went to grab some food:
+ ++ + +if you want $150 for a couple of hours of open source hacking, add support for default params to @jshint: https://t.co/ZnJG7G2a1X
— Anton (@valueof) July 30, 2013
One hour later an incredible Thomas Boyt +posted his solution which I reviewed, landed and published today as JSHint 2.1.8. +This means that JSHint now officially supports default parameters!
+After almost a year into development we decided that it's time to +make more frequent stable releases and keep a blog.
+ +Here are some links from the past:
+ + +The Official JSHint Blog: announcements, discussions, and more. + (RSS)
+ +Oct 20th, 2016 | +New Release: 2.9.4 | +
Aug 18th, 2016 | +New Release: 2.9.3 | +
Apr 19th, 2016 | +New Release: 2.9.2 | +
Jan 14th, 2016 | +New Release: 2.9.1 | +
Jan 12th, 2016 | +New Release: 2.9.1-rc3 | +
Dec 22nd, 2015 | +New Release: 2.9.1-rc2 | +
Nov 12th, 2015 | +New Release: 2.9.1-rc1 | +
Sep 3rd, 2015 | +New Release: 2.9.0 | +
Jul 7th, 2015 | +A Formal Commitment to New Language Features | +
May 31st, 2015 | +New Release: 2.8.0 | +
Apr 10th, 2015 | +New Release: 2.7.0 | +
Feb 28th, 2015 | +New Release: 2.6.3 | +
Feb 28th, 2015 | +New Release: 2.6.2 | +
Feb 27th, 2015 | +New Release: 2.6.1 | +
Jan 21st, 2015 | +New Release: 2.6.0 | +
Dec 27th, 2013 | +What's new in JSHint (December, 2013) | +
Oct 21st, 2013 | +What's new in JSHint (October, 2013) | +
Oct 8th, 2013 | +JSHint 3 plans | +
Oct 1st, 2013 | +New JSHint website | +
Aug 15th, 2013 | +New Release: 2.1.10 | +
Aug 15th, 2013 | +JSHint 2.1.10 | +
Aug 2nd, 2013 | +Better integration with NPM | +
Jul 31st, 2013 | +ES6 default parameters | +
Jul 29th, 2013 | +New Release: 2.1.6 | +
Jul 29th, 2013 | +Fun little numbers | +
Jul 28th, 2013 | +JSHint 2.1.6 | +
May 21st, 2013 | +New Release: 2.1.0 | +
May 20th, 2013 | +JSHint 2.1.0 | +
May 8th, 2013 | +New Release: 2.0.0 | +
May 7th, 2013 | +JSHint 2.0.0 | +
Mar 5th, 2013 | +JSHint 1.1.0 is out | +
Feb 27th, 2013 | +JSHint 1.0.0 is out | +
Jan 18th, 2013 | +JSHint 1.0.0 RC4 | +
Jan 18th, 2013 | +New Release: 1.0.0-rc4 | +
Jan 2nd, 2013 | +New Release: 1.0.0-rc3 | +
Jan 1st, 2013 | +JSHint 1.0.0 RC3 | +
Dec 31st, 2012 | +New Release: 1.0.0-rc2 | +
Dec 31st, 2012 | +JSHint 1.0.0 RC2 | +
Dec 29th, 2012 | +JSHint 1.0.0 RC1 | +
Oct 24th, 2012 | +New blog | +
Sep 25th, 2012 | +New release: r12 | +
Sep 3rd, 2012 | +New release: r11 | +
Aug 20th, 2012 | +New release: r10 | +
Aug 5th, 2012 | +New release: r09 | +
Jul 26th, 2012 | +New release: r08 | +
May 1st, 2012 | +New release: r07 | +
Feb 13th, 2012 | +Bugfix release: r06 | +
Jan 19th, 2012 | +New release: r05 | +
Jan 8th, 2012 | +Bugfix release: r04 | +
Dec 30th, 2011 | +New release: r03 | +
Dec 23rd, 2011 | +New release: r02 | +
Dec 20th, 2011 | +Hello | +
Thanks to Dave Camp JSHint now supports list comprehensions, a declarative way of +transforming a list:
+ +[ for (i of [ 1, 2, 3 ]) i + 2 ]; // Returns [ 3, 4, 5 ]
+
+Note: SpiderMonkey currently implements a slightly different syntax for list comprehensions which is also supported +by JSHint.
+ +Thanks to Rob Wu, Ryan Cannon, Dave Camp, Amir Livneh, Josh Hoff, Nikolay S. Frantsev, Lapo Luchini, Lukas Domnick for sending patches!
+ +A few weeks ago we shipped the new JSHint website and it seemed like +people liked it! In this blog post, I'd like to share my plans for the +next major release of JSHint.
+ +The next release will be a backwards incompatible release in which I plan +to clean up and simplify our core package. Here are my current goals +for that release:
+ +JSHINT(...) &&
+JSHINT.data()
to something better.As you can guess from my goals, I don't consider JSHint to be a style tool. +I strongly believe that there's a market for a good JavaScript style and +formatting tool, but I don't think it should be JSHint's job.
+ +JSHint is really good at giving programmers insight into their code +and I plan to iterate and improve that side of it. For example, +wouldn't it be nice if JSHint could not only warn about undefined variables +but also detect if that undefined variable is the result of a typo?
+ +Today many editors, IDEs and teaching services use JSHint to do static +analysis. The next major release will be about making their life easier. +If you're using JSHint within your product or organization and have feedback +on how you'd like JSHint to be improved, now is a perfect time to +send me an email.
+ +This doesn't mean there won't be any updates to the current stable branch (2.x) +of JSHint until 3 is ready. There will be changes, bug fixes and new features +published soon.
+Our latest release, 2.4.0, +was mostly a bug fix release. We fixed a lot of parsing bugs. Among them were +quite a few serious ES6-related bugs which were blocking some people and +companies from using JSHint on their ES6 codebases. Since ES6 is still in-progress, +a moving target, there might be some minor inconsistencies but overall, +if you're using more-or-less stable parts of ES6, you can use JSHint to lint +your forward-thinking code.
+ +We also fixed a couple of bugs that were resulting in JSHint crashing +when trying to parse invalid code. If your code is syntactically +broken beyond all hope JSHint might generate false-positive warnings +and then give up but it should never crash.
+ +Thanks to @BenoitZugmeyer we added +a new flag to the JSHint CLI program, --extract, that allows JSHint +to lint JavaScript within HTML files.
+ +tmp ☭ cat test.html
+<html>
+ <head>
+ <title>Hello, World!</title>
+ <script>
+ function hello() {
+ return "Hello, World!";
+ }
+ </script>
+ </head>
+ <body>
+ <h1>Hello, World!</h1>
+ <script>
+ console.log(hello())
+ </script>
+ </body>
+</html>
+
+tmp ☭ jshint --extract=auto test.html
+test.html: line 13, col 27, Missing semicolon.
+
+1 error
+
+Another new flag is --exclude-path which allows you to provide your +own .jshintignore file. Or you can point it to the .gitignore file and +kill two birds with one stone: exclude files both from your version control +system and JSHint.
+ +As always, the detailed list of changes is on GitHub: JSHint 2.4.0 is released.
+ +Our next major release is shaping up nicely. I removed a lot of old code, +split jshint.js into smaller pieces and changed its API. New API doesn't +mutate any global object, it simply takes your arguments and returns the +resulting object:
+ +var jshint = require("jshint");
+var report = jshint.run(source, options, globals);
+
+report.data.errors.forEach(function (err) {
+ console.log(err.line, err.message);
+});
+
+Almost all bug fixes and new features from 2.4.0 were backported into the +3.x tree so the codebase is pretty well synced at this point.
+ +On the development side, I'm spending a lot of time trying to reduce the +internal state of JSHint. This means a lot of decoupling, rewriting and +re-architecting but the codebase is already looking much better.
+ +I still haven't decided if I want to make JSHint's internal parser +to generate an AST or if I want to take a shortcut and use Acorn to do +the work for me. (This doesn't mean throwing away JSHint's +parser. We can't do that because no other parser can parse incomplete +files like JSHint and no other parser supports ES6 and Mozilla JavaScript +extensions.) Given that Acorn doesn't support ES6 syntax yet and will +probably never support Mozilla JavaScript extensions, in some cases JSHint +will not be able to return an AST. But for majority of users it should be +fine. Or, maybe, I can do Acorn as a stop-gap solution while I'm patching +JSHint to generate its own tree. Since everyone uses Mozilla Parser API +it should be easy enought to do a drop-in replacement.
+We shipped a couple of exciting new features in October. Here's a short +write-up about some of them.
+ +Thanks to Daniel Miladinov, JSHint +can now ignore blocks of code which makes it easier to use JSHint with +JavaScript language extensions such as Facebook React.
+ +// Code here will be linted with JSHint.
+/* jshint ignore:start */
+// Code here will be linted with ignored by JSHint.
+/* jshint ignore:end */
+
+All code in between ignore:start and ignore:end won't be +passed to JSHint at all. Additionally, you can ignore a single +line with a trailing comment:
+ +ignoreThis(); // jshint ignore:line
+
+Thanks to Oleg Grenrus, JSHint can now +check the use of a typeof operator when its result is compared +to a string. This operator has only a limited set of possible return +values (mdn). +If you try to compare it with an invalid value, JSHint will produce +a warning informing you about the issue. You can disable this check +with a notypeof option.
+ +// 'fuction' instead of 'function'
+if (typeof a == "fuction") { // Warning: Invalid typeof value 'fuction'
+ /* ... */
+}
+
+Thanks to Caitlin Potter, there's a new +option—freeze—that prohibits the modification of native objects +such as Array, Number, Date, etc. It's generally a bad idea to modify +these objects unless you're absolutely sure you know what you're doing.
+ +/* jshint freeze:true */
+Array.prototype.count = function (value) { return 4; };
+// -> Warning: Extending prototype of native object: 'Array'.
+
+This option is still under development. Do you have suggestions +on how we can improve it? Tell us here.
+ +We now use GitHub releases to host our changesets:
+ + +In recent months, JSHint has been receiving requests to support proposed
+JavaScript language features like
+async
/await
, method
+decorators, and class
+property declarations
+[1]. The JSHint team has turned down each request, even after the
+release of ES2015. This has
+not been easy; as open source project maintainers, nothing gives us more
+pleasure than to write code in benefit of our users. We've tried to explain our
+motivations in an ad-hoc way, but it's always come off as a bit haphazard. We'd
+like to take some time to more thoroughly describe our thought process.
The long and short of it is: JSHint will require all language extension +proposals to be at "Stage 2" of TC-39's standardization +process +before parsing and linting them.
+ +Projects like Traceur and +Babel have become very popular through progressive +implementation of the latest features and proposals. It's fair to question why +JSHint should be any different.
+ +First off, it's difficult for the project maintainers. This is not really a +defensible motivation; we only offer it in the interest of full disclosure. +Over the years, JSHint has grown from JSLint thanks to +the efforts of hundreds of contributors. This has been key to its success, but +it has also contributed to a fair amount of technical debt. Extending the +parser requires a fair amount of study, and even then, it isn't always clear +how to do this cleanly.
+ +The project has tried to be progressive about new syntax in the past
+[2], and this has often contributed to technical debt. For instance,
+JSHint continues to
+(grudgingly)
+maintain a moz
option for Mozilla-specific
+extensions,
+and the current esnext
option includes non-standard array comprehensions. (By
+the way: now that ES2015 is released, that name describes a non-existent
+specification draft.)
A plugin system is one possible +way to address this, but that will require a large effort involving careful +design, spanning refactoring, and a long-term commitment to implementation +details.
+ +More importantly, it's hazardous for developers. Inconsistencies within +toolchains will gate developers on the lowest common denominator. Imagine the +day that your transpiler supports draft 17 but JSHint has moved to draft 18. +Even if you're not struggling with coordination issues between parsers, the +release cycle for a "progressive" parser would leave most application +developers behind. Projects would frequently rely on outdated release channels +that no longer received bug fixes or new features.
+ +JSHint was born out of a reluctance to make decisions on behalf of the +user, +so while we think the above considerations should be made clear to JSHint's +users, we haven't made this decision based on them.
+ +We also believe it's harmful for the ecosystem. Empowering developers to +write non-standard code can have long-term effects on the open source +ecosystem. Code has a tendency to live longer than we expect, but it isn't +always maintained throughout its lifetime. We all look forward to the day that +features like method decorators are standard and widely-supported. Prior to +that, it's important to remember that the code we write with experimental +language features is itself non-standard. It will be frustrating if, in 2 +years, you are reviewing older code that seems to use "standard" function +decorators but that in reality depends on the syntax and semantics of "revision +12" of the function decorator proposal. The differences may be subtle, and you +will be forced to research the behavior of this not-quite-JavaScript before you +can contribute to the project.
+ +Finally, it's unhealthy for the language. TC39 does not operate from an
+ivory tower. They recognize practical considerations of patterns in existing
+code. Look no further than Annex
+B
+for proof of that. Sometimes, that is a good thing. The Promises/A+
+spec offered a clear way forward when Promises
+were first considered for inclusion in ES2015. Sometimes, this is a bad thing.
+It's the reason why we expect
+Array.prototype.includes
+instead of
+Array.prototype.contains
.
+The proliferation of production code can have a solidifying
+effect
+on new features. To the extent that JSHint is a channel through which new
+JavaScript flows (a minuscule one to be sure), we want to cooperate with the
+design process.
Stage 2 seems specifically designed for our position in the ecosystem.
+ +It's not too early. Features in this stage have a formal definition (so we have +a consistent and complete set of instructions to build from). These features +are also relatively stable, so JSHint has a chance to keep up with the latest +draft modifications.
+ +It's also not too late. The design process can still benefit from the +experience of developers applying a given pattern to their code. The process +document defines "incremental" changes expected for Stage 2 proposals, and only +recommends "experimental" implementations. You might say, "these features seem +stable enough", but +the truth is, JSHint was dealing with non-trivial modifications to ES2015 from +the moment we implemented them until as late as May of this year [3]. +So it's worth noting that JSHint is still taking some risk here.
+ +We think there's tremendous value in experimentation at earlier stages in the +process. We also feel that research should be conducted in non-production +settings in order to avoid the more fundamental problems discussed above. +Early-stage experiments have less to gain from automated code analysis both +because of their limited scope and because their syntax is already verified by +a "transpiler". In these contexts, linting has much more limited relevance.
+ +Here's the practical effect of all that talk:
+ +esnext
option; it will instead support
+esversion: 6
.moz
option, and it will be the only
+setting that enables array comprehension parsing.esversion: 7
option until that specification is
+finalized by ECMA.experimental
+configuration namespace. These features will be clearly documented as subject
+to breaking changes between major releases.This policy means denying first-class support for non-standard and early
+proposal features. JSHint will continue to support ignore
directives as a
+coarse-grained mechanism for operating on non-standard and early-proposal
+features, but we know other linting tools go much farther than
+that. We're motivated by our
+responsibility to developers but also to the open source ecosystem and to the
+standards process itself. We hope JSHint's usership continues to enjoy the tool
+because they share these same values.
esnext
) error: `import * as foo from
+'bar'For the last couple of weeks I've been working on a new homepage for JSHint +and today I'm proud to announce the new jshint.com!
+ + + +I decided to change the website to show the direction where I'm taking JSHint +and where I'd like to see other developer tools go in the near future.
+ +If you go to the front-page right now, you'll notice +that it doesn't have a Lint button anymore. Once you start typing your +code, JSHint will always be working in the background, providing you with +valuable data about your code. This data consists of not only warnings but +also of different metrics such as the cyclomatic complexity. These metrics +help you step back and look at the overall health of your codebase.
+ +I think that such instant feedback from the tools that monitor your code +can be quite useful and, now that the foundation is here, I plan to experiment +with these ideas using both JSHint and +JSHint.com.
+ +Stay tuned!
+This page's content is sourced from the JSHint project repository. If you spot an error, please open an issue or (better yet) make a pull request!
+ +Contributions to the project generally take one of three forms:
+ +This document describes the best way to contribute each of these. The +maintenance team will assign one of the following labels to document the +report's severity:
+ +If you believe you have identified incorrect behavior, please let the team know +by filing an issue. In order to help the team diagnose and fix the problem, the +issue report should have the following information:
+ +If there is some new functionality that you think would improve JSHint, we'd +love to hear about it! Great feature requests contain the following +information:
+ +If you are capable of implementing the feature and submitting a patch, then all +the better! Please begin by making a feature request so that the maintainers +can verify that it is appropriate and help shape its design.
+ +The best way to make sure your issue is addressed is to submit a patch. We +accept patches through all mediums: pull requests, email, issue comment, tweet +with a link to a snippet, etc.
+ +However, before sending a patch, please make sure that the following applies:
+ +npm test
).JSHint is developed using Node.js and has a number of
+dependencies specified in its package.json
file. To install them just run the
+following command from within your repo directory:
$ npm install
+
+After that, you will be able to run the edge version of JSHint using
+bin/jshint
or build the release bundles using bin/build
.
This section describes our coding style guide. You might not agree with it and +that's fine but if you're going to send us patches treat this guide as a law.
+ +Our main rule is simple:
+ ++ +All code in any code-base should look like a single person typed it, no +matter how many people contributed. +—idiomatic.js
if
, for
, while
, etc.No spaces between function
and (
for anonymous functions, no space between name and (
for named functions:
var a = function() {};
+function a() {}
Feel free to indent variable assignments or property definitions if it makes the code look better. But don't abuse that:
// Good
+var next = token.peak();
+var prev = token.peak(-1);
+var cur = token.current;
+
+var scope = {
+ name: "(global)",
+ parent: parentScope,
+ vars: [],
+ uses: []
+};
+
+// Bad
+var cur = token.current;
+var isSemicolon = cur.isPunctuator(";");
Wrap multi-line comments with new lines on both sides.
Use one var
per variable unless you don't assign any values to it (and it's short enough):
var token = tokens.find(index);
+var scope = scopes.current;
+var next, prev, cur;
Don't be overly descriptive with your variable names but don't abuse one-letter variables either. Find a sweet spot somewhere in between.
===
and !==
.Don't short-circuit expressions if you're not assigning the result:
// Good
+token = token || tokens.find(0);
+
+// Bad
+token.isPunctuator(";") && report.addWarning("W001");
+
+// Good
+if (token.isPunctuator(";"))
+ report.addWarning("W001");
Commit messages are written in a simple format which clearly describes the purpose of a change.
+ +The format in general should look like this:
+ +[[TYPE]] <Short description>
+<Blank line>
+
+<Body / Detailed description>
+
+<Footer>
+
+Line lengths in commit messages are not strict, but good commit messages should have headers of no +more than 60 characters, and bodies/footers wrapped at 100 columns. This renders nicely on Github's +UI.
+ +The first line is the commit message header, which will indicate the type of change, and a general +description of the change. This should fit within 60 characters, ideally. For instance:
+ +[[FIX]] Ignore "nocomma" when parsing object literals
+
+The title [[FIX]]
indicates that the change is a bugfix, while the remainder clarifies what the
+change actually contains.
Several commit types are used by jshint:
+ +[[FIX]]
--- Commit fixes a bug or regression[[FEAT]]
--- Commit introduces new functionality[[DOCS]]
--- Commit modifies documentation. Docs commits should only touch comments in source code, or scripts and assets which are used to generate the documentation.[[TEST]]
--- Commit modifies tests or test infrastructure only[[CHORE]]
--- Commit affects dev-ops, CI, or package dependencies<Body>
is a detailed commit message explaining exactly what has changed, and a summary of the
+reason why. Lines in the body should be wrapped to 100 characters for best rendering.
For a historical example, see this example
+ +<Footer>
contains a description of any breaking changes, no matter how subtle, as well as a list
+of issues affected or fixed by this commit. Lines in the footer should be wrapped to 100 characters
+for best rendering.
For instance:
+ +[[FEAT]] Enable `norecurs` option by default
+
+Commit 124124a7f introduced an option which forbids recursion. We liked it so much, we've enabled
+it by default.
+
+BREAKING CHANGE:
+
+This change will break the CI builds of many applications and frameworks.
+
+In order to work around this issue, you will need to re-engineer your applications and frameworks
+to avoid making recursive calls. Use Arrays as stacks rather than relying on the VM call stack.
+
+Fixes #1000009
+Closes #888888
+Closes #77777
+ JSHint exposes a JavaScript API for programmatic access in environments like +web browsers and Node.js.
+ +JSHINT( source, options, predef )
Analyze source code for errors and potential problems.
+ +Parameters:
+ +source
JSHINT(["'use strict';", "console.log('hello, world!');"]);
options
JSHINT(mySource, { undef: true });
predef
globals
linting
+optionJSHINT(mySource, myOptions, { jQuery: false });
JSHINT.errors
An array of warnings and errors generated by the most recent invocation of
+JSHINT
.
JSHINT.data()
Generate a report containing details about the most recent invocation of
+JSHINT
.
For example, the following code:
+ +var source = [
+ 'function goo() {}',
+ 'foo = 3;'
+];
+var options = {
+ undef: true
+};
+var predef = {
+ foo: false
+};
+
+JSHINT(source, options, predef);
+
+console.log(JSHINT.data());
+
+...will produce the following output:
+ +{
+ functions: [
+ {
+ name: 'goo',
+ param: undefined,
+ line: 1,
+ character: 14,
+ last: 1,
+ lastcharacter: 18,
+ metrics: {
+ complexity: 1,
+ parameters: 0,
+ statements: 0
+ }
+ }
+ ],
+ options: {
+ undef: true,
+ indent: 4,
+ maxerr: 50
+ },
+ errors: [
+ {
+ id: '(error)',
+ raw: 'Read only.',
+ code: 'W020',
+ evidence: 'foo = 3;',
+ line: 2,
+ character: 1,
+ scope: '(main)',
+ a: undefined,
+ b: undefined,
+ c: undefined,
+ d: undefined,
+ reason: 'Read only.'
+ }
+ ],
+ globals: [
+ 'goo',
+ 'foo'
+ ],
+ unused: [
+ {
+ name: 'goo',
+ line: 1, character: 10
+ }
+ ]
+}
+ The JSHint CLI can be installed via npm (see the Installation page +for instructions).
+ +Contents: Specifying Input · Specifying Linting +Options · Special Options · +Ignoring Files · Flags
+ + + +The jshint
executable accepts paths to files, which it will read and lint:
$ jshint myfile.js
+myfile.js: line 10, col 39, Octal literals are not allowed in strict mode.
+
+1 error
+
+If a file path is a dash (-
) then JSHint will read from standard input.
The jshint
executable is capable of applying linting options
+specified in an external JSON-formatted file. Such a file
+might look like this:
{
+ "curly": true,
+ "eqeqeq": true,
+ "nocomma": true
+}
+
+jshint
will look for this configuration in a number of locations, stopping at
+the first positive match:
--config
flagpackage.json
located in the current directory or any parent
+of the current directory (the configuration should be declared as the
+jshintConfig
attribute of that file's JSON value).jshintrc
located in the current directory or any parent of
+the current directory.jshintrc
located in the current user's "home" directory
+(where defined)If this search yields no results, jshint
will lint the input code as if no
+linting rules had been enabled.
The command-line interface offers some special options in +addition to the ones available in other contexts
+ + + +The following options concern the file system and are only available from +within configuration files (i.e. not from inline directives or the API):
+ +extends
Use another configuration file as a "base". The value of this option should be +a file path to another configuration file, and the path should be relative to +the current file.
+ +For example, you might define a .jshintrc
file in the top-level directory of
+your project (say, `./.jshintrc') to specify the linting
+options you would like to use in your entire project:
{
+ "undef": true,
+ "unused": true
+}
+
+You may want to re-use this configuration for your project's automated tests,
+but also allow for global
+variables that are specific to the
+test environment. In this case, you could create a a new file in their test
+directory, (./test/.jshintrc
for example), and include the following
+configuration:
{
+ "extends": "../.jshintrc",
+ "globals": {
+ "test": false,
+ "assert": false
+ }
+}
+
+overrides
Specify options that should only be applied to files matching a given path +pattern.
+ +The following configuration file disallows variable
+shadowing for all files and allows expressions as
+statements for only those files ending in -test.js
:
{
+ "shadow": false,
+ "overrides": {
+ "lib/*-test.js": {
+ "expr": true
+ }
+ }
+}
+
+
+
+jshint
can be configured to ignore files based on their location in the
+filesystem. You may create a dedicated "ignore" file to list any number of file
+names, file paths, or file path patterns that should not be linted. Path
+patterns will be interpreted using the minimatch
npm
+module, which itself is based on the
+Unix filename matching syntax, fnmatch.
build/
+src/**/tmp.js
+
+jshint
will look for this configuration in a number of locations, stopping at
+the first positive match:
--exclude-path
flag.jshintignore
located in the current directory or any parent
+of the current directoryIf this search yields no results, jshint
will not ignore any files.
--config
Explicitly sets the location on the file system from which jshint
should load
+linting options.
$ jshint --config ../path/to/my/config.json
+
+--reporter
Allows you to modify JSHint's output by replacing its default output function +with your own implementation.
+ +$ jshint --reporter=myreporter.js myfile.js
+
+This flag also supports two pre-defined reporters: jslint, to make output +compatible with JSLint, and checkstyle, to make output compatible with +CheckStyle XML.
+ +$ jshint --reporter=checkstyle myfile.js
+<?xml version="1.0" encoding="utf-8"?>
+<checkstyle version="4.3">
+ <file name="myfile.js">
+ <error line="10" column="39" severity="error"
+ message="Octal literals are not allowed in strict mode."/>
+ </file>
+</checkstyle>
+
+See also: Writing your own JSHint reporter.
+ +--verbose
Adds message codes to the JSHint output.
+ +--show-non-errors
Shows additional data generated by JSHint.
+ +$ jshint --show-non-errors myfile.js
+myfile.js: line 10, col 39, Octal literals are not allowed in strict mode.
+
+1 error
+
+myfile.js:
+ Unused variables:
+ foo, bar
+
+--extra-ext
Allows you to specify additional file extensions to check (default is .js).
+ +--extract=[auto|always|never]
Tells JSHint to extract JavaScript from HTML files before linting:
+ +tmp ☭ cat test.html
+<html>
+ <head>
+ <title>Hello, World!</title>
+ <script>
+ function hello() {
+ return "Hello, World!";
+ }
+ </script>
+ </head>
+ <body>
+ <h1>Hello, World!</h1>
+ <script>
+ console.log(hello())
+ </script>
+ </body>
+</html>
+
+tmp ☭ jshint --extract=auto test.html
+test.html: line 13, col 27, Missing semicolon.
+
+1 error
+
+If you set it to always JSHint will always attempt to extract JavaScript. +And if you set it to auto it will make an attempt only if file looks +like it's an HTML file.
+ +--exclude
Allows you to specify directories which you DON'T want to be linted.
+ +--exclude-path
Allows you to provide your own .jshintignore file. For example, you can point +JSHint to your .gitignore file and use it instead of default .jshintignore.
+ +--prereq
Allows you to specify prerequisite files i.e. files which include definitions +of global variables used throughout your project.
+ +--help
Shows a nice little help message similar to what you're reading right now.
+ +--version
Shows the installed version of JSHint.
+Yes, you may do so by authoring a new reporter that composes the reporters you +are interested in using.
+ +For example, to use reporters named first-reporter
and second-reporter
,
+create a new module that invokes them both:
var first = require('first-reporter');
+var second = require('second-reporter');
+
+exports.reporter = function(results, data, opts) {
+ first.reporter(results, data, opts);
+ second.reporter(results, data, opts);
+};
+
+Save that to a file named dual-reporter.js
, and run JSHint with:
$ jshint --reporter ./dual-reporter.js
+
+...and you should see the output of first-reporter
followed by the output of
+second-reporter
.
This approach is especially well-suited to using the different reporters'
+output in different contexts (for instance, e-mailing one reporter's output to
+the development team and feeding another reporter's output to a continuous
+integration system). You might output a custom delimiter between the output
+streams in order to demultiplex them. Alternatively, you might replace the
+global process.stdout
value with another stream between reporter invocations.
+This latter solution is somewhat fragile because it involves mutating global
+state--a future release of JSHint may expose a safer mechanism for this
+operation.
See the documentation on JSHint's "reporter" +API for more details on creating your own +reporter.
+ +If your code looks like this:
+ +function test(a, b, c) {
+ return c;
+}
+
+Then JSHint will not warn about unused variables a
and b
if you set the
+unused
option to true
. It figures that if unused arguments are followed
+by used ones, it was a conscious decision and not a typo. If you want to
+warn about all unused variables not matter where they appear, set the unused
+option to strict
:
/*jshint unused:strict */
+function test(a, b, c) {
+ return c;
+}
+
+// Warning: unused variable 'a'
+// Warning: unused variable 'b'
+
+For more information see: options/unused.
+JSHint is a program that flags suspicious usage in programs written in JavaScript. +The core project consists of a library itself as well as a CLI program distributed +as a Node module.
+ +More docs: List of all JSHint options · Command-line +Interface · API · Writing your own +reporter · FAQ
+ +First, check out the installation instructions for details on +how to install JSHint in your preferred environment. Both the command line +executable and the JavaScript API offer unique ways to configure JSHint's +behaviour. The most common usages are:
+ + + +Regardless of your preferred environment, you can control JSHint's behavior +through specifying any number of linting options. In +addition, JSHint will honor any directives declared within the input source +code--see the section on in-line directives for more +information.
+ +JSHint comes with a default set of warnings but it was designed to be very
+configurable. There are three main ways to configure your copy of JSHint:
+you can either specify the configuration file manually via the --config
flag,
+use a special file .jshintrc
or put your config into your projects package.json
+file under the jshintConfig
property. In case of .jshintrc
, JSHint will start
+looking for this file in the same directory as the file that's being linted.
+If not found, it will move one level up the directory tree all the way up to
+the filesystem root. (Note that if the input comes from stdin, JSHint doesn't
+attempt to find a configuration file)
This setup allows you to have different configuration files per project. Place +your file into the project root directory and, as long as you run JSHint from +anywhere within your project directory tree, the same configuration file will +be used.
+ +Configuration file is a simple JSON file that specifies which JSHint options
+to turn on or off. For example, the following file will enable warnings about
+undefined and unused variables and tell JSHint about a global variable named
+MY_GLOBAL
.
{
+ "undef": true,
+ "unused": true,
+ "globals": {
+ "MY_GLOBAL": true
+ }
+}
+
+
+
+In addition to using configuration files you can configure JSHint from within your
+files using special comments. These comments start with a label such as
+jshint
or globals
(complete list below) and are followed by a
+comma-separated list of values. For example, the following snippet will enable
+warnings about undefined and unused variables and tell JSHint about a global
+variable named MY_GLOBAL
.
/* jshint undef: true, unused: true */
+/* globals MY_GLOBAL */
+
+You can use both multi- and single-line comments to configure JSHint. These +comments are function scoped meaning that if you put them inside a function they +will affect only this function's code.
+ +Here's a list of configuration directives supported by JSHint:
+ +A directive for setting JSHint options.
+ +/* jshint strict: true */
+
+A directive for setting JSHint-compatible JSLint options.
+ +/* jslint vars: true */
+
+A directive for telling JSHint about global variables that are defined
+elsewhere. If value is false
(default), JSHint will consider that variable
+as read-only. Use it together with the undef
option.
/* globals MY_LIB: false */
+
+You can also blacklist certain global variables to make sure they are not used +anywhere in the current file.
+ +/* globals -BAD_LIB */
+
+A directive for telling JSHint about global variables that are defined in the
+current file but used elsewhere. Use it together with the unused
option.
/* exported EXPORTED_LIB */
+
+A directive for telling JSHint about all properties you intend to use. This +directive is deprecated.
+ +A directive for telling JSHint to ignore a block of code.
+ +// Code here will be linted with JSHint.
+/* jshint ignore:start */
+// Code here will be ignored by JSHint.
+/* jshint ignore:end */
+
+All code in between ignore:start
and ignore:end
won't be passed to JSHint
+so you can use any language extension such as Facebook React.
+Additionally, you can ignore a single line with a trailing comment:
ignoreThis(); // jshint ignore:line
+
+Most often, when you need to tune JSHint to your own taste, all you need to do +is to find an appropriate option. Trying to figure out how JSHint options work +can be confusing and frustrating (and we're working on fixing that!) so please +read the following couple of paragraphs carefully.
+ +JSHint has two types of options: enforcing and relaxing. The former are used to +make JSHint more strict while the latter are used to suppress some warnings. +Take the following code as an example:
+ +function main(a, b) {
+ return a == null;
+}
+
+This code will produce the following warning when run with default JSHint +options:
+ +line 2, col 14, Use '===' to compare with 'null'.
+
+Let's say that you know what you're doing and want to disable the produced
+warning but, in the same time, you're curious whether you have any variables
+that were defined but never used. What you need to do, in this case, is to
+enable two options: one relaxing that will suppress the === null
warning and
+one enforcing that will enable checks for unused variables. In your case these
+options are unused
and eqnull
.
/*jshint unused:true, eqnull:true */
+function main(a, b) {
+ return a == null;
+}
+
+After that, JSHint will produce the following warning while linting this example +code:
+ +demo.js: line 2, col 14, 'main' is defined but never used.
+demo.js: line 2, col 19, 'b' is defined but never used.
+
+Sometimes JSHint doesn't have an appropriate option that disables some
+particular warning. In this case you can use jshint
directive to disable
+warnings by their code. Let's say that you have a file that was created by
+combining multiple different files into one:
"use strict";
+/* ... */
+
+// From another file
+function b() {
+ "use strict";
+ /* ... */
+}
+
+This code will trigger a warning about an unnecessary directive in function b
.
+JSHint sees that there's already a global "use strict" directive and informs you
+that all other directives are redundant. But you don't want to strip out these
+directives since the file was auto-generated. The solution is to run JSHint
+with a flag --verbose
and note the warning code (W034 in this case):
$ jshint --verbose myfile.js
+myfile.js: line 6, col 3, Unnecessary directive "use strict". (W034)
+
+Then, to hide this warning, just add the following snippet to your file:
+ +/* jshint -W034 */
+
+A couple things to note:
+ +W
), it doesn't work
+with errors (code starts with E
).To re-enable a warning that has been disabled with the above snippet you can +use:
+ +/* jshint +W034 */
+
+This is especially useful when you have code which causes a warning but that +you know is safe in the context. In these cases you can disable the warning as +above and then re-enable the warning afterwards:
+ +var y = Object.create(null);
+// ...
+/*jshint -W089 */
+for (var prop in y) {
+ // ...
+}
+/*jshint +W089 */
+
+This page contains a list of all options supported by JSHint.
+ +By default JSHint warns when you omit break
or return
statements within
+switch statements:
switch (cond) {
+case "one":
+ doSomething(); // JSHint will warn about missing 'break' here.
+case "two":
+ doSomethingElse();
+}
+
+If you really know what you're doing you can tell JSHint that you intended the
+case block to fall through by adding a /* falls through */
comment:
switch (cond) {
+case "one":
+ doSomething();
+ /* falls through */
+case "two":
+ doSomethingElse();
+}
+ When set to true, these options will make JSHint produce more warnings about your code.
+ ++ bitwise + | +
+
+ This option prohibits the use of bitwise operators such as |
+
+ camelcase + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option allows you to force all variable names to use either +camelCase style or UPPER_CASE with underscores. + |
+
+ curly + | +
+
+ This option requires you to always put curly braces around blocks in +loops and conditionals. JavaScript allows you to omit curly braces when +the block consists of only one statement, for example:
However, in some circumstances, it can lead to bugs (you'd think that
+
+ |
+
+ enforceall + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ The option cannot be maintained without automatically opting users in to new features. This can lead to unexpected + warnings/errors in when upgrading between minor versions of + JSHint. +This option is a short hand for the most strict JSHint configuration as +available in JSHint version 2.6.3. It enables all enforcing options and +disables all relaxing options that were defined in that release. + |
+
+ eqeqeq + | +
+
+ This options prohibits the use of |
+
+ es3 + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ Use This option tells JSHint that your code needs to adhere to ECMAScript 3 +specification. Use this option if you need your program to be executable +in older browsers—such as Internet Explorer 6/7/8/9—and other legacy +JavaScript environments. + |
+
+ es5 + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ Use This option enables syntax first defined in the ECMAScript 5.1 +specification. This includes allowing reserved +keywords as object properties. + |
+
+ esversion + | +
+
+ This option is used to specify the ECMAScript version to which the code +must adhere. It can assume one of the following values:
|
+
+ forin + | +
+
+ This option requires all
For more in-depth understanding of |
+
+ freeze + | +
+
+ This options prohibits overwriting prototypes of native objects such as
+
+ |
+
+ funcscope + | +
+
+ This option suppresses warnings about declaring variables inside of +control +structures while accessing them later from the outside. Even though +JavaScript has only two real scopes—global and function—such practice +leads to confusion among people new to the language and hard-to-debug +bugs. This is why, by default, JSHint warns about variables that are +used outside of their intended scope.
+ |
+
+ futurehostile + | +
+
+ This option enables warnings about the use of identifiers which are +defined in future versions of JavaScript. Although overwriting them has +no effect in contexts where they are not implemented, this practice can +cause issues when migrating codebases to newer versions of the language. + |
+
+ globals + | +
+
+ This option can be used to specify a white list of global variables that
+are not formally defined in the source code. This is most useful when
+combined with the Setting an entry to See also the "environment" options: a set of options to be used as short +hand for enabling global variables defined in common JavaScript +environments. To configure |
+
+ immed + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option prohibits the use of immediate function invocations without +wrapping them in parentheses. Wrapping parentheses assists readers of +your code in understanding that the expression is the result of a +function, and not the function itself. + |
+
+ indent + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check + out the JSCS project. +This option sets a specific tab width for your code. + |
+
+ iterator + | +
+
+ This option suppresses warnings about the |
+
+ latedef + | +
+
+ This option prohibits the use of a variable before it was defined. +JavaScript has function scope only and, in addition to that, all variables +are always moved—or hoisted— to the top of the function. This behavior can +lead to some very nasty bugs and that's why it is safer to always use +variable only after they have been explicitly defined. Setting this option to "nofunc" will allow function declarations to be +ignored. For more in-depth understanding of scoping and hoisting in JavaScript, +read JavaScript Scoping and +Hoisting +by Ben Cherry. + |
+
+ maxcomplexity + | +
+
+ This option lets you control cyclomatic complexity throughout your code. +Cyclomatic complexity measures the number of linearly independent paths +through a program's source code. Read more about cyclomatic complexity on +Wikipedia. + |
+
+ maxdepth + | +
+
+ This option lets you control how nested do you want your blocks to be:
+ |
+
+ maxerr + | +
+
+ This options allows you to set the maximum amount of warnings JSHint will +produce before giving up. Default is 50. + |
+
+ maxlen + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check + out the JSCS project. +This option lets you set the maximum length of a line. + |
+
+ maxparams + | +
+
+ This option lets you set the max number of formal parameters allowed per +function:
+ |
+
+ maxstatements + | +
+
+ This option lets you set the max number of statements allowed per function:
+ |
+
+ newcap + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option requires you to capitalize names of constructor functions.
+Capitalizing functions that are intended to be used with Not doing so won't break your code in any browsers or environments but
+it will be a bit harder to figure out—by reading the code—if the
+function was supposed to be used with or without new. And this is
+important because when the function that was intended to be used with
+ |
+
+ noarg + | +
+
+ This option prohibits the use of |
+
+ nocomma + | +
+
+ This option prohibits the use of the comma operator. When misused, the +comma operator can obscure the value of a statement and promote +incorrect code. + |
+
+ noempty + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option warns when you have an empty block in your code. JSLint was +originally warning for all empty blocks and we simply made it optional. +There were no studies reporting that empty blocks in JavaScript break +your code in any way. + |
+
+ nonbsp + | +
+
+ This option warns about "non-breaking whitespace" characters. These +characters can be entered with option-space on Mac computers and have a +potential of breaking non-UTF8 web pages. + |
+
+ nonew + | +
+
+ This option prohibits the use of constructor functions for side-effects. +Some people like to call constructor functions without assigning its +result to any variable:
There is no advantage in this approach over simply calling
+ |
+
+ notypeof + | +
+
+ This option suppresses warnings about invalid
Do not use this option unless you're absolutely sure you don't want +these checks. + |
+
+ predef + | +
+
+ This option allows you to control which variables JSHint considers to be +implicitly defined in the environment. Configure it with an array of +string values. Prefixing a variable name with a hyphen (-) character will +remove that name from the collection of predefined variables. JSHint will consider variables declared in this way to be read-only. This option cannot be specified in-line; it may only be used via the +JavaScript API or from an external configuration file. + |
+
+ quotmark + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, check + out the JSCS project. +This option enforces the consistency of quotation marks used throughout
+your code. It accepts three values: |
+
+ shadow + | +
+
+ This option suppresses warnings about variable shadowing i.e. declaring a +variable that had been already declared somewhere in the outer scope.
|
+
+ singleGroups + | +
+
+ This option prohibits the use of the grouping operator when it is not +strictly required. Such usage commonly reflects a misunderstanding of +unary operators, for example:
+ |
+
+ strict + | +
+
+ This option requires the code to run in ECMAScript 5's strict mode. +Strict mode +is a way to opt in to a restricted variant of JavaScript. Strict mode +eliminates some JavaScript pitfalls that didn't cause errors by changing +them to produce errors. It also fixes mistakes that made it difficult +for the JavaScript engines to perform certain optimizations.
|
+
+ undef + | +
+
+ This option prohibits the use of explicitly undeclared variables. This +option is very useful for spotting leaking and mistyped variables.
If your variable is defined in another file, you can use the |
+
+ unused + | +
+
+ This option warns when you define and never use your variables. It is very
+useful for general code cleanup, especially when used in addition to
+
In addition to that, this option will warn you about unused global
+variables declared via the This can be set to |
+
+ varstmt + | +
+
+ When set to true, the use of VariableStatements are forbidden. +For example:
+ |
+
When set to true, these options will make JSHint produce fewer warnings about your code.
+ ++ asi + | +
+
+ This option suppresses warnings about missing semicolons. There is a lot +of FUD about semicolon spread by quite a few people in the community. +The common myths are that semicolons are required all the time (they are +not) and that they are unreliable. JavaScript has rules about semicolons +which are followed by all browsers so it is up to you to decide +whether you should or should not use semicolons in your code. For more information about semicolons in JavaScript read An Open Letter +to JavaScript Leaders Regarding +Semicolons +by Isaac Schlueter and JavaScript Semicolon +Insertion. + |
+
+ boss + | +
+
+ This option suppresses warnings about the use of assignments in cases
+where comparisons are expected. More often than not, code like
You can silence this error on a per-use basis by surrounding the assignment +with parenthesis, such as:
+ |
+
+ debug + | +
+
+ This option suppresses warnings about the |
+
+ elision + | +
+
+ This option tells JSHint that your code uses ES3 array elision elements,
+or empty elements (for example, |
+
+ eqnull + | +
+
+ This option suppresses warnings about |
+
+ esnext + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ Use This option tells JSHint that your code uses ECMAScript 6 specific +syntax. Note that not all browsers implement these features. More info: + + |
+
+ evil + | +
+
+ This option suppresses warnings about the use of |
+
+ expr + | +
+
+ This option suppresses warnings about the use of expressions where +normally you would expect to see assignments or function calls. Most of +the time, such code is a typo. However, it is not forbidden by the spec +and that's why this warning is optional. + |
+
+ globalstrict + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ Use This option suppresses warnings about the use of global strict mode. +Global strict mode can break third-party widgets so it is not +recommended. For more info about strict mode see the |
+
+ lastsemic + | +
+
+ This option suppresses warnings about missing semicolons, but only when +the semicolon is omitted for the last statement in a one-line block:
This is a very niche use case that is useful only when you use automatic +JavaScript code generators. + |
+
+ laxbreak + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option suppresses most of the warnings about possibly unsafe line
+breakings in your code. It doesn't suppress warnings about comma-first
+coding style. To suppress those you have to use |
+
+ laxcomma + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option suppresses warnings about comma-first coding style:
+ |
+
+ loopfunc + | +
+
+ This option suppresses warnings about functions inside of loops. +Defining functions inside of loops can lead to bugs such as this one:
To fix the code above you need to copy the value of
+ |
+
+ moz + | +
+
+ This options tells JSHint that your code uses Mozilla JavaScript +extensions. Unless you develop specifically for the Firefox web browser +you don't need this option. More info: + + |
+
+ multistr + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option suppresses warnings about multi-line strings. Multi-line
+strings can be dangerous in JavaScript because all hell breaks loose if
+you accidentally put a whitespace in between the escape character ( Note that even though this option allows correct multi-line strings, it +still warns about multi-line strings without escape characters or with +anything in between the escape character and a whitespace.
+ |
+
+ noyield + | +
+
+ This option suppresses warnings about generator functions with no
+ |
+
+ plusplus + | +
+
+ This option prohibits the use of unary increment and decrement
+operators. Some people think that |
+
+ proto + | +
+
+ This option suppresses warnings about the |
+
+ scripturl + | +
+
+ This option suppresses warnings about the use of script-targeted
+URLs—such as |
+
+ sub + | +
+
+
+ Warning This option has been deprecated and will be
+ removed in the next major release of JSHint.
+
+
+ JSHint is limiting its scope to issues of code correctness. If you would like to enforce rules relating to code style, + check out the JSCS + project. +This option suppresses warnings about using |
+
+ supernew + | +
+
+ This option suppresses warnings about "weird" constructions like
+
+ |
+
+ validthis + | +
+
+ This option suppresses warnings about possible strict violations when
+the code is running in strict mode and you use Note: This option can be used only inside of a function scope. +JSHint will fail with an error if you will try to set this option +globally. + |
+
+ withstmt + | +
+
+ This option suppresses warnings about the use of the More info: + + |
+
These options let JSHint know about some pre-defined global variables.
+ ++ browser + | +
+
+ This option defines globals exposed by modern browsers: all the way from
+good old Note: This option doesn't expose variables like |
+
+ browserify + | +
+
+ This option defines globals available when using the Browserify +tool to build a project. + |
+
+ couch + | +
+
+ This option defines globals exposed by +CouchDB. CouchDB is a document-oriented +database that can be queried and indexed in a MapReduce fashion using +JavaScript. + |
+
+ devel + | +
+
+ This option defines globals that are usually used for logging poor-man's
+debugging: |
+
+ dojo + | +
+
+ This option defines globals exposed by the Dojo +Toolkit. + |
+
+ jasmine + | +
+
+ This option defines globals exposed by the Jasmine unit testing +framework. + |
+
+ jquery + | +
+
+ This option defines globals exposed by the jQuery +JavaScript library. + |
+
+ mocha + | +
+
+ This option defines globals exposed by the "BDD" and "TDD" UIs of the +Mocha unit testing framework. + |
+
+ module + | +
+
+ This option informs JSHint that the input code describes an ECMAScript 6 +module. All module code is interpreted as strict mode code. + |
+
+ mootools + | +
+
+ This option defines globals exposed by the +MooTools JavaScript framework. + |
+
+ node + | +
+
+ This option defines globals available when your code is running inside
+of the Node runtime environment. Node.js is a
+server-side JavaScript environment that uses an asynchronous
+event-driven model. This option also skips some warnings that make sense
+in the browser environments but don't make sense in Node such as
+file-level |
+
+ nonstandard + | +
+
+ This option defines non-standard but widely adopted globals such as
+ |
+
+ phantom + | +
+
+ This option defines globals available when your core is running inside +of the PhantomJS runtime environment. PhantomJS +is a headless WebKit scriptable with a JavaScript API. It has fast and +native support for various web standards: DOM handling, CSS selector, +JSON, Canvas, and SVG. + |
+
+ prototypejs + | +
+
+ This option defines globals exposed by the +Prototype JavaScript framework. + |
+
+ qunit + | +
+
+ This option defines globals exposed by the QUnit unit testing +framework. + |
+
+ rhino + | +
+
+ This option defines globals available when your code is running inside +of the Rhino runtime environment. Rhino +is an open-source implementation of JavaScript written entirely in Java. + |
+
+ shelljs + | +
+
+ This option defines globals exposed by the ShellJS +library. + |
+
+ typed + | +
+
+ This option defines globals for typed array constructors. More info: + + |
+
+ worker + | +
+
+ This option defines globals available when your code is running inside +of a Web Worker. Web +Workers provide a +simple means for web content to run scripts in background threads. + |
+
+ wsh + | +
+
+ This option defines globals available when your code is running as a +script for the Windows Script +Host. + |
+
+ yui + | +
+
+ This option defines globals exposed by the YUI +JavaScript framework. + |
+
JSHint Reporter is a JavaScript file that accepts raw data from JSHint and +outputs something into the console (or another file, or sends an email; it's +really up to you).
+ +Here's the simplest reporter, the one that prints OK
if JSHint passed the file
+and FAIL
if it didn't:
module.exports = {
+ reporter: function (errors) {
+ console.log(errors.length ? "FAIL" : "OK");
+ }
+};
+
+Each reporter file must expose one function, reporter
, that accepts an array
+of errors. Each entry of this array has the following structure:
{
+ file: [string, filename]
+ error: {
+ id: [string, usually '(error)'],
+ code: [string, error/warning code],
+ reason: [string, error/warning message],
+ evidence: [string, a piece of code that generated this error]
+ line: [number]
+ character: [number]
+ scope: [string, message scope;
+ usually '(main)' unless the code was eval'ed]
+
+ [+ a few other legacy fields that you don't need to worry about.]
+ }
+}
+
+And a real-world example:
+ +[
+ {
+ file: 'demo.js',
+ error: {
+ id: '(error)',
+ code: 'W117',
+ reason: '\'module\' is not defined.'
+ evidence: 'module.exports = {',
+ line: 3,
+ character: 1,
+ scope: '(main)',
+
+ // [...]
+ }
+ },
+
+ // [...]
+]
+
+If you're still confused, JSHint repository has +an example reporter.
+This page has moved! You should be automatically redirected momentarily. Click +here if not.
+