eslint 5.14.1 → 5.15.3
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 +51 -0
- package/README.md +2 -2
- package/lib/built-in-rules-index.js +1 -0
- package/lib/cli-engine.js +2 -2
- package/lib/config/config-file.js +3 -3
- package/lib/config/config-initializer.js +1 -1
- package/lib/config/config-validator.js +13 -13
- package/lib/config/plugins.js +1 -1
- package/lib/formatters/codeframe.js +1 -1
- package/lib/formatters/stylish.js +2 -2
- package/lib/linter.js +23 -8
- package/lib/rules/array-bracket-newline.js +2 -4
- package/lib/rules/array-callback-return.js +2 -2
- package/lib/rules/array-element-newline.js +2 -4
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/camelcase.js +2 -2
- package/lib/rules/capitalized-comments.js +12 -17
- package/lib/rules/complexity.js +6 -5
- package/lib/rules/curly.js +1 -1
- package/lib/rules/default-case.js +2 -2
- package/lib/rules/dot-notation.js +2 -2
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/eqeqeq.js +1 -2
- package/lib/rules/func-call-spacing.js +3 -4
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-match.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +17 -172
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +2 -2
- package/lib/rules/init-declarations.js +1 -2
- package/lib/rules/jsx-quotes.js +2 -2
- package/lib/rules/key-spacing.js +28 -55
- package/lib/rules/keyword-spacing.js +7 -7
- package/lib/rules/line-comment-position.js +5 -7
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/max-depth.js +6 -5
- package/lib/rules/max-len.js +4 -4
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +4 -7
- package/lib/rules/max-nested-callbacks.js +6 -5
- package/lib/rules/max-params.js +6 -5
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +6 -5
- package/lib/rules/multiline-comment-style.js +9 -9
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-caller.js +1 -1
- package/lib/rules/no-dupe-keys.js +2 -2
- package/lib/rules/no-else-return.js +2 -2
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-extra-parens.js +11 -5
- package/lib/rules/no-fallthrough.js +2 -2
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-implied-eval.js +1 -1
- package/lib/rules/no-invalid-regexp.js +2 -2
- package/lib/rules/no-irregular-whitespace.js +3 -3
- package/lib/rules/no-lonely-if.js +1 -1
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-requires.js +3 -5
- package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
- package/lib/rules/no-octal-escape.js +1 -1
- package/lib/rules/no-octal.js +1 -1
- package/lib/rules/no-param-reassign.js +1 -1
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-tabs.js +2 -2
- package/lib/rules/no-template-curly-in-string.js +1 -1
- package/lib/rules/no-trailing-spaces.js +2 -2
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +5 -5
- package/lib/rules/no-unsafe-finally.js +3 -3
- package/lib/rules/no-unused-expressions.js +2 -2
- package/lib/rules/no-unused-vars.js +10 -14
- package/lib/rules/no-use-before-define.js +5 -5
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +6 -6
- package/lib/rules/object-curly-newline.js +4 -6
- package/lib/rules/object-shorthand.js +4 -8
- package/lib/rules/one-var.js +3 -6
- package/lib/rules/padding-line-between-statements.js +4 -3
- package/lib/rules/prefer-const.js +3 -3
- package/lib/rules/prefer-destructuring.js +7 -14
- package/lib/rules/prefer-named-capture-group.js +123 -0
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-template.js +3 -3
- package/lib/rules/quote-props.js +5 -10
- package/lib/rules/quotes.js +4 -6
- package/lib/rules/semi.js +7 -8
- package/lib/rules/space-before-function-paren.js +3 -6
- package/lib/rules/spaced-comment.js +4 -4
- package/lib/rules/template-curly-spacing.js +2 -2
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/valid-jsdoc.js +2 -2
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/yield-star-spacing.js +2 -2
- package/lib/rules/yoda.js +2 -2
- package/lib/testers/rule-tester.js +1 -1
- package/lib/util/ast-utils.js +12 -12
- package/lib/util/config-comment-parser.js +4 -4
- package/lib/util/glob-utils.js +15 -4
- package/lib/util/ignored-paths.js +4 -4
- package/lib/util/interpolate.js +1 -1
- package/lib/util/naming.js +6 -6
- package/lib/util/node-event-generator.js +1 -1
- package/lib/util/path-utils.js +2 -2
- package/lib/util/patterns/letters.js +1 -1
- package/lib/util/source-code.js +2 -2
- package/lib/util/xml-escape.js +1 -1
- package/package.json +10 -9
@@ -32,13 +32,11 @@ module.exports = {
|
|
32
32
|
properties: {
|
33
33
|
maximum: {
|
34
34
|
type: "integer",
|
35
|
-
minimum: 0
|
36
|
-
default: 10
|
35
|
+
minimum: 0
|
37
36
|
},
|
38
37
|
max: {
|
39
38
|
type: "integer",
|
40
|
-
minimum: 0
|
41
|
-
default: 10
|
39
|
+
minimum: 0
|
42
40
|
}
|
43
41
|
},
|
44
42
|
additionalProperties: false
|
@@ -59,7 +57,10 @@ module.exports = {
|
|
59
57
|
const option = context.options[0];
|
60
58
|
let THRESHOLD = 10;
|
61
59
|
|
62
|
-
if (
|
60
|
+
if (
|
61
|
+
typeof option === "object" &&
|
62
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
63
|
+
) {
|
63
64
|
THRESHOLD = option.maximum || option.max;
|
64
65
|
} else if (typeof option === "number") {
|
65
66
|
THRESHOLD = option;
|
package/lib/rules/max-params.js
CHANGED
@@ -40,13 +40,11 @@ module.exports = {
|
|
40
40
|
properties: {
|
41
41
|
maximum: {
|
42
42
|
type: "integer",
|
43
|
-
minimum: 0
|
44
|
-
default: 3
|
43
|
+
minimum: 0
|
45
44
|
},
|
46
45
|
max: {
|
47
46
|
type: "integer",
|
48
|
-
minimum: 0
|
49
|
-
default: 3
|
47
|
+
minimum: 0
|
50
48
|
}
|
51
49
|
},
|
52
50
|
additionalProperties: false
|
@@ -64,7 +62,10 @@ module.exports = {
|
|
64
62
|
const option = context.options[0];
|
65
63
|
let numParams = 3;
|
66
64
|
|
67
|
-
if (
|
65
|
+
if (
|
66
|
+
typeof option === "object" &&
|
67
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
68
|
+
) {
|
68
69
|
numParams = option.maximum || option.max;
|
69
70
|
}
|
70
71
|
if (typeof option === "number") {
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
57
57
|
// Helpers
|
58
58
|
//--------------------------------------------------------------------------
|
59
59
|
|
60
|
-
const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)
|
60
|
+
const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u;
|
61
61
|
|
62
62
|
/**
|
63
63
|
* Reports with the first extra statement, and clears it.
|
@@ -40,13 +40,11 @@ module.exports = {
|
|
40
40
|
properties: {
|
41
41
|
maximum: {
|
42
42
|
type: "integer",
|
43
|
-
minimum: 0
|
44
|
-
default: 10
|
43
|
+
minimum: 0
|
45
44
|
},
|
46
45
|
max: {
|
47
46
|
type: "integer",
|
48
|
-
minimum: 0
|
49
|
-
default: 10
|
47
|
+
minimum: 0
|
50
48
|
}
|
51
49
|
},
|
52
50
|
additionalProperties: false
|
@@ -80,7 +78,10 @@ module.exports = {
|
|
80
78
|
topLevelFunctions = [];
|
81
79
|
let maxStatements = 10;
|
82
80
|
|
83
|
-
if (
|
81
|
+
if (
|
82
|
+
typeof option === "object" &&
|
83
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
84
|
+
) {
|
84
85
|
maxStatements = option.maximum || option.max;
|
85
86
|
} else if (typeof option === "number") {
|
86
87
|
maxStatements = option;
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
52
52
|
}
|
53
53
|
return commentGroup[0].value
|
54
54
|
.split(astUtils.LINEBREAK_MATCHER)
|
55
|
-
.map(line => line.replace(/^\s
|
55
|
+
.map(line => line.replace(/^\s*\*?/u, ""));
|
56
56
|
}
|
57
57
|
|
58
58
|
/**
|
@@ -103,9 +103,9 @@ module.exports = {
|
|
103
103
|
const lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
|
104
104
|
|
105
105
|
return commentGroup[0].type === "Block" &&
|
106
|
-
/^\*\s
|
107
|
-
lines.slice(1, -1).every(line => /^\s*
|
108
|
-
/^\s
|
106
|
+
/^\*\s*$/u.test(lines[0]) &&
|
107
|
+
lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&
|
108
|
+
/^\s*$/u.test(lines[lines.length - 1]);
|
109
109
|
}
|
110
110
|
|
111
111
|
/**
|
@@ -143,7 +143,7 @@ module.exports = {
|
|
143
143
|
const lines = block.value.split(astUtils.LINEBREAK_MATCHER);
|
144
144
|
const expectedLinePrefix = `${sourceCode.text.slice(block.range[0] - block.loc.start.column, block.range[0])} *`;
|
145
145
|
|
146
|
-
if (!/^\*?\s
|
146
|
+
if (!/^\*?\s*$/u.test(lines[0])) {
|
147
147
|
const start = block.value.startsWith("*") ? block.range[0] + 1 : block.range[0];
|
148
148
|
|
149
149
|
context.report({
|
@@ -156,7 +156,7 @@ module.exports = {
|
|
156
156
|
});
|
157
157
|
}
|
158
158
|
|
159
|
-
if (!/^\s
|
159
|
+
if (!/^\s*$/u.test(lines[lines.length - 1])) {
|
160
160
|
context.report({
|
161
161
|
loc: {
|
162
162
|
start: { line: block.loc.end.line, column: block.loc.end.column - 2 },
|
@@ -176,12 +176,12 @@ module.exports = {
|
|
176
176
|
start: { line: lineNumber, column: 0 },
|
177
177
|
end: { line: lineNumber, column: sourceCode.lines[lineNumber - 1].length }
|
178
178
|
},
|
179
|
-
messageId: /^\s
|
179
|
+
messageId: /^\s*\*/u.test(lineText)
|
180
180
|
? "alignment"
|
181
181
|
: "missingStar",
|
182
182
|
fix(fixer) {
|
183
183
|
const lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 });
|
184
|
-
const linePrefixLength = lineText.match(/^\s*\*? ?/)[0].length;
|
184
|
+
const linePrefixLength = lineText.match(/^\s*\*? ?/u)[0].length;
|
185
185
|
const commentStartIndex = lineStartIndex + linePrefixLength;
|
186
186
|
|
187
187
|
const replacementText = lineNumber === block.loc.end.line || lineText.length === linePrefixLength
|
@@ -244,7 +244,7 @@ module.exports = {
|
|
244
244
|
const block = commentGroup[0];
|
245
245
|
const lines = block.value.split(astUtils.LINEBREAK_MATCHER).filter(line => line.trim());
|
246
246
|
|
247
|
-
if (lines.length > 0 && lines.every(line => /^\s
|
247
|
+
if (lines.length > 0 && lines.every(line => /^\s*\*/u.test(line))) {
|
248
248
|
context.report({
|
249
249
|
loc: {
|
250
250
|
start: block.loc.start,
|
package/lib/rules/new-cap.js
CHANGED
@@ -136,10 +136,10 @@ module.exports = {
|
|
136
136
|
const skipProperties = config.properties === false;
|
137
137
|
|
138
138
|
const newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {});
|
139
|
-
const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern) : null;
|
139
|
+
const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern) : null; // eslint-disable-line require-unicode-regexp
|
140
140
|
|
141
141
|
const capIsNewExceptions = calculateCapIsNewExceptions(config);
|
142
|
-
const capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern) : null;
|
142
|
+
const capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern) : null; // eslint-disable-line require-unicode-regexp
|
143
143
|
|
144
144
|
const listeners = {};
|
145
145
|
|
package/lib/rules/no-alert.js
CHANGED
@@ -20,7 +20,7 @@ const getPropertyName = require("../util/ast-utils").getStaticPropertyName;
|
|
20
20
|
* @returns {boolean} Whether or not the name is prohibited.
|
21
21
|
*/
|
22
22
|
function isProhibitedIdentifier(name) {
|
23
|
-
return /^(alert|confirm|prompt)
|
23
|
+
return /^(alert|confirm|prompt)$/u.test(name);
|
24
24
|
}
|
25
25
|
|
26
26
|
/**
|
package/lib/rules/no-caller.js
CHANGED
@@ -35,7 +35,7 @@ module.exports = {
|
|
35
35
|
const objectName = node.object.name,
|
36
36
|
propertyName = node.property.name;
|
37
37
|
|
38
|
-
if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
|
38
|
+
if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/u)) {
|
39
39
|
context.report({ node, messageId: "unexpected", data: { prop: propertyName } });
|
40
40
|
}
|
41
41
|
|
@@ -15,8 +15,8 @@ const astUtils = require("../util/ast-utils");
|
|
15
15
|
// Helpers
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
const GET_KIND = /^(?:init|get)
|
19
|
-
const SET_KIND = /^(?:init|set)
|
18
|
+
const GET_KIND = /^(?:init|get)$/u;
|
19
|
+
const SET_KIND = /^(?:init|set)$/u;
|
20
20
|
|
21
21
|
/**
|
22
22
|
* The class which stores properties' information of an object.
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
82
82
|
* after the if block
|
83
83
|
*/
|
84
84
|
const ifBlockMaybeUnsafe = node.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";";
|
85
|
-
const elseBlockUnsafe = /^[([/+`-]
|
85
|
+
const elseBlockUnsafe = /^[([/+`-]/u.test(firstTokenOfElseBlock.value);
|
86
86
|
|
87
87
|
if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
|
88
88
|
return null;
|
@@ -94,7 +94,7 @@ module.exports = {
|
|
94
94
|
if (lastTokenOfElseBlock.value !== ";") {
|
95
95
|
const nextToken = sourceCode.getTokenAfter(endToken);
|
96
96
|
|
97
|
-
const nextTokenUnsafe = nextToken && /^[([/+`-]
|
97
|
+
const nextTokenUnsafe = nextToken && /^[([/+`-]/u.test(nextToken.value);
|
98
98
|
const nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line;
|
99
99
|
|
100
100
|
/*
|
@@ -21,7 +21,7 @@
|
|
21
21
|
* 4. `[gimuy]*`: optional regexp flags
|
22
22
|
* 5. `$`: fix the match at the end of the string
|
23
23
|
*/
|
24
|
-
const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)
|
24
|
+
const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gimuys]*$/u;
|
25
25
|
|
26
26
|
//------------------------------------------------------------------------------
|
27
27
|
// Rule Definition
|
@@ -44,11 +44,11 @@ module.exports = {
|
|
44
44
|
{
|
45
45
|
type: "object",
|
46
46
|
properties: {
|
47
|
-
conditionalAssign: { type: "boolean"
|
48
|
-
nestedBinaryExpressions: { type: "boolean"
|
49
|
-
returnAssign: { type: "boolean"
|
47
|
+
conditionalAssign: { type: "boolean" },
|
48
|
+
nestedBinaryExpressions: { type: "boolean" },
|
49
|
+
returnAssign: { type: "boolean" },
|
50
50
|
ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] },
|
51
|
-
enforceForArrowConditionals: { type: "boolean"
|
51
|
+
enforceForArrowConditionals: { type: "boolean" }
|
52
52
|
},
|
53
53
|
additionalProperties: false
|
54
54
|
}
|
@@ -471,6 +471,7 @@ module.exports = {
|
|
471
471
|
const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
|
472
472
|
const secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken);
|
473
473
|
const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;
|
474
|
+
const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken) : null;
|
474
475
|
|
475
476
|
if (
|
476
477
|
astUtils.isOpeningParenToken(firstToken) &&
|
@@ -479,7 +480,12 @@ module.exports = {
|
|
479
480
|
secondToken.type === "Keyword" && (
|
480
481
|
secondToken.value === "function" ||
|
481
482
|
secondToken.value === "class" ||
|
482
|
-
secondToken.value === "let" &&
|
483
|
+
secondToken.value === "let" &&
|
484
|
+
tokenAfterClosingParens &&
|
485
|
+
(
|
486
|
+
astUtils.isOpeningBracketToken(tokenAfterClosingParens) ||
|
487
|
+
tokenAfterClosingParens.type === "Identifier"
|
488
|
+
)
|
483
489
|
) ||
|
484
490
|
secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function"
|
485
491
|
)
|
@@ -14,7 +14,7 @@ const lodash = require("lodash");
|
|
14
14
|
// Helpers
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/
|
17
|
+
const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
|
18
18
|
|
19
19
|
/**
|
20
20
|
* Checks whether or not a given node has a fallthrough comment.
|
@@ -95,7 +95,7 @@ module.exports = {
|
|
95
95
|
let fallthroughCommentPattern = null;
|
96
96
|
|
97
97
|
if (options.commentPattern) {
|
98
|
-
fallthroughCommentPattern = new RegExp(options.commentPattern);
|
98
|
+
fallthroughCommentPattern = new RegExp(options.commentPattern); // eslint-disable-line require-unicode-regexp
|
99
99
|
} else {
|
100
100
|
fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
|
101
101
|
}
|
@@ -11,7 +11,7 @@ const astUtils = require("../util/ast-utils");
|
|
11
11
|
// Helpers
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf
|
14
|
+
const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
|
15
15
|
const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
|
16
16
|
|
17
17
|
/**
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
const RegExpValidator = require("regexpp").RegExpValidator;
|
12
12
|
const validator = new RegExpValidator({ ecmaVersion: 2018 });
|
13
|
-
const validFlags = /[gimuys]/
|
13
|
+
const validFlags = /[gimuys]/gu;
|
14
14
|
const undefined1 = void 0;
|
15
15
|
|
16
16
|
//------------------------------------------------------------------------------
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
51
51
|
const temp = options.allowConstructorFlags.join("").replace(validFlags, "");
|
52
52
|
|
53
53
|
if (temp) {
|
54
|
-
allowedFlags = new RegExp(`[${temp}]`, "
|
54
|
+
allowedFlags = new RegExp(`[${temp}]`, "giu");
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
@@ -16,9 +16,9 @@ const astUtils = require("../util/ast-utils");
|
|
16
16
|
// Constants
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]
|
20
|
-
const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/
|
21
|
-
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/
|
19
|
+
const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u;
|
20
|
+
const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/mgu;
|
21
|
+
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mgu;
|
22
22
|
const LINE_BREAK = astUtils.createGlobalLinebreakMatcher();
|
23
23
|
|
24
24
|
//------------------------------------------------------------------------------
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
node.consequent.type !== "BlockStatement" && lastIfToken.value !== ";" && tokenAfterElseBlock &&
|
59
59
|
(
|
60
60
|
node.consequent.loc.end.line === tokenAfterElseBlock.loc.start.line ||
|
61
|
-
/^[([/+`-]
|
61
|
+
/^[([/+`-]/u.test(tokenAfterElseBlock.value) ||
|
62
62
|
lastIfToken.value === "++" ||
|
63
63
|
lastIfToken.value === "--"
|
64
64
|
)
|
@@ -30,12 +30,10 @@ module.exports = {
|
|
30
30
|
type: "object",
|
31
31
|
properties: {
|
32
32
|
grouping: {
|
33
|
-
type: "boolean"
|
34
|
-
default: false
|
33
|
+
type: "boolean"
|
35
34
|
},
|
36
35
|
allowCall: {
|
37
|
-
type: "boolean"
|
38
|
-
default: false
|
36
|
+
type: "boolean"
|
39
37
|
}
|
40
38
|
},
|
41
39
|
additionalProperties: false
|
@@ -158,7 +156,7 @@ module.exports = {
|
|
158
156
|
// "var fs = require('fs');"
|
159
157
|
return REQ_CORE;
|
160
158
|
}
|
161
|
-
if (/^\.{0,2}
|
159
|
+
if (/^\.{0,2}\//u.test(arg.value)) {
|
162
160
|
|
163
161
|
// "var utils = require('./utils');"
|
164
162
|
return REQ_FILE;
|
@@ -88,7 +88,7 @@ module.exports = {
|
|
88
88
|
* or the reverse before non-tab/-space
|
89
89
|
* characters begin.
|
90
90
|
*/
|
91
|
-
let regex = /^(?=[\t ]*(\t | \t))
|
91
|
+
let regex = /^(?=[\t ]*(\t | \t))/u;
|
92
92
|
const lines = sourceCode.lines,
|
93
93
|
comments = sourceCode.getAllComments();
|
94
94
|
|
@@ -114,7 +114,7 @@ module.exports = {
|
|
114
114
|
* At least one space followed by a tab
|
115
115
|
* before non-tab/-space characters begin.
|
116
116
|
*/
|
117
|
-
regex = /^(?=[\t ]* \t)
|
117
|
+
regex = /^(?=[\t ]* \t)/u;
|
118
118
|
}
|
119
119
|
|
120
120
|
lines.forEach((line, i) => {
|
@@ -32,7 +32,7 @@ module.exports = {
|
|
32
32
|
return;
|
33
33
|
}
|
34
34
|
|
35
|
-
const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-3][0-7]{1,2}|[4-7][0-7]|[0-7])/);
|
35
|
+
const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-3][0-7]{1,2}|[4-7][0-7]|[0-7])/u);
|
36
36
|
|
37
37
|
if (match) {
|
38
38
|
const octalDigit = match[2];
|
package/lib/rules/no-octal.js
CHANGED
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
return {
|
29
29
|
|
30
30
|
Literal(node) {
|
31
|
-
if (typeof node.value === "number" && /^0[0-7]
|
31
|
+
if (typeof node.value === "number" && /^0[0-7]/u.test(node.raw)) {
|
32
32
|
context.report({ node, message: "Octal literals should not be used." });
|
33
33
|
}
|
34
34
|
}
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)
|
11
|
+
const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
|
12
12
|
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
39
39
|
* @private
|
40
40
|
*/
|
41
41
|
function checkRegex(node, value, valueStart) {
|
42
|
-
const multipleSpacesRegex = /( {2,})( [+*{?]|[^+*{?]|$)
|
42
|
+
const multipleSpacesRegex = /( {2,})( [+*{?]|[^+*{?]|$)/u,
|
43
43
|
regexResults = multipleSpacesRegex.exec(value);
|
44
44
|
|
45
45
|
if (regexResults !== null) {
|
@@ -14,7 +14,7 @@ const astUtils = require("../util/ast-utils");
|
|
14
14
|
// Helpers
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)
|
17
|
+
const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u;
|
18
18
|
|
19
19
|
//------------------------------------------------------------------------------
|
20
20
|
// Rule Definition
|
@@ -15,7 +15,7 @@ const astUtils = require("../util/ast-utils");
|
|
15
15
|
// Helpers
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
const SPACES = /\s+/
|
18
|
+
const SPACES = /\s+/gu;
|
19
19
|
|
20
20
|
/**
|
21
21
|
* Checks whether the property of 2 given member expression nodes are the same
|
package/lib/rules/no-tabs.js
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
// Helpers
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const tabRegex = /\t+/
|
13
|
-
const anyNonWhitespaceRegex = /\S
|
12
|
+
const tabRegex = /\t+/gu;
|
13
|
+
const anyNonWhitespaceRegex = /\S/u;
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
// Public Interface
|
@@ -111,8 +111,8 @@ module.exports = {
|
|
111
111
|
* fetch the source code and do matching via regexps.
|
112
112
|
*/
|
113
113
|
|
114
|
-
const re = new RegExp(NONBLANK),
|
115
|
-
skipMatch = new RegExp(SKIP_BLANK),
|
114
|
+
const re = new RegExp(NONBLANK, "u"),
|
115
|
+
skipMatch = new RegExp(SKIP_BLANK, "u"),
|
116
116
|
lines = sourceCode.lines,
|
117
117
|
linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()),
|
118
118
|
comments = sourceCode.getAllComments(),
|
@@ -16,11 +16,11 @@ const Traverser = require("../util/traverser"),
|
|
16
16
|
// Helpers
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
const SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)
|
20
|
-
const LOOP_PATTERN = /^(?:DoWhile|For|While)Statement
|
21
|
-
const GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)
|
22
|
-
const SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression
|
23
|
-
const DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression
|
19
|
+
const SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)$/u;
|
20
|
+
const LOOP_PATTERN = /^(?:DoWhile|For|While)Statement$/u; // for-in/of statements don't have `test` property.
|
21
|
+
const GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)$/u;
|
22
|
+
const SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression$/u;
|
23
|
+
const DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression$/u;
|
24
24
|
|
25
25
|
/**
|
26
26
|
* @typedef {Object} LoopConditionInfo
|
@@ -9,9 +9,9 @@
|
|
9
9
|
// Helpers
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)
|
13
|
-
const SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)
|
14
|
-
const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)
|
12
|
+
const SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
|
13
|
+
const SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/u;
|
14
|
+
const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/u;
|
15
15
|
|
16
16
|
|
17
17
|
//------------------------------------------------------------------------------
|
@@ -88,7 +88,7 @@ module.exports = {
|
|
88
88
|
grandparent = ancestors[ancestors.length - 2];
|
89
89
|
|
90
90
|
return (parent.type === "Program" || parent.type === "BlockStatement" &&
|
91
|
-
(/Function
|
91
|
+
(/Function/u.test(grandparent.type))) &&
|
92
92
|
directives(parent).indexOf(node) >= 0;
|
93
93
|
}
|
94
94
|
|
@@ -116,7 +116,7 @@ module.exports = {
|
|
116
116
|
return true;
|
117
117
|
}
|
118
118
|
|
119
|
-
return /^(?:Assignment|Call|New|Update|Yield|Await)Expression
|
119
|
+
return /^(?:Assignment|Call|New|Update|Yield|Await)Expression$/u.test(node.type) ||
|
120
120
|
(node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0);
|
121
121
|
}
|
122
122
|
|