eslint 5.3.0 → 5.4.0
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 +11 -0
- package/lib/cli-engine.js +1 -2
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/complexity.js +2 -2
- package/lib/rules/indent.js +6 -2
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/max-depth.js +2 -2
- package/lib/rules/max-lines.js +1 -1
- package/lib/rules/max-nested-callbacks.js +2 -2
- package/lib/rules/max-params.js +2 -2
- package/lib/rules/max-statements.js +2 -2
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/one-var.js +6 -6
- package/lib/rules/padded-blocks.js +6 -6
- package/lib/rules/prefer-reflect.js +1 -1
- package/lib/rules/semi-spacing.js +2 -2
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/testers/rule-tester.js +5 -5
- package/lib/util/file-finder.js +2 -2
- package/lib/util/lint-result-cache.js +2 -2
- package/lib/util/source-code-fixer.js +1 -1
- package/package.json +1 -2
- package/lib/rules/.eslintrc.yml +0 -4
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
v5.4.0 - August 17, 2018
|
2
|
+
|
3
|
+
* a70909f Docs: Add jscs-dev.github.io links (#10771) (Gustavo Santana)
|
4
|
+
* 034690f Fix: no-invalid-meta crashes for non Object values (fixes #10750) (#10753) (Sandeep Kumar Ranka)
|
5
|
+
* 11a462d Docs: Broken jscs.info URLs (fixes #10732) (#10770) (Gustavo Santana)
|
6
|
+
* 985567d Chore: rm unused dep string.prototype.matchall (#10756) (薛定谔的猫)
|
7
|
+
* f3d8454 Update: Improve no-extra-parens error message (#10748) (Timo Tijhof)
|
8
|
+
* 562a03f Fix: consistent-docs-url crashes if meta.docs is empty (fixes #10722) (#10749) (Sandeep Kumar Ranka)
|
9
|
+
* 6492233 Chore: enable no-prototype-builtins in codebase (fixes #10660) (#10664) (薛定谔的猫)
|
10
|
+
* 137140f Chore: use eslintrc overrides (#10677) (薛定谔的猫)
|
11
|
+
|
1
12
|
v5.3.0 - August 3, 2018
|
2
13
|
|
3
14
|
* dd6cb19 Docs: Updated no-return-await Rule Documentation (fixes #9695) (#10699) (Marla Foreman)
|
package/lib/cli-engine.js
CHANGED
@@ -30,7 +30,6 @@ const fs = require("fs"),
|
|
30
30
|
pkg = require("../package.json");
|
31
31
|
|
32
32
|
const debug = require("debug")("eslint:cli-engine");
|
33
|
-
|
34
33
|
const resolver = new ModuleResolver();
|
35
34
|
|
36
35
|
//------------------------------------------------------------------------------
|
@@ -469,7 +468,7 @@ class CLIEngine {
|
|
469
468
|
* @returns {void}
|
470
469
|
*/
|
471
470
|
static outputFixes(report) {
|
472
|
-
report.results.filter(result =>
|
471
|
+
report.results.filter(result => Object.prototype.hasOwnProperty.call(result, "output")).forEach(result => {
|
473
472
|
fs.writeFileSync(result.filePath, result.output);
|
474
473
|
});
|
475
474
|
}
|
package/lib/rules/comma-style.js
CHANGED
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
NewExpression: true
|
59
59
|
};
|
60
60
|
|
61
|
-
if (context.options.length === 2 && context.options[1]
|
61
|
+
if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
|
62
62
|
const keys = Object.keys(context.options[1].exceptions);
|
63
63
|
|
64
64
|
for (let i = 0; i < keys.length; i++) {
|
package/lib/rules/complexity.js
CHANGED
@@ -61,10 +61,10 @@ module.exports = {
|
|
61
61
|
const option = context.options[0];
|
62
62
|
let THRESHOLD = 20;
|
63
63
|
|
64
|
-
if (typeof option === "object" &&
|
64
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
65
65
|
THRESHOLD = option.maximum;
|
66
66
|
}
|
67
|
-
if (typeof option === "object" &&
|
67
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
68
68
|
THRESHOLD = option.max;
|
69
69
|
}
|
70
70
|
if (typeof option === "number") {
|
package/lib/rules/indent.js
CHANGED
@@ -1333,7 +1333,9 @@ module.exports = {
|
|
1333
1333
|
node.expressions.forEach((expression, index) => {
|
1334
1334
|
const previousQuasi = node.quasis[index];
|
1335
1335
|
const nextQuasi = node.quasis[index + 1];
|
1336
|
-
const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line
|
1336
|
+
const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line
|
1337
|
+
? sourceCode.getFirstToken(previousQuasi)
|
1338
|
+
: null;
|
1337
1339
|
|
1338
1340
|
offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
|
1339
1341
|
offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
|
@@ -1341,7 +1343,9 @@ module.exports = {
|
|
1341
1343
|
},
|
1342
1344
|
|
1343
1345
|
VariableDeclaration(node) {
|
1344
|
-
const variableIndent =
|
1346
|
+
const variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind)
|
1347
|
+
? options.VariableDeclarator[node.kind]
|
1348
|
+
: DEFAULT_VARIABLE_INDENT;
|
1345
1349
|
|
1346
1350
|
if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) {
|
1347
1351
|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
62
62
|
above = !options.position || options.position === "above";
|
63
63
|
ignorePattern = options.ignorePattern;
|
64
64
|
|
65
|
-
if (
|
65
|
+
if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
|
66
66
|
applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
|
67
67
|
} else {
|
68
68
|
applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
|
package/lib/rules/max-depth.js
CHANGED
@@ -54,10 +54,10 @@ module.exports = {
|
|
54
54
|
option = context.options[0];
|
55
55
|
let maxDepth = 4;
|
56
56
|
|
57
|
-
if (typeof option === "object" &&
|
57
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
58
58
|
maxDepth = option.maximum;
|
59
59
|
}
|
60
|
-
if (typeof option === "object" &&
|
60
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
61
61
|
maxDepth = option.max;
|
62
62
|
}
|
63
63
|
if (typeof option === "number") {
|
package/lib/rules/max-lines.js
CHANGED
@@ -56,7 +56,7 @@ module.exports = {
|
|
56
56
|
const option = context.options[0];
|
57
57
|
let max = 300;
|
58
58
|
|
59
|
-
if (typeof option === "object" &&
|
59
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
60
60
|
max = option.max;
|
61
61
|
}
|
62
62
|
|
@@ -52,10 +52,10 @@ module.exports = {
|
|
52
52
|
const option = context.options[0];
|
53
53
|
let THRESHOLD = 10;
|
54
54
|
|
55
|
-
if (typeof option === "object" &&
|
55
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
56
56
|
THRESHOLD = option.maximum;
|
57
57
|
}
|
58
|
-
if (typeof option === "object" &&
|
58
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
59
59
|
THRESHOLD = option.max;
|
60
60
|
}
|
61
61
|
if (typeof option === "number") {
|
package/lib/rules/max-params.js
CHANGED
@@ -57,10 +57,10 @@ module.exports = {
|
|
57
57
|
const option = context.options[0];
|
58
58
|
let numParams = 3;
|
59
59
|
|
60
|
-
if (typeof option === "object" &&
|
60
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
61
61
|
numParams = option.maximum;
|
62
62
|
}
|
63
|
-
if (typeof option === "object" &&
|
63
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
64
64
|
numParams = option.max;
|
65
65
|
}
|
66
66
|
if (typeof option === "number") {
|
@@ -73,10 +73,10 @@ module.exports = {
|
|
73
73
|
topLevelFunctions = [];
|
74
74
|
let maxStatements = 10;
|
75
75
|
|
76
|
-
if (typeof option === "object" &&
|
76
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
77
77
|
maxStatements = option.maximum;
|
78
78
|
}
|
79
|
-
if (typeof option === "object" &&
|
79
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
80
80
|
maxStatements = option.max;
|
81
81
|
}
|
82
82
|
if (typeof option === "number") {
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
83
83
|
const options = Array.isArray(context.options) ? context.options : [];
|
84
84
|
const isPathAndPatternsObject =
|
85
85
|
typeof options[0] === "object" &&
|
86
|
-
(options[0]
|
86
|
+
(Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
|
87
87
|
|
88
88
|
const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
|
89
89
|
const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
|
@@ -77,7 +77,7 @@ module.exports = {
|
|
77
77
|
const options = Array.isArray(context.options) ? context.options : [];
|
78
78
|
const isPathAndPatternsObject =
|
79
79
|
typeof options[0] === "object" &&
|
80
|
-
(options[0]
|
80
|
+
(Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
|
81
81
|
|
82
82
|
const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
|
83
83
|
const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
|
package/lib/rules/one-var.js
CHANGED
@@ -74,19 +74,19 @@ module.exports = {
|
|
74
74
|
options.let = { uninitialized: mode, initialized: mode };
|
75
75
|
options.const = { uninitialized: mode, initialized: mode };
|
76
76
|
} else if (typeof mode === "object") { // options configuration is an object
|
77
|
-
if (
|
77
|
+
if (Object.prototype.hasOwnProperty.call(mode, "separateRequires")) {
|
78
78
|
options.separateRequires = !!mode.separateRequires;
|
79
79
|
}
|
80
|
-
if (
|
80
|
+
if (Object.prototype.hasOwnProperty.call(mode, "var")) {
|
81
81
|
options.var = { uninitialized: mode.var, initialized: mode.var };
|
82
82
|
}
|
83
|
-
if (
|
83
|
+
if (Object.prototype.hasOwnProperty.call(mode, "let")) {
|
84
84
|
options.let = { uninitialized: mode.let, initialized: mode.let };
|
85
85
|
}
|
86
|
-
if (
|
86
|
+
if (Object.prototype.hasOwnProperty.call(mode, "const")) {
|
87
87
|
options.const = { uninitialized: mode.const, initialized: mode.const };
|
88
88
|
}
|
89
|
-
if (
|
89
|
+
if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
|
90
90
|
if (!options.var) {
|
91
91
|
options.var = {};
|
92
92
|
}
|
@@ -100,7 +100,7 @@ module.exports = {
|
|
100
100
|
options.let.uninitialized = mode.uninitialized;
|
101
101
|
options.const.uninitialized = mode.uninitialized;
|
102
102
|
}
|
103
|
-
if (
|
103
|
+
if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
|
104
104
|
if (!options.var) {
|
105
105
|
options.var = {};
|
106
106
|
}
|
@@ -58,13 +58,13 @@ module.exports = {
|
|
58
58
|
options.switches = shouldHavePadding;
|
59
59
|
options.classes = shouldHavePadding;
|
60
60
|
} else {
|
61
|
-
if (
|
61
|
+
if (Object.prototype.hasOwnProperty.call(config, "blocks")) {
|
62
62
|
options.blocks = config.blocks === "always";
|
63
63
|
}
|
64
|
-
if (
|
64
|
+
if (Object.prototype.hasOwnProperty.call(config, "switches")) {
|
65
65
|
options.switches = config.switches === "always";
|
66
66
|
}
|
67
|
-
if (
|
67
|
+
if (Object.prototype.hasOwnProperty.call(config, "classes")) {
|
68
68
|
options.classes = config.classes === "always";
|
69
69
|
}
|
70
70
|
}
|
@@ -225,7 +225,7 @@ module.exports = {
|
|
225
225
|
|
226
226
|
const rule = {};
|
227
227
|
|
228
|
-
if (
|
228
|
+
if (Object.prototype.hasOwnProperty.call(options, "switches")) {
|
229
229
|
rule.SwitchStatement = function(node) {
|
230
230
|
if (node.cases.length === 0) {
|
231
231
|
return;
|
@@ -234,7 +234,7 @@ module.exports = {
|
|
234
234
|
};
|
235
235
|
}
|
236
236
|
|
237
|
-
if (
|
237
|
+
if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
|
238
238
|
rule.BlockStatement = function(node) {
|
239
239
|
if (node.body.length === 0) {
|
240
240
|
return;
|
@@ -243,7 +243,7 @@ module.exports = {
|
|
243
243
|
};
|
244
244
|
}
|
245
245
|
|
246
|
-
if (
|
246
|
+
if (Object.prototype.hasOwnProperty.call(options, "classes")) {
|
247
247
|
rule.ClassBody = function(node) {
|
248
248
|
if (node.body.length === 0) {
|
249
249
|
return;
|
@@ -98,7 +98,7 @@ module.exports = {
|
|
98
98
|
CallExpression(node) {
|
99
99
|
const methodName = (node.callee.property || {}).name;
|
100
100
|
const isReflectCall = (node.callee.object || {}).name === "Reflect";
|
101
|
-
const hasReflectSubsitute =
|
101
|
+
const hasReflectSubsitute = Object.prototype.hasOwnProperty.call(reflectSubsitutes, methodName);
|
102
102
|
const userConfiguredException = exceptions.indexOf(methodName) !== -1;
|
103
103
|
|
104
104
|
if (hasReflectSubsitute && !isReflectCall && !userConfiguredException) {
|
@@ -46,10 +46,10 @@ module.exports = {
|
|
46
46
|
requireSpaceAfter = true;
|
47
47
|
|
48
48
|
if (typeof config === "object") {
|
49
|
-
if (
|
49
|
+
if (Object.prototype.hasOwnProperty.call(config, "before")) {
|
50
50
|
requireSpaceBefore = config.before;
|
51
51
|
}
|
52
|
-
if (
|
52
|
+
if (Object.prototype.hasOwnProperty.call(config, "after")) {
|
53
53
|
requireSpaceAfter = config.after;
|
54
54
|
}
|
55
55
|
}
|
@@ -72,7 +72,7 @@ module.exports = {
|
|
72
72
|
* @returns {boolean} Whether or not an override has been provided for the operator
|
73
73
|
*/
|
74
74
|
function overrideExistsForOperator(operator) {
|
75
|
-
return options.overrides &&
|
75
|
+
return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
|
76
76
|
}
|
77
77
|
|
78
78
|
/**
|
package/lib/rules/valid-jsdoc.js
CHANGED
@@ -322,7 +322,7 @@ module.exports = {
|
|
322
322
|
}
|
323
323
|
|
324
324
|
// check tag preferences
|
325
|
-
if (
|
325
|
+
if (Object.prototype.hasOwnProperty.call(prefer, tag.title) && tag.title !== prefer[tag.title]) {
|
326
326
|
const entireTagRange = getAbsoluteRange(jsdocNode, tag);
|
327
327
|
|
328
328
|
context.report({
|
@@ -533,19 +533,19 @@ class RuleTester {
|
|
533
533
|
assert.strictEqual(message.nodeType, error.type, `Error type should be ${error.type}, found ${message.nodeType}`);
|
534
534
|
}
|
535
535
|
|
536
|
-
if (
|
536
|
+
if (Object.prototype.hasOwnProperty.call(error, "line")) {
|
537
537
|
assert.strictEqual(message.line, error.line, `Error line should be ${error.line}`);
|
538
538
|
}
|
539
539
|
|
540
|
-
if (
|
540
|
+
if (Object.prototype.hasOwnProperty.call(error, "column")) {
|
541
541
|
assert.strictEqual(message.column, error.column, `Error column should be ${error.column}`);
|
542
542
|
}
|
543
543
|
|
544
|
-
if (
|
544
|
+
if (Object.prototype.hasOwnProperty.call(error, "endLine")) {
|
545
545
|
assert.strictEqual(message.endLine, error.endLine, `Error endLine should be ${error.endLine}`);
|
546
546
|
}
|
547
547
|
|
548
|
-
if (
|
548
|
+
if (Object.prototype.hasOwnProperty.call(error, "endColumn")) {
|
549
549
|
assert.strictEqual(message.endColumn, error.endColumn, `Error endColumn should be ${error.endColumn}`);
|
550
550
|
}
|
551
551
|
} else {
|
@@ -556,7 +556,7 @@ class RuleTester {
|
|
556
556
|
}
|
557
557
|
}
|
558
558
|
|
559
|
-
if (
|
559
|
+
if (Object.prototype.hasOwnProperty.call(item, "output")) {
|
560
560
|
if (item.output === null) {
|
561
561
|
assert.strictEqual(
|
562
562
|
messages.filter(message => message.fix).length,
|
package/lib/util/file-finder.js
CHANGED
@@ -89,7 +89,7 @@ class FileFinder {
|
|
89
89
|
? path.resolve(this.cwd, relativeDirectory)
|
90
90
|
: this.cwd;
|
91
91
|
|
92
|
-
if (
|
92
|
+
if (Object.prototype.hasOwnProperty.call(cache, initialDirectory)) {
|
93
93
|
yield* cache[initialDirectory];
|
94
94
|
return; // to avoid doing the normal loop afterwards
|
95
95
|
}
|
@@ -130,7 +130,7 @@ class FileFinder {
|
|
130
130
|
return;
|
131
131
|
}
|
132
132
|
|
133
|
-
} while (!
|
133
|
+
} while (!Object.prototype.hasOwnProperty.call(cache, directory));
|
134
134
|
|
135
135
|
// Add what has been cached previously to the cache of each directory searched.
|
136
136
|
for (let i = 0; i < searched; i++) {
|
@@ -109,7 +109,7 @@ class LintResultCache {
|
|
109
109
|
* @returns {void}
|
110
110
|
*/
|
111
111
|
setCachedLintResults(filePath, result) {
|
112
|
-
if (result &&
|
112
|
+
if (result && Object.prototype.hasOwnProperty.call(result, "output")) {
|
113
113
|
return;
|
114
114
|
}
|
115
115
|
|
@@ -125,7 +125,7 @@ class LintResultCache {
|
|
125
125
|
* In `getCachedLintResults`, if source is explicitly null, we will
|
126
126
|
* read the file from the filesystem to set the value again.
|
127
127
|
*/
|
128
|
-
if (
|
128
|
+
if (Object.prototype.hasOwnProperty.call(resultToSerialize, "source")) {
|
129
129
|
resultToSerialize.source = null;
|
130
130
|
}
|
131
131
|
|
@@ -107,7 +107,7 @@ SourceCodeFixer.applyFixes = function(sourceText, messages, shouldFix) {
|
|
107
107
|
}
|
108
108
|
|
109
109
|
messages.forEach(problem => {
|
110
|
-
if (
|
110
|
+
if (Object.prototype.hasOwnProperty.call(problem, "fix")) {
|
111
111
|
fixes.push(problem);
|
112
112
|
} else {
|
113
113
|
remainingMessages.push(problem);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.4.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -69,7 +69,6 @@
|
|
69
69
|
"regexpp": "^2.0.0",
|
70
70
|
"require-uncached": "^1.0.3",
|
71
71
|
"semver": "^5.5.0",
|
72
|
-
"string.prototype.matchall": "^2.0.0",
|
73
72
|
"strip-ansi": "^4.0.0",
|
74
73
|
"strip-json-comments": "^2.0.1",
|
75
74
|
"table": "^4.0.3",
|
package/lib/rules/.eslintrc.yml
DELETED