eslint 3.9.0 → 3.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -1
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/eslint.js +5 -5
- package/conf/eslint.json +1 -0
- package/lib/ast-utils.js +1 -3
- package/lib/cli-engine.js +9 -11
- package/lib/code-path-analysis/debug-helpers.js +4 -4
- package/lib/config/autoconfig.js +23 -35
- package/lib/config/config-file.js +1 -1
- package/lib/config/config-initializer.js +12 -20
- package/lib/config/config-ops.js +7 -9
- package/lib/config/config-rule.js +14 -18
- package/lib/config/config-validator.js +3 -3
- package/lib/config/environments.js +1 -1
- package/lib/config.js +2 -2
- package/lib/eslint.js +21 -23
- package/lib/file-finder.js +1 -1
- package/lib/formatters/checkstyle.js +2 -2
- package/lib/formatters/compact.js +2 -2
- package/lib/formatters/html.js +9 -11
- package/lib/formatters/jslint-xml.js +2 -2
- package/lib/formatters/junit.js +2 -2
- package/lib/formatters/stylish.js +3 -7
- package/lib/formatters/table.js +4 -6
- package/lib/formatters/tap.js +2 -2
- package/lib/formatters/unix.js +2 -2
- package/lib/formatters/visualstudio.js +2 -2
- package/lib/load-rules.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +9 -2
- package/lib/rules/brace-style.js +2 -2
- package/lib/rules/comma-spacing.js +2 -2
- package/lib/rules/comma-style.js +51 -4
- package/lib/rules/consistent-this.js +5 -9
- package/lib/rules/constructor-super.js +1 -1
- package/lib/rules/curly.js +10 -7
- package/lib/rules/default-case.js +1 -3
- package/lib/rules/eqeqeq.js +19 -7
- package/lib/rules/func-names.js +23 -4
- package/lib/rules/global-require.js +3 -7
- package/lib/rules/handle-callback-err.js +1 -3
- package/lib/rules/id-length.js +1 -1
- package/lib/rules/indent.js +10 -25
- package/lib/rules/key-spacing.js +4 -4
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/lines-around-comment.js +5 -11
- package/lib/rules/lines-around-directive.js +23 -4
- package/lib/rules/max-len.js +5 -11
- package/lib/rules/max-lines.js +4 -12
- package/lib/rules/max-statements.js +11 -2
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +2 -4
- package/lib/rules/no-alert.js +2 -4
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-control-regex.js +2 -2
- package/lib/rules/no-duplicate-case.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +3 -7
- package/lib/rules/no-extra-boolean-cast.js +14 -3
- package/lib/rules/no-extra-parens.js +4 -4
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-implicit-globals.js +4 -4
- package/lib/rules/no-irregular-whitespace.js +3 -3
- package/lib/rules/no-mixed-operators.js +1 -3
- package/lib/rules/no-mixed-requires.js +2 -2
- package/lib/rules/no-mixed-spaces-and-tabs.js +3 -3
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-new-symbol.js +1 -1
- package/lib/rules/no-redeclare.js +2 -4
- package/lib/rules/no-restricted-globals.js +2 -2
- package/lib/rules/no-restricted-imports.js +45 -11
- package/lib/rules/no-restricted-modules.js +53 -36
- package/lib/rules/no-restricted-syntax.js +2 -4
- package/lib/rules/no-return-await.js +77 -0
- package/lib/rules/no-tabs.js +1 -1
- package/lib/rules/no-this-before-super.js +2 -2
- package/lib/rules/no-undef.js +1 -1
- package/lib/rules/no-underscore-dangle.js +1 -3
- package/lib/rules/no-unused-vars.js +2 -6
- package/lib/rules/no-use-before-define.js +1 -1
- package/lib/rules/no-useless-escape.js +8 -54
- package/lib/rules/no-useless-return.js +6 -0
- package/lib/rules/no-warning-comments.js +2 -2
- package/lib/rules/object-shorthand.js +21 -10
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/prefer-const.js +1 -3
- package/lib/rules/prefer-reflect.js +2 -1
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +2 -2
- package/lib/rules/require-jsdoc.js +8 -0
- package/lib/rules/sort-vars.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-infix-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/valid-jsdoc.js +3 -3
- package/lib/rules.js +2 -2
- package/lib/testers/event-generator-tester.js +5 -5
- package/lib/testers/rule-tester.js +11 -13
- package/lib/timing.js +11 -13
- package/lib/util/comment-event-generator.js +1 -1
- package/lib/util/glob-util.js +3 -5
- package/lib/util/npm-util.js +1 -1
- package/lib/util/source-code-fixer.js +3 -5
- package/lib/util/source-code-util.js +4 -4
- package/lib/util/source-code.js +3 -3
- package/lib/util/traverser.js +1 -3
- package/lib/util/xml-escape.js +1 -1
- package/package.json +3 -3
@@ -307,9 +307,7 @@ RuleTester.prototype = {
|
|
307
307
|
if (validateSchema.errors) {
|
308
308
|
throw new Error([
|
309
309
|
`Schema for rule ${ruleName} is invalid:`
|
310
|
-
].concat(validateSchema.errors.map(
|
311
|
-
return `\t${error.field}: ${error.message}`;
|
312
|
-
})).join("\n"));
|
310
|
+
].concat(validateSchema.errors.map(error => `\t${error.field}: ${error.message}`)).join("\n"));
|
313
311
|
}
|
314
312
|
}
|
315
313
|
|
@@ -321,10 +319,10 @@ RuleTester.prototype = {
|
|
321
319
|
* running the rule under test.
|
322
320
|
*/
|
323
321
|
eslint.reset();
|
324
|
-
eslint.on("Program",
|
322
|
+
eslint.on("Program", node => {
|
325
323
|
beforeAST = cloneDeeplyExcludesParent(node);
|
326
324
|
|
327
|
-
eslint.on("Program:exit",
|
325
|
+
eslint.on("Program:exit", node => {
|
328
326
|
afterAST = cloneDeeplyExcludesParent(node);
|
329
327
|
});
|
330
328
|
});
|
@@ -448,7 +446,7 @@ RuleTester.prototype = {
|
|
448
446
|
}
|
449
447
|
|
450
448
|
if (item.errors[i].type) {
|
451
|
-
assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}`);
|
449
|
+
assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}, found ${messages[i].nodeType}`);
|
452
450
|
}
|
453
451
|
|
454
452
|
if (item.errors[i].hasOwnProperty("line")) {
|
@@ -488,18 +486,18 @@ RuleTester.prototype = {
|
|
488
486
|
* This creates a mocha test suite and pipes all supplied info through
|
489
487
|
* one of the templates above.
|
490
488
|
*/
|
491
|
-
RuleTester.describe(ruleName,
|
492
|
-
RuleTester.describe("valid",
|
493
|
-
test.valid.forEach(
|
494
|
-
RuleTester.it(valid.code || valid,
|
489
|
+
RuleTester.describe(ruleName, () => {
|
490
|
+
RuleTester.describe("valid", () => {
|
491
|
+
test.valid.forEach(valid => {
|
492
|
+
RuleTester.it(valid.code || valid, () => {
|
495
493
|
testValidTemplate(ruleName, valid);
|
496
494
|
});
|
497
495
|
});
|
498
496
|
});
|
499
497
|
|
500
|
-
RuleTester.describe("invalid",
|
501
|
-
test.invalid.forEach(
|
502
|
-
RuleTester.it(invalid.code,
|
498
|
+
RuleTester.describe("invalid", () => {
|
499
|
+
test.invalid.forEach(invalid => {
|
500
|
+
RuleTester.it(invalid.code, () => {
|
503
501
|
testInvalidTemplate(ruleName, invalid);
|
504
502
|
});
|
505
503
|
});
|
package/lib/timing.js
CHANGED
@@ -54,18 +54,16 @@ const ALIGN = [alignLeft, alignRight, alignRight];
|
|
54
54
|
function display(data) {
|
55
55
|
let total = 0;
|
56
56
|
const rows = Object.keys(data)
|
57
|
-
.map(
|
57
|
+
.map(key => {
|
58
58
|
const time = data[key];
|
59
59
|
|
60
60
|
total += time;
|
61
61
|
return [key, time];
|
62
62
|
})
|
63
|
-
.sort(
|
64
|
-
return b[1] - a[1];
|
65
|
-
})
|
63
|
+
.sort((a, b) => b[1] - a[1])
|
66
64
|
.slice(0, 10);
|
67
65
|
|
68
|
-
rows.forEach(
|
66
|
+
rows.forEach(row => {
|
69
67
|
row.push(`${(row[1] * 100 / total).toFixed(1)}%`);
|
70
68
|
row[1] = row[1].toFixed(3);
|
71
69
|
});
|
@@ -74,7 +72,7 @@ function display(data) {
|
|
74
72
|
|
75
73
|
const widths = [];
|
76
74
|
|
77
|
-
rows.forEach(
|
75
|
+
rows.forEach(row => {
|
78
76
|
const len = row.length;
|
79
77
|
|
80
78
|
for (let i = 0; i < len; i++) {
|
@@ -86,13 +84,13 @@ function display(data) {
|
|
86
84
|
}
|
87
85
|
});
|
88
86
|
|
89
|
-
const table = rows.map(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
87
|
+
const table = rows.map(row =>
|
88
|
+
row
|
89
|
+
.map((cell, index) => ALIGN[index](cell, widths[index]))
|
90
|
+
.join(" | ")
|
91
|
+
);
|
94
92
|
|
95
|
-
table.splice(1, 0, widths.map(
|
93
|
+
table.splice(1, 0, widths.map((w, index) => {
|
96
94
|
if (index !== 0 && index !== widths.length - 1) {
|
97
95
|
w++;
|
98
96
|
}
|
@@ -130,7 +128,7 @@ module.exports = (function() {
|
|
130
128
|
}
|
131
129
|
|
132
130
|
if (enabled) {
|
133
|
-
process.on("exit",
|
131
|
+
process.on("exit", () => {
|
134
132
|
display(data);
|
135
133
|
});
|
136
134
|
}
|
package/lib/util/glob-util.js
CHANGED
@@ -43,9 +43,7 @@ function processPath(options) {
|
|
43
43
|
const cwd = (options && options.cwd) || process.cwd();
|
44
44
|
let extensions = (options && options.extensions) || [".js"];
|
45
45
|
|
46
|
-
extensions = extensions.map(
|
47
|
-
return ext.charAt(0) === "." ? ext.substr(1) : ext;
|
48
|
-
});
|
46
|
+
extensions = extensions.map(ext => ext.replace(/^\./, ""));
|
49
47
|
|
50
48
|
let suffix = "/**";
|
51
49
|
|
@@ -150,7 +148,7 @@ function listFilesToProcess(globPatterns, options) {
|
|
150
148
|
}
|
151
149
|
|
152
150
|
debug("Creating list of files to process.");
|
153
|
-
globPatterns.forEach(
|
151
|
+
globPatterns.forEach(pattern => {
|
154
152
|
const file = path.resolve(cwd, pattern);
|
155
153
|
|
156
154
|
if (shell.test("-f", file)) {
|
@@ -170,7 +168,7 @@ function listFilesToProcess(globPatterns, options) {
|
|
170
168
|
cwd,
|
171
169
|
};
|
172
170
|
|
173
|
-
new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(
|
171
|
+
new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(globMatch => {
|
174
172
|
addFile(path.resolve(cwd, globMatch), false, ignoredPaths);
|
175
173
|
});
|
176
174
|
}
|
package/lib/util/npm-util.js
CHANGED
@@ -89,7 +89,7 @@ function check(packages, opt) {
|
|
89
89
|
if (opt.dependencies && typeof fileJson.dependencies === "object") {
|
90
90
|
deps = deps.concat(Object.keys(fileJson.dependencies));
|
91
91
|
}
|
92
|
-
return packages.reduce(
|
92
|
+
return packages.reduce((status, pkg) => {
|
93
93
|
status[pkg] = deps.indexOf(pkg) !== -1;
|
94
94
|
return status;
|
95
95
|
}, {});
|
@@ -72,7 +72,7 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) {
|
|
72
72
|
let lastFixPos = text.length + 1,
|
73
73
|
prefix = (sourceCode.hasBOM ? BOM : "");
|
74
74
|
|
75
|
-
messages.forEach(
|
75
|
+
messages.forEach(problem => {
|
76
76
|
if (problem.hasOwnProperty("fix")) {
|
77
77
|
fixes.push(problem);
|
78
78
|
} else {
|
@@ -84,14 +84,12 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) {
|
|
84
84
|
debug("Found fixes to apply");
|
85
85
|
|
86
86
|
// sort in reverse order of occurrence
|
87
|
-
fixes.sort(
|
88
|
-
return b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0];
|
89
|
-
});
|
87
|
+
fixes.sort((a, b) => b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0]);
|
90
88
|
|
91
89
|
// split into array of characters for easier manipulation
|
92
90
|
const chars = text.split("");
|
93
91
|
|
94
|
-
fixes.forEach(
|
92
|
+
fixes.forEach(problem => {
|
95
93
|
const fix = problem.fix;
|
96
94
|
let start = fix.range[0];
|
97
95
|
const end = fix.range[1];
|
@@ -84,14 +84,14 @@ function getSourceCodeOfFiles(patterns, options, cb) {
|
|
84
84
|
debug("constructed options:", opts);
|
85
85
|
patterns = globUtil.resolveFileGlobPatterns(patterns, opts);
|
86
86
|
|
87
|
-
const filenames = globUtil.listFilesToProcess(patterns, opts)
|
88
|
-
|
89
|
-
|
87
|
+
const filenames = globUtil.listFilesToProcess(patterns, opts)
|
88
|
+
.filter(fileInfo => !fileInfo.ignored)
|
89
|
+
.reduce((files, fileInfo) => files.concat(fileInfo.filename), []);
|
90
90
|
|
91
91
|
if (filenames.length === 0) {
|
92
92
|
debug(`Did not find any files matching pattern(s): ${patterns}`);
|
93
93
|
}
|
94
|
-
filenames.forEach(
|
94
|
+
filenames.forEach(filename => {
|
95
95
|
const sourceCode = getSourceCodeOfFile(filename, opts);
|
96
96
|
|
97
97
|
if (sourceCode) {
|
package/lib/util/source-code.js
CHANGED
@@ -117,9 +117,9 @@ function SourceCode(text, ast) {
|
|
117
117
|
*/
|
118
118
|
this.lines = SourceCode.splitLines(this.text);
|
119
119
|
|
120
|
-
this.tokensAndComments = ast.tokens
|
121
|
-
|
122
|
-
|
120
|
+
this.tokensAndComments = ast.tokens
|
121
|
+
.concat(ast.comments)
|
122
|
+
.sort((left, right) => left.range[0] - right.range[0]);
|
123
123
|
|
124
124
|
// create token store methods
|
125
125
|
const tokenStore = createTokenStore(ast.tokens);
|
package/lib/util/traverser.js
CHANGED
@@ -46,9 +46,7 @@ function Traverser() {
|
|
46
46
|
* @private
|
47
47
|
*/
|
48
48
|
Traverser.getKeys = function(node) {
|
49
|
-
return Object.keys(node).filter(
|
50
|
-
return KEY_BLACKLIST.indexOf(key) === -1;
|
51
|
-
});
|
49
|
+
return Object.keys(node).filter(key => KEY_BLACKLIST.indexOf(key) === -1);
|
52
50
|
};
|
53
51
|
|
54
52
|
module.exports = Traverser;
|
package/lib/util/xml-escape.js
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
* @private
|
16
16
|
*/
|
17
17
|
module.exports = function(s) {
|
18
|
-
return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g,
|
18
|
+
return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, c => { // eslint-disable-line no-control-regex
|
19
19
|
switch (c) {
|
20
20
|
case "<":
|
21
21
|
return "<";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.10.2",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"file-entry-cache": "^2.0.0",
|
47
47
|
"glob": "^7.0.3",
|
48
48
|
"globals": "^9.2.0",
|
49
|
-
"ignore": "^3.
|
49
|
+
"ignore": "^3.2.0",
|
50
50
|
"imurmurhash": "^0.1.4",
|
51
51
|
"inquirer": "^0.12.0",
|
52
52
|
"is-my-json-valid": "^2.10.0",
|
@@ -98,7 +98,7 @@
|
|
98
98
|
"load-perf": "^0.2.0",
|
99
99
|
"markdownlint": "^0.2.0",
|
100
100
|
"mocha": "^2.4.5",
|
101
|
-
"mock-fs": "3.
|
101
|
+
"mock-fs": "^3.12.1",
|
102
102
|
"npm-license": "^0.3.2",
|
103
103
|
"phantomjs-prebuilt": "^2.1.7",
|
104
104
|
"proxyquire": "^1.7.10",
|