Permalink
Browse files

tools: update ESLint to 3.4.0

PR-URL: #8296
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
  • Loading branch information...
Trott authored and Fishrock123 committed Aug 27, 2016
1 parent 605db31 commit 54f689fc1e85e518230c0ca8e81176f9ba333016
Showing 303 changed files with 2,227 additions and 2,058 deletions.
View
@@ -155,13 +155,14 @@ ESLint follows [semantic versioning](http://semver.org). However, due to the nat
* Minor release (might break your lint build)
* A bug fix in a rule that results in ESLint reporting more errors.
* A new rule is created.
* A new option to an existing rule is created.
* A new option to an existing rule that does not result in ESLint reporting more errors by default.
* An existing rule is deprecated.
* A new CLI capability is created.
* New capabilities to the public API are added (new classes, new methods, new arguments to existing methods, etc.).
* A new formatter is created.
* Major release (likely to break your lint build)
* `eslint:recommended` is updated.
* A new option to an existing rule that results in ESLint reporting more errors by default.
* An existing rule is removed.
* An existing formatter is removed.
* Part of the public API is removed or changed in an incompatible way.
View
@@ -0,0 +1,77 @@
#!/usr/bin/env node
/**
* @fileoverview Main CLI that is run via the eslint command.
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
var useStdIn = (process.argv.indexOf("--stdin") > -1),
init = (process.argv.indexOf("--init") > -1),
debug = (process.argv.indexOf("--debug") > -1);
// must do this initialization *before* other requires in order to work
if (debug) {
require("debug").enable("eslint:*,-eslint:code-path");
}
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
// now we can safely include the other modules that use debug
var concat = require("concat-stream"),
cli = require("../lib/cli"),
path = require("path"),
fs = require("fs");
//------------------------------------------------------------------------------
// Execution
//------------------------------------------------------------------------------
process.on("uncaughtException", function(err){
// lazy load
var lodash = require("lodash");
if (typeof err.messageTemplate === "string" && err.messageTemplate.length > 0) {
var template = lodash.template(fs.readFileSync(path.resolve(__dirname, "../messages/" + err.messageTemplate + ".txt"), "utf-8"));
console.log("\nOops! Something went wrong! :(");
console.log("\n" + template(err.messageData || {}));
} else {
console.log(err.message);
console.log(err.stack);
}
process.exit(1);
});
if (useStdIn) {
process.stdin.pipe(concat({ encoding: "string" }, function(text) {
try {
process.exitCode = cli.execute(process.argv, text);
} catch (ex) {
console.error(ex.message);
console.error(ex.stack);
process.exitCode = 1;
}
}));
} else if (init) {
var configInit = require("../lib/config/config-initializer");
configInit.initializeConfig(function(err) {
if (err) {
process.exitCode = 1;
console.error(err.message);
console.error(err.stack);
} else {
process.exitCode = 0;
}
});
} else {
process.exitCode = cli.execute(process.argv);
}
@@ -140,6 +140,7 @@
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
@@ -217,6 +218,7 @@
"space-unary-ops": "off",
"spaced-comment": "off",
"strict": "off",
"symbol-description": "off",
"template-curly-spacing": "off",
"unicode-bom": "off",
"use-isnan": "error",
@@ -210,23 +210,23 @@ module.exports = {
* @returns {boolean} Whether or not the tokens are on the same line.
* @public
*/
isTokenOnSameLine: function(left, right) {
isTokenOnSameLine(left, right) {
return left.loc.end.line === right.loc.start.line;
},
isNullOrUndefined: isNullOrUndefined,
isCallee: isCallee,
isES5Constructor: isES5Constructor,
getUpperFunction: getUpperFunction,
isArrayFromMethod: isArrayFromMethod,
isParenthesised: isParenthesised,
isNullOrUndefined,
isCallee,
isES5Constructor,
getUpperFunction,
isArrayFromMethod,
isParenthesised,
/**
* Checks whether or not a given node is a string literal.
* @param {ASTNode} node - A node to check.
* @returns {boolean} `true` if the node is a string literal.
*/
isStringLiteral: function(node) {
isStringLiteral(node) {
return (
(node.type === "Literal" && typeof node.value === "string") ||
node.type === "TemplateLiteral"
@@ -247,7 +247,7 @@ module.exports = {
* @param {ASTNode} node - A node to check.
* @returns {boolean} `true` if the node is breakable.
*/
isBreakableStatement: function(node) {
isBreakableStatement(node) {
return breakableTypePattern.test(node.type);
},
@@ -257,7 +257,7 @@ module.exports = {
* @param {ASTNode} node - A node to get.
* @returns {string|null} The label or `null`.
*/
getLabel: function(node) {
getLabel(node) {
if (node.parent.type === "LabeledStatement") {
return node.parent.label.name;
}
@@ -270,7 +270,7 @@ module.exports = {
* @returns {Reference[]} An array of only references which are non initializer and writable.
* @public
*/
getModifyingReferences: function(references) {
getModifyingReferences(references) {
return references.filter(isModifyingReference);
},
@@ -281,7 +281,7 @@ module.exports = {
* @returns {boolean} True if the text is surrounded by the character, false if not.
* @private
*/
isSurroundedBy: function(val, character) {
isSurroundedBy(val, character) {
return val[0] === character && val[val.length - 1] === character;
},
@@ -290,7 +290,7 @@ module.exports = {
* @param {LineComment|BlockComment} node The node to be checked
* @returns {boolean} `true` if the node is an ESLint directive comment
*/
isDirectiveComment: function(node) {
isDirectiveComment(node) {
const comment = node.value.trim();
return (
@@ -323,7 +323,7 @@ module.exports = {
* @param {string} name - A variable name to find.
* @returns {escope.Variable|null} A found variable or `null`.
*/
getVariableByName: function(initScope, name) {
getVariableByName(initScope, name) {
let scope = initScope;
while (scope) {
@@ -360,7 +360,7 @@ module.exports = {
* @param {SourceCode} sourceCode - A SourceCode instance to get comments.
* @returns {boolean} The function node is the default `this` binding.
*/
isDefaultThisBinding: function(node, sourceCode) {
isDefaultThisBinding(node, sourceCode) {
if (isES5Constructor(node) || hasJSDocThisTag(node, sourceCode)) {
return false;
}
@@ -496,7 +496,7 @@ module.exports = {
* @returns {int} precedence level
* @private
*/
getPrecedence: function(node) {
getPrecedence(node) {
switch (node.type) {
case "SequenceExpression":
return 0;
@@ -594,7 +594,7 @@ module.exports = {
* @param {ASTNode|null} node - A node to check.
* @returns {boolean} `true` if the node is a loop node.
*/
isLoop: function(node) {
isLoop(node) {
return Boolean(node && anyLoopPattern.test(node.type));
},
@@ -609,7 +609,7 @@ module.exports = {
* @param {ASTNode|null} node - A node to check.
* @returns {boolean} `true` if the node is a function node.
*/
isFunction: function(node) {
isFunction(node) {
return Boolean(node && anyFunctionPattern.test(node.type));
},
@@ -241,8 +241,8 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) {
parsedBlocks.forEach(function(block) {
unprocessedMessages.push(eslint.verify(block, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
filename,
allowInlineConfig
}));
});
@@ -254,14 +254,14 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) {
if (fix) {
fixedResult = multipassFix(text, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
filename,
allowInlineConfig
});
messages = fixedResult.messages;
} else {
messages = eslint.verify(text, config, {
filename: filename,
allowInlineConfig: allowInlineConfig
filename,
allowInlineConfig
});
}
}
@@ -270,7 +270,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) {
const result = {
filePath: filename,
messages: messages,
messages,
errorCount: stats.errorCount,
warningCount: stats.warningCount
};
@@ -329,7 +329,7 @@ function createIgnoreResult(filePath, baseDir) {
{
fatal: false,
severity: 1,
message: message
message
}
],
errorCount: 0,
@@ -559,7 +559,7 @@ CLIEngine.prototype = {
* @param {Object} pluginobject Plugin configuration object.
* @returns {void}
*/
addPlugin: function(name, pluginobject) {
addPlugin(name, pluginobject) {
Plugins.define(name, pluginobject);
},
@@ -569,7 +569,7 @@ CLIEngine.prototype = {
* @param {string[]} patterns The file patterns passed on the command line.
* @returns {string[]} The equivalent glob patterns.
*/
resolveFileGlobPatterns: function(patterns) {
resolveFileGlobPatterns(patterns) {
return globUtil.resolveFileGlobPatterns(patterns, this.options);
},
@@ -578,7 +578,7 @@ CLIEngine.prototype = {
* @param {string[]} patterns An array of file and directory names.
* @returns {Object} The results for all files that were linted.
*/
executeOnFiles: function(patterns) {
executeOnFiles(patterns) {
const results = [],
options = this.options,
fileCache = this._fileCache,
@@ -716,7 +716,7 @@ CLIEngine.prototype = {
debug("Linting complete in: " + (Date.now() - startTime) + "ms");
return {
results: results,
results,
errorCount: stats.errorCount,
warningCount: stats.warningCount
};
@@ -729,7 +729,7 @@ CLIEngine.prototype = {
* @param {boolean} warnIgnored Always warn when a file is ignored
* @returns {Object} The results for the linting.
*/
executeOnText: function(text, filename, warnIgnored) {
executeOnText(text, filename, warnIgnored) {
const results = [],
options = this.options,
@@ -752,7 +752,7 @@ CLIEngine.prototype = {
const stats = calculateStatsPerRun(results);
return {
results: results,
results,
errorCount: stats.errorCount,
warningCount: stats.warningCount
};
@@ -765,7 +765,7 @@ CLIEngine.prototype = {
* @param {string} filePath The path of the file to retrieve a config object for.
* @returns {Object} A configuration object for the file.
*/
getConfigForFile: function(filePath) {
getConfigForFile(filePath) {
const configHelper = new Config(this.options);
return configHelper.getConfig(filePath);
@@ -776,7 +776,7 @@ CLIEngine.prototype = {
* @param {string} filePath The path of the file to check.
* @returns {boolean} Whether or not the given path is ignored.
*/
isPathIgnored: function(filePath) {
isPathIgnored(filePath) {
const resolvedPath = path.resolve(this.options.cwd, filePath);
const ignoredPaths = new IgnoredPaths(this.options);
View
@@ -120,7 +120,7 @@ const cli = {
* @param {string} [text] The text to lint (used for TTY).
* @returns {int} The exit code for the operation.
*/
execute: function(args, text) {
execute(args, text) {
let currentOptions;
@@ -592,7 +592,7 @@ CodePathAnalyzer.prototype = {
* @param {ASTNode} node - A node which is entering.
* @returns {void}
*/
enterNode: function(node) {
enterNode(node) {
this.currentNode = node;
// Updates the code path due to node's position in its parent node.
@@ -617,7 +617,7 @@ CodePathAnalyzer.prototype = {
* @param {ASTNode} node - A node which is leaving.
* @returns {void}
*/
leaveNode: function(node) {
leaveNode(node) {
this.currentNode = node;
// Updates the code path.
@@ -641,7 +641,7 @@ CodePathAnalyzer.prototype = {
* @param {CodePathSegment} toSegment - A segment of next.
* @returns {void}
*/
onLooped: function(fromSegment, toSegment) {
onLooped(fromSegment, toSegment) {
if (fromSegment.reachable && toSegment.reachable) {
debug.dump("onCodePathSegmentLoop " + fromSegment.id + " -> " + toSegment.id);
this.emitter.emit(
@@ -138,7 +138,7 @@ CodePathSegment.prototype = {
* @param {CodePathSegment} segment - A previous segment to check.
* @returns {boolean} `true` if the segment is coming from the end of a loop.
*/
isLoopedPrevSegment: function(segment) {
isLoopedPrevSegment(segment) {
return this.internal.loopedPrevSegments.indexOf(segment) !== -1;
}
};
Oops, something went wrong.

0 comments on commit 54f689f

Please sign in to comment.