Skip to content

Commit

Permalink
tools: update ESLint to 2.9.0
Browse files Browse the repository at this point in the history
ESLint 2.9.0 fixes some minor bugs that we have been experiencing and
introduces some new rules that we may wish to consider.

PR-URL: #6498
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
  • Loading branch information
Trott committed May 4, 2016
1 parent 1027b94 commit 7a8dd69
Show file tree
Hide file tree
Showing 603 changed files with 22,448 additions and 30,406 deletions.
92 changes: 92 additions & 0 deletions tools/eslint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
v2.9.0 - April 29, 2016

* a8a2cd8 Fix: Avoid autoconfig crashes from inline comments (fixes #5992) (#5999) (Ian VanSchooten)
* 23b00e0 Upgrade: npm-license to 0.3.2 (fixes #5996) (#5998) (alberto)
* 377167d Upgrade: ignore to 3.1.2 (fixes #5979) (#5988) (alberto)
* 141b778 Fix: no-control-regex literal handling fixed. (fixes #5737) (#5943) (Efe Gürkan YALAMAN)
* 577757d Fix: Clarify color option (fixes #5928) (#5974) (Grant Snodgrass)
* e7e6581 Docs: Update CLA link (#5980) (Gustav Nikolaj)
* 0be26bc Build: Add nodejs 6 to travis (fixes #5971) (#5973) (Gyandeep Singh)
* e606523 New: Rule `no-unsafe-finally` (fixes #5808) (#5932) (Onur Temizkan)
* 42d1ecc Chore: Add metadata to existing rules - Batch 7 (refs #5417) (#5969) (Vitor Balocco)
* e2ad1ec Update: object-shorthand lints computed methods (fixes #5871) (#5963) (Chris Sauvé)
* d24516a Chore: Add metadata to existing rules - Batch 6 (refs #5417) (#5966) (Vitor Balocco)
* 1e7a3ef Fix: `id-match` false positive in property values (fixes #5885) (#5960) (Mike Sherov)
* 51ddd4b Update: Use process @abstract when processing @return (fixes #5941) (#5945) (Simon Schick)
* 52a4bea Update: Add autofix for `no-whitespace-before-property` (fixes #5927) (#5951) (alberto)
* 46e058d Docs: Correct typo in configuring.md (#5957) (Nick S. Plekhanov)
* 5f8abab Chore: Add metadata to existing rules - Batch 5 (refs #5417) (#5944) (Vitor Balocco)
* 0562f77 Chore: Add missing newlines to test cases (fixes #5947) (Rich Trott)
* fc78e78 Chore: Enable quote-props rule in eslint-config-eslint (refs #5188) (#5938) (Gyandeep Singh)
* 43f6d05 Docs: Update docs to refer to column (#5937) (Sashko Stubailo)
* 586478e Update: Add autofix for `comma-dangle` (fixes #3805) (#5925) (alberto)
* a4f9c5a Docs: Distinguish examples in rules under Stylistic Issues part 3 (Kenneth Williams)
* e7c0737 Chore: Enable no-console rule in eslint-config-eslint (refs #5188) (Kevin Partington)
* 0023fe6 Build: Add “chore” to commit tags (fixes #5880) (#5929) (Mike Sherov)
* 25d626a Upgrade: espree 3.1.4 (fixes #5923, fixes #5756) (Kai Cataldo)
* a01b412 New: Add `no-useless-computed-key` rule (fixes #5402) (Burak Yigit Kaya)
* 9afb9cb Chore: Remove workaround for espree and escope bugs (fixes #5852) (alberto)
* 3ffc582 Chore: Update copyright and license info (alberto)
* 249eb40 Docs: Clarify init sets up local installation (fixes #5874) (Kai Cataldo)
* 6cd8c86 Docs: Describe options in rules under Possible Errors part 1 (Mark Pedrotti)
* f842d18 Fix: `no-this-before-super` crash on unreachable paths (fixes #5894) (Toru Nagashima)
* a02960b Docs: Fix missing delimiter in README links (Kevin Partington)
* 3a9e72c Docs: Update developer guide with new standards (Nicholas C. Zakas)
* cb78585 Update: Add `allowUnboundThis` to `prefer-arrow-callback` (fixes #4668) (Burak Yigit Kaya)
* 02be29f Chore: Remove CLA check from bot (Nicholas C. Zakas)
* 220713e Chore: Add metadata to existing rules - Batch 4 (refs #5417) (Vitor Balocco)
* df53414 Chore: Include jQuery Foundation info (Nicholas C. Zakas)
* f1b2992 Fix: `no-useless-escape` false positive in JSXAttribute (fixes #5882) (Toru Nagashima)
* 74674ad Docs: Move `sort-imports` to 'ECMAScript 6' (Kenneth Williams)
* ae69ddb Docs: Fix severity type in example (Kenneth Williams)
* 19f6fff Update: Autofixing does multiple passes (refs #5329) (Nicholas C. Zakas)
* 1e4b0ca Docs: Reduce length of paragraphs in rules index (Mark Pedrotti)
* 8cfe1eb Docs: Fix a wrong option (Zach Orlovsky)
* 8f6739f Docs: Add alberto as reviewer (alberto)
* 2ae4938 Docs: Fix message for `inline-config` option (alberto)
* 089900b Docs: Fix a wrong rule name in an example (Toru Nagashima)
* c032b41 Docs: Fix emphasis (Toru Nagashima)
* ae606f0 Docs: Update JSCS info in README (alberto)
* a9c5323 Fix: Install ESLint on init if not installed (fixes #5833) (Kai Cataldo)
* ed38358 Docs: Removed incorrect example (James M. Greene)
* af3113c Docs: Fix config comments in indent docs (Brandon Mills)
* 2b39461 Update: `commentPattern` option for `default-case` rule (fixes #5803) (Artyom Lvov)

v2.8.0 - April 15, 2016

* a8821a5 Docs: Distinguish examples in rules under Stylistic Issues part 2 (Kenneth Williams)
* 76913b6 Update: Add metadata to existing rules - Batch 3 (refs #5417) (Vitor Balocco)
* 34ad8d2 Fix: Check that module.paths exists (fixes #5791) (Nicholas C. Zakas)
* 37239b1 Docs: Add new members of the team (Ilya Volodin)
* fb3c2eb Update: allow template literals (fixes #5234) (Jonathan Haines)
* 5a4a935 Update: Add metadata to existing rules - Batch 2 (refs #5417) (Vitor Balocco)
* ea2e625 Fix: newline-before-return handles return as first token (fixes #5816) (Kevin Partington)
* f8db9c9 Update: add nestedBinaryExpressions to no-extra-parens (fixes #3065) (Ilya Volodin)
* 0045d57 Update: `allowNamedFunctions` in `prefer-arrow-callback` (fixes #5675) (alberto)
* 19da72a Update: Add metadata to existing rules - Batch 1 (refs #5417) (Vitor Balocco)
* cc14e43 Fix: `no-fallthrough` empty case with comment (fixes #5799) (alberto)
* 13c8b14 Fix: LogicalExpression checks for short circuit (fixes #5693) (Vamshi krishna)
* 73b225e Fix: Document and fix metadata (refs #5417) (Ilya Volodin)
* 882d199 Docs: Improve options description in `no-redeclare` (alberto)
* 6a71ceb Docs: Improve options description in `no-params-reassign` (alberto)
* 24b6215 Update: Include 'typeof' in rule 'no-constant-condition' (fixes #5228) (Vamshi krishna)
* a959063 Docs: Remove link to deprecated ESLintTester project (refs #3110) (Trey Thomas)
* 6fd7d82 Update: Change order in `eslint --init` env options (fixes #5742) (alberto)
* c59d909 Fix: Extra paren check around object arrow bodies (fixes #5789) (Brandon Mills)
* 6f88546 Docs: Use double quotes for better Win compatibility (fixes #5796) (alberto)
* 02743d5 Fix: catch self-assignment operators in `no-magic-number` (fixes #4400) (alberto)
* c94e74e Docs: Make rule descriptions more consistent (Kenneth Williams)
* 6028252 Docs: Distinguish examples in rules under Stylistic Issues part 1 (Mark Pedrotti)
* ccd8ca9 Fix: Added property onlyDeclaration to id-match rule (fixes #3488) (Gajus Kuizinas)
* 6703c02 Update: no-useless-escape / exact locations of errors (fixes #5751) (Onur Temizkan)
* 3d84b91 Fix: ignore trailing whitespace in template literal (fixes #5786) (Kai Cataldo)
* b0e6bc4 Update: add allowEmptyCatch option to no-empty (fixes #5800) (Kai Cataldo)
* f1f1dd7 Docs: Add @pedrottimark as a committer (Brandon Mills)
* 228f201 Update: `commentPattern` option for `no-fallthrough` rule (fixes #5757) (Artyom Lvov)
* 41db670 Docs: Clarify disable inline comments (Kai Cataldo)
* 9c9a295 Docs: Add note about shell vs node glob parameters in cli (alberto)
* 5308ff9 Docs: Add code backticks to sentence in fixable rules (Mark Pedrotti)
* 965ec06 Docs: fix the examples for space-before-function-paren. (Craig Silverstein)
* 2b202fc Update: Add ignore option to space-before-function-parens (fixes #4127) (Craig Silverstein)
* 24c12ba Fix: improve `constructor-super` errors for literals (fixes #5449) (Toru Nagashima)

v2.7.0 - April 4, 2016

* 134cb1f Revert "Update: adds nestedBinaryExpressions for no-extra-parens rule (fixes #3065)" (Ilya Volodin)
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ESLint
Copyright (c) 2013 Nicholas C. Zakas. All rights reserved.
Copyright jQuery Foundation and other contributors, https://jquery.org/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 25 additions & 5 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@

# ESLint

[Website](http://eslint.org) | [Configuring](http://eslint.org/docs/user-guide/configuring) | [Rules](http://eslint.org/docs/rules/) | [Contributing](http://eslint.org/docs/developer-guide/contributing) | [Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) | [Twitter](https://twitter.com/geteslint) | [Mailing List](https://groups.google.com/group/eslint) | [Chat Room](https://gitter.im/eslint/eslint)
[Website](http://eslint.org) |
[Configuring](http://eslint.org/docs/user-guide/configuring) |
[Rules](http://eslint.org/docs/rules/) |
[Contributing](http://eslint.org/docs/developer-guide/contributing) |
[Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) |
[Code of Conduct](https://jquery.org/conduct/) |
[Twitter](https://twitter.com/geteslint) |
[Mailing List](https://groups.google.com/group/eslint) |
[Chat Room](https://gitter.im/eslint/eslint)

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions:

Expand All @@ -32,6 +40,8 @@ After that, you can run ESLint on any JavaScript file:

eslint test.js test2.js

**Note:** `eslint --init` is intended for setting up and configuring ESLint on a per-project basis and will perform a local installation of ESLint and its plugins in the directory in which it is run. If you prefer using a global installation of ESLint, any plugins used in your configuration must also be installed globally.

## Configuration

After running `eslint --init`, you'll have a `.eslintrc` file in your directory. In it, you'll see some rules configured like this:
Expand Down Expand Up @@ -67,13 +77,19 @@ These folks keep the project moving and are resources for help:
* Brandon Mills ([@btmills](https://github.com/btmills)) - reviewer
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps)) - reviewer
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea)) - reviewer
* Alberto Rodríguez ([@alberto](https://github.com/alberto)) - reviewer
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma)) - committer
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx)) - committer
* Ian VanSchooten ([@ianvs](https://github.com/ianvs)) - committer
* Burak Yiğit Kaya ([@byk](https://github.com/byk)) - committer
* Alberto Rodríguez ([@alberto](https://github.com/alberto)) - committer
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo)) - committer
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra)) - committer
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark)) - committer
* Oleg Gaidarenko ([@markelog](https://github.com/markelog)) - committer
* Mike Sherov [@mikesherov](https://github.com/mikesherov)) - committer
* Henry Zhu ([@hzoo](https://github.com/hzoo)) - committer
* Marat Dulin ([@mdevils](https://github.com/mdevils)) - committer
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox)) - committer

## Releases

Expand All @@ -98,15 +114,19 @@ I do like JSHint. And I like Anton and Rick. Neither of those were deciding fact

That's not really a question, but I got it. I'm not trying to convince you that ESLint is better than JSHint. The only thing I know is that ESLint is better than JSHint for what I'm doing. In the off chance you're doing something similar, it might be better for you. Otherwise, keep using JSHint, I'm certainly not going to tell you to stop using it.

### How does ESLint performance compare to JSHint and JSCS?
### How does ESLint performance compare to JSHint?

ESLint is slower than JSHint, usually 2-3x slower on a single file. This is because ESLint uses Espree to construct an AST before it can evaluate your code whereas JSHint evaluates your code as it's being parsed. The speed is also based on the number of rules you enable; the more rules you enable, the slower the process.

Despite being slower, we believe that ESLint is fast enough to replace JSHint without causing significant pain.

ESLint is faster than JSCS, as ESLint uses a single-pass traversal for analysis whereas JSCS using a querying model.
### I heard ESLint is going to replace JSCS?

Yes. Since we are solving the same problems, ESLint and JSCS teams have decided to join forces and work together in the development of ESLint instead of competing with each other. You can read more about this in both [ESLint](http://eslint.org/blog/2016/04/welcoming-jscs-to-eslint) and [JSCS](https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2#.u76sx334n) announcements.

### So, should I stop using JSCS and start using ESLint?

If you are using both JSHint and JSCS on your files, then using just ESLint will be faster.
Not yet. We are still working to smooth the transition. You can see our progress [here](https://github.com/eslint/eslint/milestones/JSCS%20Compatibility). We’ll announce when all of the changes necessary to support JSCS users in ESLint are complete and will start encouraging JSCS users to switch to ESLint at that time. Meanwhile, we recommend you to upgrade to JSCS 3.0 and provide feedback to the team.

### Is ESLint just linting or does it also check style?

Expand Down
2 changes: 0 additions & 2 deletions tools/eslint/bin/eslint.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
/**
* @fileoverview Main CLI that is run via the eslint command.
* @author Nicholas C. Zakas
* @copyright 2013 Nicholas C. Zakas. All rights reserved.
* See LICENSE file in root directory for full license.
*/

"use strict";
Expand Down
2 changes: 0 additions & 2 deletions tools/eslint/conf/cli-options.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview Default CLIEngineOptions.
* @author Ian VanSchooten
* @copyright 2016 Ian VanSchooten. All rights reserved.
* See LICENSE in root directory for full license.
*/

"use strict";
Expand Down
1 change: 0 additions & 1 deletion tools/eslint/conf/environments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @fileoverview Defines environment settings and globals.
* @author Elan Shanker
* @copyright 2014 Elan Shanker. All rights reserved.
*/
"use strict";

Expand Down
2 changes: 2 additions & 0 deletions tools/eslint/conf/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@
"no-unmodified-loop-condition": "off",
"no-unneeded-ternary": "off",
"no-unreachable": "error",
"no-unsafe-finally": "off",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-unused-vars": "error",
"no-use-before-define": "off",
"no-useless-call": "off",
"no-useless-computed-key": "off",
"no-useless-concat": "off",
"no-useless-constructor": "off",
"no-useless-escape": "off",
Expand Down
2 changes: 0 additions & 2 deletions tools/eslint/lib/ast-utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview Common utils for AST.
* @author Gyandeep Singh
* @copyright 2015 Gyandeep Singh. All rights reserved.
* See LICENSE file in root directory for full license.
*/

"use strict";
Expand Down
91 changes: 82 additions & 9 deletions tools/eslint/lib/cli-engine.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview Main CLI object.
* @author Nicholas C. Zakas
* @copyright 2014 Nicholas C. Zakas. All rights reserved.
* See LICENSE in root directory for full license.
*/

"use strict";
Expand Down Expand Up @@ -115,6 +113,79 @@ function calculateStatsPerRun(results) {
});
}

/**
* Performs multiple autofix passes over the text until as many fixes as possible
* have been applied.
* @param {string} text The source text to apply fixes to.
* @param {Object} config The ESLint config object to use.
* @param {Object} options The ESLint options object to use.
* @param {string} options.filename The filename from which the text was read.
* @param {boolean} options.allowInlineConfig Flag indicating if inline comments
* should be allowed.
* @returns {Object} The result of the fix operation as returned from the
* SourceCodeFixer.
* @private
*/
function multipassFix(text, config, options) {

var messages = [],
fixedResult,
fixed = false,
passNumber = 0,
lastMessageCount,
MAX_PASSES = 10;

/**
* This loop continues until one of the following is true:
*
* 1. No more fixes have been applied.
* 2. There are no more linting errors reported.
* 3. The number of linting errors is no different between two passes.
* 4. Ten passes have been made.
*
* That means anytime a fix is successfully applied, there will be another pass.
* Essentially, guaranteeing a minimum of two passes.
*/
do {
passNumber++;
lastMessageCount = messages.length;

debug("Linting code for " + options.filename + " (pass " + passNumber + ")");
messages = eslint.verify(text, config, options);

debug("Generating fixed text for " + options.filename + " (pass " + passNumber + ")");
fixedResult = SourceCodeFixer.applyFixes(eslint.getSourceCode(), messages);

// keep track if any fixes were ever applied - important for return value
fixed = fixed || fixedResult.fixed;

// update to use the fixed output instead of the original text
text = fixedResult.output;

} while (
fixedResult.fixed && fixedResult.messages.length > 0 &&
fixedResult.messages.length !== lastMessageCount &&
passNumber < MAX_PASSES
);


/*
* If the last result had fixes, we need to lint again to me sure we have
* the most up-to-date information.
*/
if (fixedResult.fixed) {
fixedResult.messages = eslint.verify(text, config, options);
}


// ensure the last result properly reflects if fixes were done
fixedResult.fixed = fixed;
fixedResult.output = text;

return fixedResult;

}

/**
* Processes an source code using ESLint.
* @param {string} text The source code to check.
Expand Down Expand Up @@ -179,15 +250,17 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) {

} else {

messages = eslint.verify(text, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
});

if (fix) {
debug("Generating fixed text for " + filename);
fixedResult = SourceCodeFixer.applyFixes(eslint.getSourceCode(), messages);
fixedResult = multipassFix(text, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
});
messages = fixedResult.messages;
} else {
messages = eslint.verify(text, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
});
}
}

Expand Down
2 changes: 0 additions & 2 deletions tools/eslint/lib/code-path-analysis/code-path-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview A class of the code path analyzer.
* @author Toru Nagashima
* @copyright 2015 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/

"use strict";
Expand Down
17 changes: 11 additions & 6 deletions tools/eslint/lib/code-path-analysis/code-path-segment.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview A class of the code path segment.
* @author Toru Nagashima
* @copyright 2015 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/

"use strict";
Expand All @@ -11,8 +9,7 @@
// Requirements
//------------------------------------------------------------------------------

var assert = require("assert"),
debug = require("./debug-helpers");
var debug = require("./debug-helpers");

//------------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -178,7 +175,13 @@ CodePathSegment.newNext = function(id, allPrevSegments) {
* @returns {CodePathSegment} The created segment.
*/
CodePathSegment.newUnreachable = function(id, allPrevSegments) {
return new CodePathSegment(id, flattenUnusedSegments(allPrevSegments), false);
var segment = new CodePathSegment(id, flattenUnusedSegments(allPrevSegments), false);

// In `if (a) return a; foo();` case, the unreachable segment preceded by
// the return statement is not used but must not be remove.
CodePathSegment.markUsed(segment);

return segment;
};

/**
Expand All @@ -203,7 +206,9 @@ CodePathSegment.newDisconnected = function(id, allPrevSegments) {
* @returns {void}
*/
CodePathSegment.markUsed = function(segment) {
assert(!segment.internal.used, segment.id + " is marked twice.");
if (segment.internal.used) {
return;
}
segment.internal.used = true;

var i;
Expand Down
2 changes: 0 additions & 2 deletions tools/eslint/lib/code-path-analysis/code-path-state.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @fileoverview A class to manage state of generating a code path.
* @author Toru Nagashima
* @copyright 2015 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/

"use strict";
Expand Down
Loading

0 comments on commit 7a8dd69

Please sign in to comment.