JSHint 2.1.0 is out. This releases adds support for ES6 class syntax and fixes some issues with our parser.
- Added support for ES6
class syntax. (#1048)
- Added support for error code in the Checkstyle reporter. (#1088)
- Added support for
do statement bodies that are not block statements. (#1062)
- Fixed issues with JSHint not parsing comma expressions correctly. (#1084)
- Fixed a bug with W080 no longer pointing to relevant identifiers. (#1070)
- Fixed a potential issue with Node 0.10 and Windows. (#1065)
- Fixed issues with JSHint not parsing assignments in
switch conditionals. (#1064)
- Fixed an issue with
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!
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.
EcmaScript 5
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.
Partial support for Mozilla JavaScript extensions and ES6
Thanks to our newest core contributor, Bernard Pratz, JSHint now has partial support for Mozilla JavaScript extensions (moz option) and ES6 (esnext option):
- Destructuring assignment
const
let blocks and expressions
- Generators and iterators
- List comprehension
- Try/catch filters and multiple catch blocks
- Concise method declaration
for ... of loops
- Fat arrows
We have more patches in queue that add support for classes and other nifty ES6 things. Stay tuned!
CLI
- JSHint now looks for
.jshintrc in the directory being linted. (#833)
- Various cross-platform fixes for our Node CLI module.
- New public method for the CLI export that allows third-parties to hook into the file resolution logic. (#741)
General
-
For non-Node system we upgraded to the latest version of Browserify. This resolves some performance issues we had with Rhino.
-
Added SVG globals to the browser environment.
-
Option 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.
-
Fixed a bug where indent:false was triggering indentation warnings. (#1035)
-
Fixed a regression bug where unused was not behaving correctly. (#996)
-
Plus lots and lots of other, smaller bug fixes.
New rapid release schedule
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 1.1.0 is out! This release contains important bug fixes for 1.0.0 and a couple of new features.
-
This version adds a new environment option for PhantomJS: phantom. (#814)
-
Fixes a bug where JSHint would skip parent directory when looking for .jshintrc file. (#850)
-
Adds new option gcl to make JSHint style checks compatible with Google Closure Linter. (#812 and #811)
-
Adds a new example .jshintrc file that mirrors defaults from the website.
-
Removes errors about empty input. JSHint will now treat empty files as valid. (#767)
-
Fixes a bug where code like 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)
-
Fixes a bug where \0 in strings would produce a false positive warning.
-
Fixes a bug where unused would generate false positive warnings on ES3 future reserved words in the ES5 environment.
-
Removes support for all single-line special comments except for // 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.
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.0.0 Release Candidate 4 is now out:
- Fixes a bug with JSHint not allowing reserved words to be used as property names. (#768)
- Fixes a bug with JSHint lexer not recognizing
/ after ]. (#803)
- Fixes a bug with JSHint not recognizing
predef when its value is an array, and not an object. (#800)
- Fixes a bug with JSHint crashing on unrecoverable syntax errors such as
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 3 is now out:
- Fixes a bug with JSHint not allowing
new and debugger to appear after a comma. (#793)
- Fixes a bug with JSHint not collecting file recursively. (#794)
- Fixes a bug with JSHint crashing when future reserved words are used as identifiers.
- Adds a newline separator between files in the CLI output.
- Fixes a bug with JSHint not parsing
/*global global:true */ correctly. (#795)
- Fixes a bug with JSHint crashing when files can’t be found.
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 2 is now out:
- Fixes a bug with JSHint not recognizing regular expressions after commas. (#792)
- Fixes two failed tests on Windows. (#790)
- Fixes a bug with JSHint builder failing when there is no dist/ directory. (#788)
- Adds JSHint binary to package.json so that JSHint could be, once again, installed and used globally as a CLI program. (#787)
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!
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.
Parser
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)
General
-
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.
(#726 and #659)
-
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:
- Adds scope property to critical errors. (#714)
- Fixes a regression bug with option predef making all global variables writeable. (#665)
- Fixes a bug with JSHint not warning about potential typos on
return o.a = 1. (#670)
- Fixes a bug with implied property containing false positive data when option undef is off. (#668)
CLI
-
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:
What’s next?
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 ...
Contributors
Thanks to Bernhard K. Weisshuhn, James Allardice, Mike MacCana, Stephen Fry, Steven Olmsted, Leith Abdulla, Eric Promislow and Vlad Gurdiga for submitting patches!
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.
This is mostly a bugfix release:
- Fixed a bug where
indent behaved differently when passed as as an argument to JSHint.
- Fixed a bug where
maxparams check was failing on functions with no parameters.
- New predefined globals for YUI.
Thanks to Dav Glass, Mariusz Nowak and Brad Harris.
More posts available in the archive.