Skip to content

Commit e313c02

Browse files
committed
tools: update to ESLint 3.2.2
PR-URL: #7999 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Johan Bergström <[email protected]>
1 parent 49e473a commit e313c02

File tree

701 files changed

+18378
-10561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

701 files changed

+18378
-10561
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ cpplint:
697697
@$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
698698
@$(PYTHON) tools/check-imports.py
699699

700-
ifneq ("","$(wildcard tools/eslint/bin/eslint.js)")
700+
ifneq ("","$(wildcard tools/eslint/lib/eslint.js)")
701701
lint: jslint cpplint
702702
CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
703703
lint-ci: jslint-ci cpplint

tools/eslint/README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ These folks keep the project moving and are resources for help.
126126
* Henry Zhu ([@hzoo](https://github.com/hzoo))
127127
* Marat Dulin ([@mdevils](https://github.com/mdevils))
128128
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))
129-
130-
### Issues Team
131-
132129
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
133130
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
134131

@@ -169,6 +166,8 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat
169166
* An existing formatter is removed.
170167
* Part of the public API is removed or changed in an incompatible way.
171168

169+
According to our policy, any minor update may report more errors than the previous release (ex: from a bug fix). As such, we recommend using the tilde (`~`) in `package.json` e.g. `"eslint": "~3.1.0"` to guarantee the results of your builds.
170+
172171
## Frequently Asked Questions
173172

174173
### How is ESLint different from JSHint?
@@ -187,7 +186,10 @@ Yes. Since we are solving the same problems, ESLint and JSCS teams have decided
187186

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

190-
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.
189+
Maybe, depending on how much you need it. [JSCS has reached end of life](http://eslint.org/blog/2016/07/jscs-end-of-life), but if it is working for you then there is no reason to move 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.
190+
191+
If you are having issues with JSCS, you can try to move to ESLint. We are focusing our time and energy on JSCS compatibility issues.
192+
191193

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

tools/eslint/bin/eslint.js

-80
This file was deleted.

tools/eslint/conf/category-list.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"categories": [
3+
{ "name": "Possible Errors", "description": "These rules relate to possible syntax or logic errors in JavaScript code:" },
4+
{ "name": "Best Practices", "description": "These rules relate to better ways of doing things to help you avoid problems:" },
5+
{ "name": "Strict Mode", "description": "These rules relate to strict mode directives:" },
6+
{ "name": "Variables", "description": "These rules relate to variable declarations:" },
7+
{ "name": "Node.js and CommonJS", "description": "These rules relate to code running in Node.js, or in browsers with CommonJS:" },
8+
{ "name": "Stylistic Issues", "description": "These rules relate to style guidelines, and are therefore quite subjective:" },
9+
{ "name": "ECMAScript 6", "description": "These rules relate to ES6, also known as ES2015:" }
10+
],
11+
"removed": {
12+
"name": "Removed",
13+
"description": "These rules from older versions of ESLint have been replaced by newer rules:",
14+
"rules": [
15+
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
16+
{ "removed": "global-strict", "replacedBy": ["strict"] },
17+
{ "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] },
18+
{ "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] },
19+
{ "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] },
20+
{ "removed": "no-empty-label", "replacedBy": ["no-labels"] },
21+
{ "removed": "no-extra-strict", "replacedBy": ["strict"] },
22+
{ "removed": "no-reserved-keys", "replacedBy": ["quote-props"] },
23+
{ "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] },
24+
{ "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] },
25+
{ "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] },
26+
{ "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] },
27+
{ "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] },
28+
{ "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] },
29+
{ "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] },
30+
{ "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] },
31+
{ "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] },
32+
{ "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }
33+
]
34+
}
35+
}

tools/eslint/conf/environments.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Requirements
99
//------------------------------------------------------------------------------
1010

11-
var globals = require("globals");
11+
let globals = require("globals");
1212

1313
//------------------------------------------------------------------------------
1414
// Public Interface

tools/eslint/conf/eslint-all.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
// Requirements
1010
//------------------------------------------------------------------------------
1111

12-
var fs = require("fs"),
12+
let fs = require("fs"),
1313
path = require("path");
1414

1515
//------------------------------------------------------------------------------
1616
// Helpers
1717
//------------------------------------------------------------------------------
1818

19-
var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
20-
var enabledRules = ruleFiles.reduce(function(result, filename) {
21-
result[path.basename(filename, ".js")] = "error";
19+
let ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
20+
let enabledRules = ruleFiles.reduce(function(result, filename) {
21+
if (path.extname(filename) === ".js") {
22+
result[path.basename(filename, ".js")] = "error";
23+
}
2224
return result;
2325
}, {});
2426

tools/eslint/conf/eslint.json

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"no-spaced-func": "off",
100100
"no-sparse-arrays": "error",
101101
"no-sync": "off",
102+
"no-tabs": "off",
102103
"no-ternary": "off",
103104
"no-trailing-spaces": "off",
104105
"no-this-before-super": "error",
@@ -174,6 +175,7 @@
174175
"max-params": "off",
175176
"max-statements": "off",
176177
"max-statements-per-line": "off",
178+
"multiline-ternary": "off",
177179
"new-cap": "off",
178180
"new-parens": "off",
179181
"newline-after-var": "off",

tools/eslint/lib/ast-utils.js

+50-16
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
// Requirements
1010
//------------------------------------------------------------------------------
1111

12-
var esutils = require("esutils");
12+
let esutils = require("esutils");
1313

1414
//------------------------------------------------------------------------------
1515
// Helpers
1616
//------------------------------------------------------------------------------
1717

18-
var anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/;
19-
var arrayOrTypedArrayPattern = /Array$/;
20-
var arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/;
21-
var bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/;
22-
var breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/;
23-
var thisTagPattern = /^[\s\*]*@this/m;
18+
let anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/;
19+
let anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/;
20+
let arrayOrTypedArrayPattern = /Array$/;
21+
let arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/;
22+
let bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/;
23+
let breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/;
24+
let thisTagPattern = /^[\s\*]*@this/m;
2425

2526
/**
2627
* Checks reference if is non initializer and writable.
@@ -31,7 +32,7 @@ var thisTagPattern = /^[\s\*]*@this/m;
3132
* @private
3233
*/
3334
function isModifyingReference(reference, index, references) {
34-
var identifier = reference.identifier,
35+
let identifier = reference.identifier,
3536
modifyingDifferentIdentifier;
3637

3738
/*
@@ -159,7 +160,7 @@ function isMethodWhichHasThisArg(node) {
159160
* @returns {boolean} Whether or not the node has a `@this` tag in its comments.
160161
*/
161162
function hasJSDocThisTag(node, sourceCode) {
162-
var jsdocComment = sourceCode.getJSDocComment(node);
163+
let jsdocComment = sourceCode.getJSDocComment(node);
163164

164165
if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
165166
return true;
@@ -182,7 +183,7 @@ function hasJSDocThisTag(node, sourceCode) {
182183
* @private
183184
*/
184185
function isParenthesised(sourceCode, node) {
185-
var previousToken = sourceCode.getTokenBefore(node),
186+
let previousToken = sourceCode.getTokenBefore(node),
186187
nextToken = sourceCode.getTokenAfter(node);
187188

188189
return Boolean(previousToken && nextToken) &&
@@ -284,7 +285,7 @@ module.exports = {
284285
* @returns {boolean} `true` if the node is an ESLint directive comment
285286
*/
286287
isDirectiveComment: function(node) {
287-
var comment = node.value.trim();
288+
let comment = node.value.trim();
288289

289290
return (
290291
node.type === "Line" && comment.indexOf("eslint-") === 0 ||
@@ -317,10 +318,10 @@ module.exports = {
317318
* @returns {escope.Variable|null} A found variable or `null`.
318319
*/
319320
getVariableByName: function(initScope, name) {
320-
var scope = initScope;
321+
let scope = initScope;
321322

322323
while (scope) {
323-
var variable = scope.set.get(name);
324+
let variable = scope.set.get(name);
324325

325326
if (variable) {
326327
return variable;
@@ -359,7 +360,7 @@ module.exports = {
359360
}
360361

361362
while (node) {
362-
var parent = node.parent;
363+
let parent = node.parent;
363364

364365
switch (parent.type) {
365366

@@ -378,14 +379,15 @@ module.exports = {
378379
// // setup...
379380
// return function foo() { ... };
380381
// })();
381-
case "ReturnStatement":
382-
var func = getUpperFunction(parent);
382+
case "ReturnStatement": {
383+
const func = getUpperFunction(parent);
383384

384385
if (func === null || !isCallee(func)) {
385386
return true;
386387
}
387388
node = func.parent;
388389
break;
390+
}
389391

390392
// e.g.
391393
// var obj = { foo() { ... } };
@@ -551,5 +553,37 @@ module.exports = {
551553
// no default
552554
}
553555
return 18;
556+
},
557+
558+
/**
559+
* Checks whether a given node is a loop node or not.
560+
* The following types are loop nodes:
561+
*
562+
* - DoWhileStatement
563+
* - ForInStatement
564+
* - ForOfStatement
565+
* - ForStatement
566+
* - WhileStatement
567+
*
568+
* @param {ASTNode|null} node - A node to check.
569+
* @returns {boolean} `true` if the node is a loop node.
570+
*/
571+
isLoop: function(node) {
572+
return Boolean(node && anyLoopPattern.test(node.type));
573+
},
574+
575+
/**
576+
* Checks whether a given node is a function node or not.
577+
* The following types are function nodes:
578+
*
579+
* - ArrowFunctionExpression
580+
* - FunctionDeclaration
581+
* - FunctionExpression
582+
*
583+
* @param {ASTNode|null} node - A node to check.
584+
* @returns {boolean} `true` if the node is a function node.
585+
*/
586+
isFunction: function(node) {
587+
return Boolean(node && anyFunctionPattern.test(node.type));
554588
}
555589
};

0 commit comments

Comments
 (0)