Skip to content

Commit

Permalink
tools: update to ESLint 3.2.2
Browse files Browse the repository at this point in the history
PR-URL: #7999
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
  • Loading branch information
Trott committed Aug 10, 2016
1 parent 49e473a commit e313c02
Show file tree
Hide file tree
Showing 701 changed files with 18,378 additions and 10,561 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ cpplint:
@$(PYTHON) tools/cpplint.py $(CPPLINT_FILES)
@$(PYTHON) tools/check-imports.py

ifneq ("","$(wildcard tools/eslint/bin/eslint.js)")
ifneq ("","$(wildcard tools/eslint/lib/eslint.js)")
lint: jslint cpplint
CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
lint-ci: jslint-ci cpplint
Expand Down
10 changes: 6 additions & 4 deletions tools/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ These folks keep the project moving and are resources for help.
* Henry Zhu ([@hzoo](https://github.com/hzoo))
* Marat Dulin ([@mdevils](https://github.com/mdevils))
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))

### Issues Team

* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))

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

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.

## Frequently Asked Questions

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

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

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

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.


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

Expand Down
80 changes: 0 additions & 80 deletions tools/eslint/bin/eslint.js

This file was deleted.

35 changes: 35 additions & 0 deletions tools/eslint/conf/category-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"categories": [
{ "name": "Possible Errors", "description": "These rules relate to possible syntax or logic errors in JavaScript code:" },
{ "name": "Best Practices", "description": "These rules relate to better ways of doing things to help you avoid problems:" },
{ "name": "Strict Mode", "description": "These rules relate to strict mode directives:" },
{ "name": "Variables", "description": "These rules relate to variable declarations:" },
{ "name": "Node.js and CommonJS", "description": "These rules relate to code running in Node.js, or in browsers with CommonJS:" },
{ "name": "Stylistic Issues", "description": "These rules relate to style guidelines, and are therefore quite subjective:" },
{ "name": "ECMAScript 6", "description": "These rules relate to ES6, also known as ES2015:" }
],
"removed": {
"name": "Removed",
"description": "These rules from older versions of ESLint have been replaced by newer rules:",
"rules": [
{ "removed": "generator-star", "replacedBy": ["generator-star-spacing"] },
{ "removed": "global-strict", "replacedBy": ["strict"] },
{ "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] },
{ "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] },
{ "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] },
{ "removed": "no-empty-label", "replacedBy": ["no-labels"] },
{ "removed": "no-extra-strict", "replacedBy": ["strict"] },
{ "removed": "no-reserved-keys", "replacedBy": ["quote-props"] },
{ "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] },
{ "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] },
{ "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] },
{ "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] },
{ "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] },
{ "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] },
{ "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }
]
}
}
2 changes: 1 addition & 1 deletion tools/eslint/conf/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Requirements
//------------------------------------------------------------------------------

var globals = require("globals");
let globals = require("globals");

//------------------------------------------------------------------------------
// Public Interface
Expand Down
10 changes: 6 additions & 4 deletions tools/eslint/conf/eslint-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
// Requirements
//------------------------------------------------------------------------------

var fs = require("fs"),
let fs = require("fs"),
path = require("path");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

var ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
var enabledRules = ruleFiles.reduce(function(result, filename) {
result[path.basename(filename, ".js")] = "error";
let ruleFiles = fs.readdirSync(path.resolve(__dirname, "../lib/rules"));
let enabledRules = ruleFiles.reduce(function(result, filename) {
if (path.extname(filename) === ".js") {
result[path.basename(filename, ".js")] = "error";
}
return result;
}, {});

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 @@ -99,6 +99,7 @@
"no-spaced-func": "off",
"no-sparse-arrays": "error",
"no-sync": "off",
"no-tabs": "off",
"no-ternary": "off",
"no-trailing-spaces": "off",
"no-this-before-super": "error",
Expand Down Expand Up @@ -174,6 +175,7 @@
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-cap": "off",
"new-parens": "off",
"newline-after-var": "off",
Expand Down
66 changes: 50 additions & 16 deletions tools/eslint/lib/ast-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
// Requirements
//------------------------------------------------------------------------------

var esutils = require("esutils");
let esutils = require("esutils");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

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

/**
* Checks reference if is non initializer and writable.
Expand All @@ -31,7 +32,7 @@ var thisTagPattern = /^[\s\*]*@this/m;
* @private
*/
function isModifyingReference(reference, index, references) {
var identifier = reference.identifier,
let identifier = reference.identifier,
modifyingDifferentIdentifier;

/*
Expand Down Expand Up @@ -159,7 +160,7 @@ function isMethodWhichHasThisArg(node) {
* @returns {boolean} Whether or not the node has a `@this` tag in its comments.
*/
function hasJSDocThisTag(node, sourceCode) {
var jsdocComment = sourceCode.getJSDocComment(node);
let jsdocComment = sourceCode.getJSDocComment(node);

if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
return true;
Expand All @@ -182,7 +183,7 @@ function hasJSDocThisTag(node, sourceCode) {
* @private
*/
function isParenthesised(sourceCode, node) {
var previousToken = sourceCode.getTokenBefore(node),
let previousToken = sourceCode.getTokenBefore(node),
nextToken = sourceCode.getTokenAfter(node);

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

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

while (scope) {
var variable = scope.set.get(name);
let variable = scope.set.get(name);

if (variable) {
return variable;
Expand Down Expand Up @@ -359,7 +360,7 @@ module.exports = {
}

while (node) {
var parent = node.parent;
let parent = node.parent;

switch (parent.type) {

Expand All @@ -378,14 +379,15 @@ module.exports = {
// // setup...
// return function foo() { ... };
// })();
case "ReturnStatement":
var func = getUpperFunction(parent);
case "ReturnStatement": {
const func = getUpperFunction(parent);

if (func === null || !isCallee(func)) {
return true;
}
node = func.parent;
break;
}

// e.g.
// var obj = { foo() { ... } };
Expand Down Expand Up @@ -551,5 +553,37 @@ module.exports = {
// no default
}
return 18;
},

/**
* Checks whether a given node is a loop node or not.
* The following types are loop nodes:
*
* - DoWhileStatement
* - ForInStatement
* - ForOfStatement
* - ForStatement
* - WhileStatement
*
* @param {ASTNode|null} node - A node to check.
* @returns {boolean} `true` if the node is a loop node.
*/
isLoop: function(node) {
return Boolean(node && anyLoopPattern.test(node.type));
},

/**
* Checks whether a given node is a function node or not.
* The following types are function nodes:
*
* - ArrowFunctionExpression
* - FunctionDeclaration
* - FunctionExpression
*
* @param {ASTNode|null} node - A node to check.
* @returns {boolean} `true` if the node is a function node.
*/
isFunction: function(node) {
return Boolean(node && anyFunctionPattern.test(node.type));
}
};
Loading

0 comments on commit e313c02

Please sign in to comment.