Permalink
Browse files

tools: update ESLint to 3.5.0

PR-URL: #8478
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
Trott authored and Fishrock123 committed Sep 10, 2016
1 parent ef5cb12 commit 36235ac32396a852a588a0bae1323ab3cc77a0c4
Showing with 5,347 additions and 403 deletions.
  1. +3,412 −0 tools/eslint/CHANGELOG.md
  2. +2 −1 tools/eslint/README.md
  3. +4 −0 tools/eslint/conf/eslint.json
  4. +35 −0 tools/eslint/lib/ast-utils.js
  5. +10 −0 tools/eslint/lib/config/plugins.js
  6. +7 −4 tools/eslint/lib/eslint.js
  7. +16 −4 tools/eslint/lib/rules/array-bracket-spacing.js
  8. +2 −2 tools/eslint/lib/rules/arrow-parens.js
  9. +9 −7 tools/eslint/lib/rules/arrow-spacing.js
  10. +8 −2 tools/eslint/lib/rules/block-spacing.js
  11. +7 −1 tools/eslint/lib/rules/class-methods-use-this.js
  12. +5 −2 tools/eslint/lib/rules/comma-spacing.js
  13. +67 −10 tools/eslint/lib/rules/comma-style.js
  14. +16 −4 tools/eslint/lib/rules/computed-property-spacing.js
  15. +9 −2 tools/eslint/lib/rules/consistent-return.js
  16. +2 −2 tools/eslint/lib/rules/curly.js
  17. +52 −5 tools/eslint/lib/rules/dot-notation.js
  18. +6 −1 tools/eslint/lib/rules/generator-star-spacing.js
  19. +87 −3 tools/eslint/lib/rules/indent.js
  20. +14 −2 tools/eslint/lib/rules/init-declarations.js
  21. +4 −1 tools/eslint/lib/rules/jsx-quotes.js
  22. +4 −1 tools/eslint/lib/rules/key-spacing.js
  23. +1 −1 tools/eslint/lib/rules/keyword-spacing.js
  24. +101 −0 tools/eslint/lib/rules/line-comment-position.js
  25. +165 −0 tools/eslint/lib/rules/lines-around-directive.js
  26. +89 −3 tools/eslint/lib/rules/max-len.js
  27. +37 −4 tools/eslint/lib/rules/max-statements-per-line.js
  28. +1 −1 tools/eslint/lib/rules/new-cap.js
  29. +53 −9 tools/eslint/lib/rules/new-parens.js
  30. +63 −8 tools/eslint/lib/rules/newline-before-return.js
  31. +8 −5 tools/eslint/lib/rules/newline-per-chained-call.js
  32. +81 −16 tools/eslint/lib/rules/no-console.js
  33. +4 −2 tools/eslint/lib/rules/no-control-regex.js
  34. +1 −1 tools/eslint/lib/rules/no-dupe-class-members.js
  35. +5 −2 tools/eslint/lib/rules/no-duplicate-imports.js
  36. +4 −1 tools/eslint/lib/rules/no-empty-function.js
  37. +14 −2 tools/eslint/lib/rules/no-extend-native.js
  38. +13 −3 tools/eslint/lib/rules/no-floating-decimal.js
  39. +69 −42 tools/eslint/lib/rules/no-implicit-coercion.js
  40. +13 −4 tools/eslint/lib/rules/no-invalid-regexp.js
  41. +9 −4 tools/eslint/lib/rules/no-magic-numbers.js
  42. +9 −4 tools/eslint/lib/rules/no-mixed-operators.js
  43. +14 −4 tools/eslint/lib/rules/no-multiple-empty-lines.js
  44. +7 −1 tools/eslint/lib/rules/no-plusplus.js
  45. +12 −1 tools/eslint/lib/rules/no-regex-spaces.js
  46. +88 −0 tools/eslint/lib/rules/no-restricted-properties.js
  47. +7 −1 tools/eslint/lib/rules/no-shadow-restricted-names.js
  48. +7 −1 tools/eslint/lib/rules/no-sync.js
  49. +2 −2 tools/eslint/lib/rules/no-trailing-spaces.js
  50. +21 −3 tools/eslint/lib/rules/no-underscore-dangle.js
  51. +4 −1 tools/eslint/lib/rules/no-unsafe-finally.js
  52. +1 −1 tools/eslint/lib/rules/no-unused-vars.js
  53. +4 −1 tools/eslint/lib/rules/no-useless-escape.js
  54. +7 −1 tools/eslint/lib/rules/no-warning-comments.js
  55. +16 −4 tools/eslint/lib/rules/object-curly-spacing.js
  56. +8 −5 tools/eslint/lib/rules/object-shorthand.js
  57. +42 −6 tools/eslint/lib/rules/one-var.js
  58. +44 −16 tools/eslint/lib/rules/operator-linebreak.js
  59. +42 −2 tools/eslint/lib/rules/prefer-arrow-callback.js
  60. +62 −0 tools/eslint/lib/rules/prefer-numeric-literals.js
  61. +1 −1 tools/eslint/lib/rules/quote-props.js
  62. +9 −3 tools/eslint/lib/rules/quotes.js
  63. +24 −6 tools/eslint/lib/rules/space-unary-ops.js
  64. +13 −11 tools/eslint/lib/rules/spaced-comment.js
  65. +8 −2 tools/eslint/lib/rules/template-curly-spacing.js
  66. +14 −2 tools/eslint/lib/rules/valid-jsdoc.js
  67. +8 −2 tools/eslint/lib/rules/wrap-regex.js
  68. +5 −1 tools/eslint/lib/rules/yield-star-spacing.js
  69. +15 −3 tools/eslint/lib/rules/yoda.js
  70. +19 −11 tools/eslint/lib/util/glob-util.js
  71. +3 −0 tools/eslint/messages/whitespace-found.txt
  72. +67 −30 tools/eslint/node_modules/bluebird/js/browser/bluebird.core.js
  73. +3 −3 tools/eslint/node_modules/bluebird/js/browser/bluebird.core.min.js
  74. +94 −42 tools/eslint/node_modules/bluebird/js/browser/bluebird.js
  75. +4 −4 tools/eslint/node_modules/bluebird/js/browser/bluebird.min.js
  76. +11 −11 tools/eslint/node_modules/bluebird/package.json
  77. +13 −6 tools/eslint/node_modules/concat-stream/index.js
  78. +19 −11 tools/eslint/node_modules/concat-stream/package.json
  79. +2 −0 tools/eslint/node_modules/concat-stream/readme.md
  80. +1 −1 tools/eslint/node_modules/deep-is/package.json
  81. +1 −1 tools/eslint/node_modules/es6-weak-map/package.json
  82. +7 −1 tools/eslint/node_modules/inherits/inherits.js
  83. +20 −8 tools/eslint/node_modules/inherits/package.json
  84. +1 −1 tools/eslint/node_modules/is-path-cwd/package.json
  85. +1 −1 tools/eslint/node_modules/is-path-in-cwd/package.json
  86. +1 −1 tools/eslint/node_modules/is-property/package.json
  87. +1 −1 tools/eslint/node_modules/number-is-nan/package.json
  88. +28 −0 tools/eslint/node_modules/once/README.md
  89. +21 −0 tools/eslint/node_modules/once/once.js
  90. +14 −10 tools/eslint/node_modules/once/package.json
  91. +1 −1 tools/eslint/node_modules/path-is-absolute/package.json
  92. +1 −1 tools/eslint/node_modules/prelude-ls/package.json
  93. +1 −1 tools/eslint/node_modules/typedarray/package.json
  94. +1 −1 tools/eslint/node_modules/util-deprecate/package.json
  95. +9 −9 tools/eslint/package.json
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -111,14 +111,14 @@ These folks keep the project moving and are resources for help.
* Gyandeep Singh ([@gyandeeps](https://github.com/gyandeeps))
* Toru Nagashima ([@mysticatea](https://github.com/mysticatea))
* Alberto Rodríguez ([@alberto](https://github.com/alberto))
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
### Development Team
* Mathias Schreck ([@lo1tuma](https://github.com/lo1tuma))
* Jamund Ferguson ([@xjamundx](https://github.com/xjamundx))
* Ian VanSchooten ([@ianvs](https://github.com/ianvs))
* Burak Yiğit Kaya ([@byk](https://github.com/byk))
* Kai Cataldo ([@kaicataldo](https://github.com/kaicataldo))
* Michael Ficarra ([@michaelficarra](https://github.com/michaelficarra))
* Mark Pedrotti ([@pedrottimark](https://github.com/pedrottimark))
* Oleg Gaidarenko ([@markelog](https://github.com/markelog))
@@ -128,6 +128,7 @@ These folks keep the project moving and are resources for help.
* Alexej Yaroshevich ([@zxqfox](https://github.com/zxqfox))
* Kevin Partington ([@platinumazure](https://github.com/platinumazure))
* Vitor Balocco ([@vitorbal](https://github.com/vitorbal))
* James Henry ([@JamesHenry](https://github.com/JamesHenry))
## Releases
@@ -88,6 +88,7 @@
"no-restricted-globals": "off",
"no-restricted-imports": "off",
"no-restricted-modules": "off",
"no-restricted-properties": "off",
"no-restricted-syntax": "off",
"no-return-assign": "off",
"no-script-url": "off",
@@ -171,7 +172,9 @@
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": "off",
"line-comment-position": "off",
"lines-around-comment": "off",
"lines-around-directive": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
@@ -196,6 +199,7 @@
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "off",
"prefer-numeric-literals": "off",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
@@ -680,5 +680,40 @@ module.exports = {
}
return null;
},
/**
* Get directives from directive prologue of a Program or Function node.
* @param {ASTNode} node - The node to check.
* @returns {ASTNode[]} The directives found in the directive prologue.
*/
getDirectivePrologue(node) {
const directives = [];
// Directive prologues only occur at the top of files or functions.
if (
node.type === "Program" ||
node.type === "FunctionDeclaration" ||
node.type === "FunctionExpression" ||
// Do not check arrow functions with implicit return.
// `() => "use strict";` returns the string `"use strict"`.
(node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement")
) {
const statements = node.type === "Program" ? node.body : node.body.body;
for (const statement of statements) {
if (
statement.type === "ExpressionStatement" &&
statement.expression.type === "Literal"
) {
directives.push(statement);
} else {
break;
}
}
}
return directives;
}
};
@@ -114,6 +114,16 @@ module.exports = {
longName = pluginNamespace + PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix;
let plugin = null;
if (pluginName.match(/\s+/)) {
const whitespaceError = new Error("Whitespace found in plugin name '" + pluginName + "'");
whitespaceError.messageTemplate = "whitespace-found";
whitespaceError.messageData = {
pluginName: longName
};
throw whitespaceError;
}
if (!plugins[shortName]) {
try {
plugin = require(longName);
View
@@ -598,10 +598,11 @@ module.exports = (function() {
* as possible
* @param {string} text The text to parse.
* @param {Object} config The ESLint configuration object.
* @param {string} filePath The path to the file being parsed.
* @returns {ASTNode} The AST if successful or null if not.
* @private
*/
function parse(text, config) {
function parse(text, config, filePath) {
let parser,
parserOptions = {
@@ -610,7 +611,8 @@ module.exports = (function() {
raw: true,
tokens: true,
comment: true,
attachComment: true
attachComment: true,
filePath
};
try {
@@ -783,7 +785,8 @@ module.exports = (function() {
shebang = captured;
return "//" + captured;
}),
config
config,
currentFilename
);
if (ast) {
@@ -974,7 +977,7 @@ module.exports = (function() {
}
if (opts) {
message = message.replace(/\{\{\s*(.+?)\s*\}\}/g, function(fullMatch, term) {
message = message.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, function(fullMatch, term) {
if (term in opts) {
return opts[term];
}
@@ -75,7 +75,10 @@ module.exports = {
context.report({
node,
loc: token.loc.start,
message: "There should be no space after '" + token.value + "'.",
message: "There should be no space after '{{tokenValue}}'.",
data: {
tokenValue: token.value
},
fix(fixer) {
const nextToken = sourceCode.getTokenAfter(token);
@@ -94,7 +97,10 @@ module.exports = {
context.report({
node,
loc: token.loc.start,
message: "There should be no space before '" + token.value + "'.",
message: "There should be no space before '{{tokenValue}}'.",
data: {
tokenValue: token.value
},
fix(fixer) {
const previousToken = sourceCode.getTokenBefore(token);
@@ -113,7 +119,10 @@ module.exports = {
context.report({
node,
loc: token.loc.start,
message: "A space is required after '" + token.value + "'.",
message: "A space is required after '{{tokenValue}}'.",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextAfter(token, " ");
}
@@ -130,7 +139,10 @@ module.exports = {
context.report({
node,
loc: token.loc.start,
message: "A space is required before '" + token.value + "'.",
message: "A space is required before '{{tokenValue}}'.",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextBefore(token, " ");
}
@@ -87,7 +87,7 @@ module.exports = {
node,
message: requireForBlockBodyNoParensMessage,
fix(fixer) {
return fixer.replaceText(token, "(" + token.value + ")");
return fixer.replaceText(token, `(${token.value})`);
}
});
}
@@ -123,7 +123,7 @@ module.exports = {
node,
message,
fix(fixer) {
return fixer.replaceText(token, "(" + token.value + ")");
return fixer.replaceText(token, `(${token.value})`);
}
});
}
@@ -51,16 +51,18 @@ module.exports = {
* @returns {Object} Tokens of arrow and before/after arrow.
*/
function getTokens(node) {
let t = sourceCode.getFirstToken(node);
let before;
let arrow = sourceCode.getTokenBefore(node.body);
while (t.type !== "Punctuator" || t.value !== "=>") {
before = t;
t = sourceCode.getTokenAfter(t);
// skip '(' tokens.
while (arrow.value !== "=>") {
arrow = sourceCode.getTokenBefore(arrow);
}
const after = sourceCode.getTokenAfter(t);
return { before, arrow: t, after };
return {
before: sourceCode.getTokenBefore(arrow),
arrow,
after: sourceCode.getTokenAfter(arrow)
};
}
/**
@@ -97,7 +97,10 @@ module.exports = {
context.report({
node,
loc: openBrace.loc.start,
message: message + " after '{'.",
message: "{{message}} after '{'.",
data: {
message
},
fix(fixer) {
if (always) {
return fixer.insertTextBefore(firstToken, " ");
@@ -111,7 +114,10 @@ module.exports = {
context.report({
node,
loc: closeBrace.loc.start,
message: message + " before '}'.",
message: "{{message}} before '}'.",
data: {
message
},
fix(fixer) {
if (always) {
return fixer.insertTextAfter(lastToken, " ");
@@ -53,7 +53,13 @@ module.exports = {
const methodUsesThis = stack.pop();
if (isInstanceMethod(node.parent) && !methodUsesThis) {
context.report(node, "Expected 'this' to be used by class method '" + node.parent.key.name + "'.");
context.report({
node,
message: "Expected 'this' to be used by class method '{{classMethod}}'.",
data: {
classMethod: node.parent.key.name
}
});
}
}
@@ -97,8 +97,11 @@ module.exports = {
}
},
message: options[dir] ?
"A space is required " + dir + " ','." :
"There should be no space " + dir + " ','."
"A space is required {{dir}} ','." :
"There should be no space {{dir}} ','.",
data: {
dir
}
});
}
@@ -18,7 +18,7 @@ module.exports = {
category: "Stylistic Issues",
recommended: false
},
fixable: "code",
schema: [
{
enum: ["first", "last"]
@@ -61,6 +61,49 @@ module.exports = {
return !!token && (token.type === "Punctuator") && (token.value === ",");
}
/**
* Modified text based on the style
* @param {string} styleType Style type
* @param {string} text Source code text
* @returns {string} modified text
* @private
*/
function getReplacedText(styleType, text) {
switch (styleType) {
case "between":
return `,${text.replace("\n", "")}`;
case "first":
return `${text},`;
case "last":
return `,${text}`;
default:
return "";
}
}
/**
* Determines the fixer function for a given style.
* @param {string} styleType comma style
* @param {ASTNode} previousItemToken The token to check.
* @param {ASTNode} commaToken The token to check.
* @param {ASTNode} currentItemToken The token to check.
* @returns {Function} Fixer function
* @private
*/
function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
const text =
sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) +
sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
const range = [previousItemToken.range[1], currentItemToken.range[0]];
return function(fixer) {
return fixer.replaceTextRange(range, getReplacedText(styleType, text));
};
}
/**
* Validates the spacing around single items in lists.
* @param {Token} previousItemToken The last token from the previous item.
@@ -82,21 +125,35 @@ module.exports = {
!astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
// lone comma
context.report(reportItem, {
line: commaToken.loc.end.line,
column: commaToken.loc.start.column
}, "Bad line breaking before and after ','.");
context.report({
node: reportItem,
loc: {
line: commaToken.loc.end.line,
column: commaToken.loc.start.column
},
message: "Bad line breaking before and after ','.",
fix: getFixerFunction("between", previousItemToken, commaToken, currentItemToken)
});
} else if (style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
context.report(reportItem, "',' should be placed first.");
context.report({
node: reportItem,
message: "',' should be placed first.",
fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
});
} else if (style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
context.report(reportItem, {
line: commaToken.loc.end.line,
column: commaToken.loc.end.column
}, "',' should be placed last.");
context.report({
node: reportItem,
loc: {
line: commaToken.loc.end.line,
column: commaToken.loc.end.column
},
message: "',' should be placed last.",
fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
});
}
}
Oops, something went wrong.

0 comments on commit 36235ac

Please sign in to comment.