eslint 6.0.0-rc.0 → 6.2.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 +90 -0
- package/README.md +4 -13
- package/bin/eslint.js +4 -1
- package/conf/config-schema.js +1 -0
- package/conf/environments.js +72 -15
- package/lib/cli-engine/cascading-config-array-factory.js +15 -3
- package/lib/cli-engine/cli-engine.js +13 -3
- package/lib/cli-engine/config-array/config-array.js +8 -2
- package/lib/cli-engine/config-array/extracted-config.js +16 -1
- package/lib/cli-engine/config-array-factory.js +9 -6
- package/lib/cli-engine/file-enumerator.js +5 -13
- package/lib/init/config-initializer.js +19 -9
- package/lib/init/npm-utils.js +2 -2
- package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -0
- package/lib/linter/linter.js +49 -16
- package/lib/rule-tester/rule-tester.js +15 -3
- package/lib/rules/accessor-pairs.js +195 -35
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/class-methods-use-this.js +10 -3
- package/lib/rules/dot-location.js +21 -17
- package/lib/rules/dot-notation.js +6 -2
- package/lib/rules/func-call-spacing.js +30 -20
- package/lib/rules/func-names.js +4 -0
- package/lib/rules/function-call-argument-newline.js +120 -0
- package/lib/rules/function-paren-newline.js +34 -22
- package/lib/rules/indent.js +13 -2
- package/lib/rules/index.js +1 -0
- package/lib/rules/max-len.js +7 -0
- package/lib/rules/multiline-comment-style.js +2 -1
- package/lib/rules/new-cap.js +2 -1
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-duplicate-case.js +10 -8
- package/lib/rules/no-else-return.js +127 -0
- package/lib/rules/no-extra-bind.js +1 -0
- package/lib/rules/no-extra-boolean-cast.js +44 -5
- package/lib/rules/no-extra-parens.js +295 -39
- package/lib/rules/no-mixed-operators.js +48 -13
- package/lib/rules/no-param-reassign.js +12 -1
- package/lib/rules/no-restricted-syntax.js +2 -2
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/no-var.js +14 -1
- package/lib/rules/prefer-const.js +9 -3
- package/lib/rules/prefer-template.js +1 -10
- package/lib/rules/require-atomic-updates.js +63 -84
- package/lib/rules/sort-keys.js +11 -3
- package/lib/rules/utils/ast-utils.js +45 -3
- package/lib/rules/yoda.js +1 -1
- package/lib/{cli-engine → shared}/naming.js +0 -0
- package/lib/shared/types.js +2 -0
- package/messages/extend-config-missing.txt +2 -0
- package/messages/print-config-with-directory-path.txt +2 -0
- package/package.json +27 -30
@@ -67,7 +67,8 @@ module.exports = {
|
|
67
67
|
let node = reference.identifier;
|
68
68
|
let parent = node.parent;
|
69
69
|
|
70
|
-
while (parent && !stopNodePattern.test(parent.type)
|
70
|
+
while (parent && (!stopNodePattern.test(parent.type) ||
|
71
|
+
parent.type === "ForInStatement" || parent.type === "ForOfStatement")) {
|
71
72
|
switch (parent.type) {
|
72
73
|
|
73
74
|
// e.g. foo.a = 0;
|
@@ -85,6 +86,16 @@ module.exports = {
|
|
85
86
|
}
|
86
87
|
break;
|
87
88
|
|
89
|
+
// e.g. for (foo.a in b) {}
|
90
|
+
case "ForInStatement":
|
91
|
+
case "ForOfStatement":
|
92
|
+
if (parent.left === node) {
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
|
96
|
+
// this is a stop node for parent.right and parent.body
|
97
|
+
return false;
|
98
|
+
|
88
99
|
// EXCLUDES: e.g. cache.get(foo.a).b = 0;
|
89
100
|
case "CallExpression":
|
90
101
|
if (parent.callee !== node) {
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
21
21
|
|
22
22
|
schema: {
|
23
23
|
type: "array",
|
24
|
-
items:
|
24
|
+
items: {
|
25
25
|
oneOf: [
|
26
26
|
{
|
27
27
|
type: "string"
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
36
36
|
additionalProperties: false
|
37
37
|
}
|
38
38
|
]
|
39
|
-
}
|
39
|
+
},
|
40
40
|
uniqueItems: true,
|
41
41
|
minItems: 0
|
42
42
|
}
|
@@ -507,7 +507,7 @@ module.exports = {
|
|
507
507
|
const childScopes = scope.childScopes;
|
508
508
|
let i, l;
|
509
509
|
|
510
|
-
if (scope.type !== "
|
510
|
+
if (scope.type !== "global" || config.vars === "all") {
|
511
511
|
for (i = 0, l = variables.length; i < l; ++i) {
|
512
512
|
const variable = variables[i];
|
513
513
|
|
package/lib/rules/no-var.js
CHANGED
@@ -174,6 +174,17 @@ function hasReferenceInTDZ(node) {
|
|
174
174
|
};
|
175
175
|
}
|
176
176
|
|
177
|
+
/**
|
178
|
+
* Checks whether a given variable has name that is allowed for 'var' declarations,
|
179
|
+
* but disallowed for `let` declarations.
|
180
|
+
*
|
181
|
+
* @param {eslint-scope.Variable} variable The variable to check.
|
182
|
+
* @returns {boolean} `true` if the variable has a disallowed name.
|
183
|
+
*/
|
184
|
+
function hasNameDisallowedForLetDeclarations(variable) {
|
185
|
+
return variable.name === "let";
|
186
|
+
}
|
187
|
+
|
177
188
|
//------------------------------------------------------------------------------
|
178
189
|
// Rule Definition
|
179
190
|
//------------------------------------------------------------------------------
|
@@ -223,6 +234,7 @@ module.exports = {
|
|
223
234
|
* - A variable might be used before it is assigned within a loop.
|
224
235
|
* - A variable might be used in TDZ.
|
225
236
|
* - A variable is declared in statement position (e.g. a single-line `IfStatement`)
|
237
|
+
* - A variable has name that is disallowed for `let` declarations.
|
226
238
|
*
|
227
239
|
* ## A variable is declared on a SwitchCase node.
|
228
240
|
*
|
@@ -271,7 +283,8 @@ module.exports = {
|
|
271
283
|
node.declarations.some(hasSelfReferenceInTDZ) ||
|
272
284
|
variables.some(isGlobal) ||
|
273
285
|
variables.some(isRedeclared) ||
|
274
|
-
variables.some(isUsedFromOutsideOf(scopeNode))
|
286
|
+
variables.some(isUsedFromOutsideOf(scopeNode)) ||
|
287
|
+
variables.some(hasNameDisallowedForLetDeclarations)
|
275
288
|
) {
|
276
289
|
return false;
|
277
290
|
}
|
@@ -420,8 +420,9 @@ module.exports = {
|
|
420
420
|
|
421
421
|
let shouldFix = varDeclParent &&
|
422
422
|
|
423
|
-
// Don't do a fix unless the
|
424
|
-
(varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" ||
|
423
|
+
// Don't do a fix unless all variables in the declarations are initialized (or it's in a for-in or for-of loop)
|
424
|
+
(varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" ||
|
425
|
+
varDeclParent.declarations.every(declaration => declaration.init)) &&
|
425
426
|
|
426
427
|
/*
|
427
428
|
* If options.destructuring is "all", then this warning will not occur unless
|
@@ -450,7 +451,12 @@ module.exports = {
|
|
450
451
|
node,
|
451
452
|
messageId: "useConst",
|
452
453
|
data: node,
|
453
|
-
fix: shouldFix
|
454
|
+
fix: shouldFix
|
455
|
+
? fixer => fixer.replaceText(
|
456
|
+
sourceCode.getFirstToken(varDeclParent, t => t.value === varDeclParent.kind),
|
457
|
+
"const"
|
458
|
+
)
|
459
|
+
: null
|
454
460
|
});
|
455
461
|
});
|
456
462
|
}
|
@@ -52,16 +52,7 @@ function isOctalEscapeSequence(node) {
|
|
52
52
|
return false;
|
53
53
|
}
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
if (match) {
|
58
|
-
|
59
|
-
// \0 is actually not considered an octal
|
60
|
-
if (match[2] !== "0" || typeof match[3] !== "undefined") {
|
61
|
-
return true;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
return false;
|
55
|
+
return astUtils.hasOctalEscapeSequence(node.raw);
|
65
56
|
}
|
66
57
|
|
67
58
|
/**
|
@@ -24,12 +24,51 @@ function createReferenceMap(scope, outReferenceMap = new Map()) {
|
|
24
24
|
return outReferenceMap;
|
25
25
|
}
|
26
26
|
|
27
|
+
/**
|
28
|
+
* Get `reference.writeExpr` of a given reference.
|
29
|
+
* If it's the read reference of MemberExpression in LHS, returns RHS in order to address `a.b = await a`
|
30
|
+
* @param {escope.Reference} reference The reference to get.
|
31
|
+
* @returns {Expression|null} The `reference.writeExpr`.
|
32
|
+
*/
|
33
|
+
function getWriteExpr(reference) {
|
34
|
+
if (reference.writeExpr) {
|
35
|
+
return reference.writeExpr;
|
36
|
+
}
|
37
|
+
let node = reference.identifier;
|
38
|
+
|
39
|
+
while (node) {
|
40
|
+
const t = node.parent.type;
|
41
|
+
|
42
|
+
if (t === "AssignmentExpression" && node.parent.left === node) {
|
43
|
+
return node.parent.right;
|
44
|
+
}
|
45
|
+
if (t === "MemberExpression" && node.parent.object === node) {
|
46
|
+
node = node.parent;
|
47
|
+
continue;
|
48
|
+
}
|
49
|
+
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
|
53
|
+
return null;
|
54
|
+
}
|
55
|
+
|
27
56
|
/**
|
28
57
|
* Checks if an expression is a variable that can only be observed within the given function.
|
29
|
-
* @param {
|
58
|
+
* @param {Variable|null} variable The variable to check
|
59
|
+
* @param {boolean} isMemberAccess If `true` then this is a member access.
|
30
60
|
* @returns {boolean} `true` if the variable is local to the given function, and is never referenced in a closure.
|
31
61
|
*/
|
32
|
-
function isLocalVariableWithoutEscape(variable) {
|
62
|
+
function isLocalVariableWithoutEscape(variable, isMemberAccess) {
|
63
|
+
if (!variable) {
|
64
|
+
return false; // A global variable which was not defined.
|
65
|
+
}
|
66
|
+
|
67
|
+
// If the reference is a property access and the variable is a parameter, it handles the variable is not local.
|
68
|
+
if (isMemberAccess && variable.defs.some(d => d.type === "Parameter")) {
|
69
|
+
return false;
|
70
|
+
}
|
71
|
+
|
33
72
|
const functionScope = variable.scope.variableScope;
|
34
73
|
|
35
74
|
return variable.references.every(reference =>
|
@@ -47,52 +86,49 @@ class SegmentInfo {
|
|
47
86
|
* @returns {void}
|
48
87
|
*/
|
49
88
|
initialize(segment) {
|
50
|
-
const
|
51
|
-
const
|
89
|
+
const outdatedReadVariableNames = new Set();
|
90
|
+
const freshReadVariableNames = new Set();
|
52
91
|
|
53
92
|
for (const prevSegment of segment.prevSegments) {
|
54
93
|
const info = this.info.get(prevSegment);
|
55
94
|
|
56
95
|
if (info) {
|
57
|
-
info.
|
58
|
-
info.
|
96
|
+
info.outdatedReadVariableNames.forEach(Set.prototype.add, outdatedReadVariableNames);
|
97
|
+
info.freshReadVariableNames.forEach(Set.prototype.add, freshReadVariableNames);
|
59
98
|
}
|
60
99
|
}
|
61
100
|
|
62
|
-
this.info.set(segment, {
|
101
|
+
this.info.set(segment, { outdatedReadVariableNames, freshReadVariableNames });
|
63
102
|
}
|
64
103
|
|
65
104
|
/**
|
66
105
|
* Mark a given variable as read on given segments.
|
67
106
|
* @param {PathSegment[]} segments The segments that it read the variable on.
|
68
|
-
* @param {
|
107
|
+
* @param {string} variableName The variable name to be read.
|
69
108
|
* @returns {void}
|
70
109
|
*/
|
71
|
-
markAsRead(segments,
|
110
|
+
markAsRead(segments, variableName) {
|
72
111
|
for (const segment of segments) {
|
73
112
|
const info = this.info.get(segment);
|
74
113
|
|
75
114
|
if (info) {
|
76
|
-
info.
|
115
|
+
info.freshReadVariableNames.add(variableName);
|
77
116
|
}
|
78
117
|
}
|
79
118
|
}
|
80
119
|
|
81
120
|
/**
|
82
|
-
* Move `
|
121
|
+
* Move `freshReadVariableNames` to `outdatedReadVariableNames`.
|
83
122
|
* @param {PathSegment[]} segments The segments to process.
|
84
123
|
* @returns {void}
|
85
124
|
*/
|
86
125
|
makeOutdated(segments) {
|
87
|
-
const vars = new Set();
|
88
|
-
|
89
126
|
for (const segment of segments) {
|
90
127
|
const info = this.info.get(segment);
|
91
128
|
|
92
129
|
if (info) {
|
93
|
-
info.
|
94
|
-
info.
|
95
|
-
info.freshReadVariables.clear();
|
130
|
+
info.freshReadVariableNames.forEach(Set.prototype.add, info.outdatedReadVariableNames);
|
131
|
+
info.freshReadVariableNames.clear();
|
96
132
|
}
|
97
133
|
}
|
98
134
|
}
|
@@ -100,14 +136,14 @@ class SegmentInfo {
|
|
100
136
|
/**
|
101
137
|
* Check if a given variable is outdated on the current segments.
|
102
138
|
* @param {PathSegment[]} segments The current segments.
|
103
|
-
* @param {
|
139
|
+
* @param {string} variableName The variable name to check.
|
104
140
|
* @returns {boolean} `true` if the variable is outdated on the segments.
|
105
141
|
*/
|
106
|
-
isOutdated(segments,
|
142
|
+
isOutdated(segments, variableName) {
|
107
143
|
for (const segment of segments) {
|
108
144
|
const info = this.info.get(segment);
|
109
145
|
|
110
|
-
if (info && info.
|
146
|
+
if (info && info.outdatedReadVariableNames.has(variableName)) {
|
111
147
|
return true;
|
112
148
|
}
|
113
149
|
}
|
@@ -140,69 +176,10 @@ module.exports = {
|
|
140
176
|
|
141
177
|
create(context) {
|
142
178
|
const sourceCode = context.getSourceCode();
|
143
|
-
const globalScope = context.getScope();
|
144
|
-
const dummyVariables = new Map();
|
145
179
|
const assignmentReferences = new Map();
|
146
180
|
const segmentInfo = new SegmentInfo();
|
147
181
|
let stack = null;
|
148
182
|
|
149
|
-
/**
|
150
|
-
* Get the variable of a given reference.
|
151
|
-
* If it's not defined, returns a dummy object.
|
152
|
-
* @param {escope.Reference} reference The reference to get.
|
153
|
-
* @returns {escope.Variable} The variable of the reference.
|
154
|
-
*/
|
155
|
-
function getVariable(reference) {
|
156
|
-
if (reference.resolved) {
|
157
|
-
return reference.resolved;
|
158
|
-
}
|
159
|
-
|
160
|
-
// Get or create a dummy.
|
161
|
-
const name = reference.identifier.name;
|
162
|
-
let variable = dummyVariables.get(name);
|
163
|
-
|
164
|
-
if (!variable) {
|
165
|
-
variable = {
|
166
|
-
name,
|
167
|
-
scope: globalScope,
|
168
|
-
references: []
|
169
|
-
};
|
170
|
-
dummyVariables.set(name, variable);
|
171
|
-
}
|
172
|
-
variable.references.push(reference);
|
173
|
-
|
174
|
-
return variable;
|
175
|
-
}
|
176
|
-
|
177
|
-
/**
|
178
|
-
* Get `reference.writeExpr` of a given reference.
|
179
|
-
* If it's the read reference of MemberExpression in LHS, returns RHS in order to address `a.b = await a`
|
180
|
-
* @param {escope.Reference} reference The reference to get.
|
181
|
-
* @returns {Expression|null} The `reference.writeExpr`.
|
182
|
-
*/
|
183
|
-
function getWriteExpr(reference) {
|
184
|
-
if (reference.writeExpr) {
|
185
|
-
return reference.writeExpr;
|
186
|
-
}
|
187
|
-
let node = reference.identifier;
|
188
|
-
|
189
|
-
while (node) {
|
190
|
-
const t = node.parent.type;
|
191
|
-
|
192
|
-
if (t === "AssignmentExpression" && node.parent.left === node) {
|
193
|
-
return node.parent.right;
|
194
|
-
}
|
195
|
-
if (t === "MemberExpression" && node.parent.object === node) {
|
196
|
-
node = node.parent;
|
197
|
-
continue;
|
198
|
-
}
|
199
|
-
|
200
|
-
break;
|
201
|
-
}
|
202
|
-
|
203
|
-
return null;
|
204
|
-
}
|
205
|
-
|
206
183
|
return {
|
207
184
|
onCodePathStart(codePath) {
|
208
185
|
const scope = context.getScope();
|
@@ -234,12 +211,14 @@ module.exports = {
|
|
234
211
|
if (!reference) {
|
235
212
|
return;
|
236
213
|
}
|
237
|
-
const
|
214
|
+
const name = reference.identifier.name;
|
215
|
+
const variable = reference.resolved;
|
238
216
|
const writeExpr = getWriteExpr(reference);
|
217
|
+
const isMemberAccess = reference.identifier.parent.type === "MemberExpression";
|
239
218
|
|
240
219
|
// Add a fresh read variable.
|
241
220
|
if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) {
|
242
|
-
segmentInfo.markAsRead(codePath.currentSegments,
|
221
|
+
segmentInfo.markAsRead(codePath.currentSegments, name);
|
243
222
|
}
|
244
223
|
|
245
224
|
/*
|
@@ -248,7 +227,7 @@ module.exports = {
|
|
248
227
|
*/
|
249
228
|
if (writeExpr &&
|
250
229
|
writeExpr.parent.right === writeExpr && // ← exclude variable declarations.
|
251
|
-
!isLocalVariableWithoutEscape(variable)
|
230
|
+
!isLocalVariableWithoutEscape(variable, isMemberAccess)
|
252
231
|
) {
|
253
232
|
let refs = assignmentReferences.get(writeExpr);
|
254
233
|
|
@@ -263,7 +242,7 @@ module.exports = {
|
|
263
242
|
|
264
243
|
/*
|
265
244
|
* Verify assignments.
|
266
|
-
* If the reference exists in `
|
245
|
+
* If the reference exists in `outdatedReadVariableNames` list, report it.
|
267
246
|
*/
|
268
247
|
":expression:exit"(node) {
|
269
248
|
const { codePath, referenceMap } = stack;
|
@@ -285,9 +264,9 @@ module.exports = {
|
|
285
264
|
assignmentReferences.delete(node);
|
286
265
|
|
287
266
|
for (const reference of references) {
|
288
|
-
const
|
267
|
+
const name = reference.identifier.name;
|
289
268
|
|
290
|
-
if (segmentInfo.isOutdated(codePath.currentSegments,
|
269
|
+
if (segmentInfo.isOutdated(codePath.currentSegments, name)) {
|
291
270
|
context.report({
|
292
271
|
node: node.parent,
|
293
272
|
messageId: "nonAtomicUpdate",
|
package/lib/rules/sort-keys.js
CHANGED
@@ -29,7 +29,13 @@ const astUtils = require("./utils/ast-utils"),
|
|
29
29
|
* @private
|
30
30
|
*/
|
31
31
|
function getPropertyName(node) {
|
32
|
-
|
32
|
+
const staticName = astUtils.getStaticPropertyName(node);
|
33
|
+
|
34
|
+
if (staticName !== null) {
|
35
|
+
return staticName;
|
36
|
+
}
|
37
|
+
|
38
|
+
return node.key.name || null;
|
33
39
|
}
|
34
40
|
|
35
41
|
/**
|
@@ -151,9 +157,11 @@ module.exports = {
|
|
151
157
|
const numKeys = stack.numKeys;
|
152
158
|
const thisName = getPropertyName(node);
|
153
159
|
|
154
|
-
|
160
|
+
if (thisName !== null) {
|
161
|
+
stack.prevName = thisName;
|
162
|
+
}
|
155
163
|
|
156
|
-
if (
|
164
|
+
if (prevName === null || thisName === null || numKeys < minKeys) {
|
157
165
|
return;
|
158
166
|
}
|
159
167
|
|
@@ -37,6 +37,9 @@ const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
|
|
37
37
|
// A set of node types that can contain a list of statements
|
38
38
|
const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
|
39
39
|
|
40
|
+
const DECIMAL_INTEGER_PATTERN = /^(0|[1-9]\d*)$/u;
|
41
|
+
const OCTAL_ESCAPE_PATTERN = /^(?:[^\\]|\\[^0-7]|\\0(?![0-9]))*\\(?:[1-7]|0[0-9])/u;
|
42
|
+
|
40
43
|
/**
|
41
44
|
* Checks reference if is non initializer and writable.
|
42
45
|
* @param {Reference} reference - A reference to check.
|
@@ -283,6 +286,16 @@ function isCommaToken(token) {
|
|
283
286
|
return token.value === "," && token.type === "Punctuator";
|
284
287
|
}
|
285
288
|
|
289
|
+
/**
|
290
|
+
* Checks if the given token is a dot token or not.
|
291
|
+
*
|
292
|
+
* @param {Token} token - The token to check.
|
293
|
+
* @returns {boolean} `true` if the token is a dot token.
|
294
|
+
*/
|
295
|
+
function isDotToken(token) {
|
296
|
+
return token.value === "." && token.type === "Punctuator";
|
297
|
+
}
|
298
|
+
|
286
299
|
/**
|
287
300
|
* Checks if the given token is a semicolon token or not.
|
288
301
|
*
|
@@ -462,12 +475,14 @@ module.exports = {
|
|
462
475
|
isColonToken,
|
463
476
|
isCommaToken,
|
464
477
|
isCommentToken,
|
478
|
+
isDotToken,
|
465
479
|
isKeywordToken,
|
466
480
|
isNotClosingBraceToken: negate(isClosingBraceToken),
|
467
481
|
isNotClosingBracketToken: negate(isClosingBracketToken),
|
468
482
|
isNotClosingParenToken: negate(isClosingParenToken),
|
469
483
|
isNotColonToken: negate(isColonToken),
|
470
484
|
isNotCommaToken: negate(isCommaToken),
|
485
|
+
isNotDotToken: negate(isDotToken),
|
471
486
|
isNotOpeningBraceToken: negate(isOpeningBraceToken),
|
472
487
|
isNotOpeningBracketToken: negate(isOpeningBracketToken),
|
473
488
|
isNotOpeningParenToken: negate(isOpeningParenToken),
|
@@ -833,6 +848,7 @@ module.exports = {
|
|
833
848
|
return 17;
|
834
849
|
|
835
850
|
case "CallExpression":
|
851
|
+
case "ImportExpression":
|
836
852
|
return 18;
|
837
853
|
|
838
854
|
case "NewExpression":
|
@@ -988,7 +1004,18 @@ module.exports = {
|
|
988
1004
|
* '5' // false
|
989
1005
|
*/
|
990
1006
|
isDecimalInteger(node) {
|
991
|
-
return node.type === "Literal" && typeof node.value === "number" &&
|
1007
|
+
return node.type === "Literal" && typeof node.value === "number" &&
|
1008
|
+
DECIMAL_INTEGER_PATTERN.test(node.raw);
|
1009
|
+
},
|
1010
|
+
|
1011
|
+
/**
|
1012
|
+
* Determines whether this token is a decimal integer numeric token.
|
1013
|
+
* This is similar to isDecimalInteger(), but for tokens.
|
1014
|
+
* @param {Token} token - The token to check.
|
1015
|
+
* @returns {boolean} `true` if this token is a decimal integer.
|
1016
|
+
*/
|
1017
|
+
isDecimalIntegerNumericToken(token) {
|
1018
|
+
return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
|
992
1019
|
},
|
993
1020
|
|
994
1021
|
/**
|
@@ -1076,7 +1103,7 @@ module.exports = {
|
|
1076
1103
|
} else {
|
1077
1104
|
const name = module.exports.getStaticPropertyName(parent);
|
1078
1105
|
|
1079
|
-
if (name) {
|
1106
|
+
if (name !== null) {
|
1080
1107
|
tokens.push(`'${name}'`);
|
1081
1108
|
}
|
1082
1109
|
}
|
@@ -1276,7 +1303,7 @@ module.exports = {
|
|
1276
1303
|
* set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
|
1277
1304
|
* `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
|
1278
1305
|
*/
|
1279
|
-
return node.type === "Literal" && node.value === null && !node.regex;
|
1306
|
+
return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
|
1280
1307
|
},
|
1281
1308
|
|
1282
1309
|
/**
|
@@ -1348,5 +1375,20 @@ module.exports = {
|
|
1348
1375
|
"/*".length +
|
1349
1376
|
(match ? match.index + 1 : 0)
|
1350
1377
|
);
|
1378
|
+
},
|
1379
|
+
|
1380
|
+
/**
|
1381
|
+
* Determines whether the given raw string contains an octal escape sequence.
|
1382
|
+
*
|
1383
|
+
* "\1", "\2" ... "\7"
|
1384
|
+
* "\00", "\01" ... "\09"
|
1385
|
+
*
|
1386
|
+
* "\0", when not followed by a digit, is not an octal escape sequence.
|
1387
|
+
*
|
1388
|
+
* @param {string} rawString A string in its raw representation.
|
1389
|
+
* @returns {boolean} `true` if the string contains at least one octal escape sequence.
|
1390
|
+
*/
|
1391
|
+
hasOctalEscapeSequence(rawString) {
|
1392
|
+
return OCTAL_ESCAPE_PATTERN.test(rawString);
|
1351
1393
|
}
|
1352
1394
|
};
|
package/lib/rules/yoda.js
CHANGED
File without changes
|
package/lib/shared/types.js
CHANGED
@@ -30,6 +30,7 @@ module.exports = {};
|
|
30
30
|
* @property {Record<string, boolean>} [env] The environment settings.
|
31
31
|
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
32
32
|
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
33
|
+
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
33
34
|
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
34
35
|
* @property {string} [parser] The path to a parser or the package name of a parser.
|
35
36
|
* @property {ParserOptions} [parserOptions] The parser options.
|
@@ -47,6 +48,7 @@ module.exports = {};
|
|
47
48
|
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
48
49
|
* @property {string | string[]} files The glob pattarns for target files.
|
49
50
|
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
51
|
+
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
50
52
|
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
51
53
|
* @property {string} [parser] The path to a parser or the package name of a parser.
|
52
54
|
* @property {ParserOptions} [parserOptions] The parser options.
|
@@ -1,3 +1,5 @@
|
|
1
1
|
ESLint couldn't find the config "<%- configName %>" to extend from. Please check that the name of the config is correct.
|
2
2
|
|
3
|
+
The config "<%- configName %>" was referenced from the config file in "<%- importerName %>".
|
4
|
+
|
3
5
|
If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
|