eslint 5.13.0 → 5.15.1
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 +69 -0
- package/README.md +68 -156
- package/lib/built-in-rules-index.js +1 -0
- package/lib/cli-engine.js +5 -2
- package/lib/config/config-file.js +27 -4
- package/lib/config/config-initializer.js +151 -144
- package/lib/config/config-ops.js +2 -0
- package/lib/config/config-validator.js +1 -1
- 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 +7 -4
- package/lib/rules/accessor-pairs.js +4 -2
- package/lib/rules/array-callback-return.js +4 -3
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +2 -1
- package/lib/rules/arrow-spacing.js +7 -6
- package/lib/rules/brace-style.js +2 -1
- package/lib/rules/camelcase.js +5 -4
- package/lib/rules/capitalized-comments.js +10 -14
- package/lib/rules/class-methods-use-this.js +1 -1
- package/lib/rules/comma-spacing.js +10 -4
- package/lib/rules/complexity.js +6 -7
- package/lib/rules/consistent-return.js +2 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/default-case.js +2 -2
- package/lib/rules/dot-notation.js +7 -5
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/func-call-spacing.js +2 -2
- package/lib/rules/func-style.js +3 -2
- package/lib/rules/getter-return.js +3 -2
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-length.js +3 -2
- package/lib/rules/id-match.js +7 -4
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +9 -6
- package/lib/rules/jsx-quotes.js +2 -2
- package/lib/rules/key-spacing.js +1 -1
- package/lib/rules/keyword-spacing.js +14 -14
- package/lib/rules/line-comment-position.js +5 -4
- package/lib/rules/lines-around-comment.js +14 -14
- package/lib/rules/lines-between-class-members.js +2 -1
- package/lib/rules/max-depth.js +5 -5
- package/lib/rules/max-len.js +21 -14
- package/lib/rules/max-lines-per-function.js +13 -17
- package/lib/rules/max-lines.js +3 -5
- package/lib/rules/max-nested-callbacks.js +6 -7
- package/lib/rules/max-params.js +5 -5
- package/lib/rules/max-statements-per-line.js +3 -2
- package/lib/rules/max-statements.js +6 -7
- package/lib/rules/multiline-comment-style.js +9 -9
- package/lib/rules/new-cap.js +9 -6
- package/lib/rules/newline-per-chained-call.js +2 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-bitwise.js +2 -1
- package/lib/rules/no-caller.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-constant-condition.js +2 -1
- package/lib/rules/no-dupe-keys.js +2 -2
- package/lib/rules/no-duplicate-imports.js +2 -1
- package/lib/rules/no-else-return.js +4 -3
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-empty.js +2 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-extra-parens.js +7 -1
- package/lib/rules/no-fallthrough.js +4 -3
- package/lib/rules/no-implicit-coercion.js +10 -7
- 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 +11 -7
- package/lib/rules/no-labels.js +6 -4
- package/lib/rules/no-lonely-if.js +1 -1
- package/lib/rules/no-magic-numbers.js +6 -3
- package/lib/rules/no-mixed-operators.js +6 -5
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
- package/lib/rules/no-multi-spaces.js +2 -1
- package/lib/rules/no-octal-escape.js +1 -1
- package/lib/rules/no-octal.js +1 -1
- package/lib/rules/no-param-reassign.js +2 -2
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-plusplus.js +2 -1
- package/lib/rules/no-redeclare.js +2 -2
- 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 +3 -2
- package/lib/rules/no-shadow-restricted-names.js +16 -2
- package/lib/rules/no-shadow.js +3 -3
- package/lib/rules/no-sync.js +2 -1
- package/lib/rules/no-tabs.js +4 -3
- package/lib/rules/no-template-curly-in-string.js +1 -1
- package/lib/rules/no-trailing-spaces.js +7 -5
- package/lib/rules/no-undef.js +2 -1
- package/lib/rules/no-underscore-dangle.js +6 -3
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +5 -5
- package/lib/rules/no-unneeded-ternary.js +2 -1
- package/lib/rules/no-unsafe-finally.js +3 -3
- package/lib/rules/no-unused-expressions.js +8 -5
- package/lib/rules/no-unused-vars.js +6 -6
- package/lib/rules/no-use-before-define.js +2 -2
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-rename.js +3 -3
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +6 -6
- package/lib/rules/object-property-newline.js +5 -3
- package/lib/rules/one-var.js +18 -35
- package/lib/rules/padded-blocks.js +32 -9
- package/lib/rules/padding-line-between-statements.js +4 -3
- package/lib/rules/prefer-arrow-callback.js +4 -2
- package/lib/rules/prefer-const.js +5 -5
- package/lib/rules/prefer-destructuring.js +56 -5
- package/lib/rules/prefer-named-capture-group.js +123 -0
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-spread.js +2 -13
- package/lib/rules/prefer-template.js +3 -3
- package/lib/rules/quotes.js +2 -2
- package/lib/rules/require-jsdoc.js +13 -7
- package/lib/rules/semi-spacing.js +6 -8
- package/lib/rules/semi.js +4 -4
- package/lib/rules/sort-imports.js +6 -3
- package/lib/rules/sort-keys.js +13 -5
- package/lib/rules/sort-vars.js +2 -1
- package/lib/rules/space-infix-ops.js +2 -1
- package/lib/rules/space-unary-ops.js +5 -3
- package/lib/rules/spaced-comment.js +6 -5
- package/lib/rules/switch-colon-spacing.js +2 -2
- package/lib/rules/template-curly-spacing.js +2 -2
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/valid-jsdoc.js +12 -7
- package/lib/rules/valid-typeof.js +2 -1
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/wrap-iife.js +3 -2
- package/lib/rules/yoda.js +6 -4
- package/lib/util/ajv.js +1 -0
- package/lib/util/ast-utils.js +12 -12
- package/lib/util/config-comment-parser.js +4 -4
- package/lib/util/glob-utils.js +3 -3
- 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 +25 -23
package/lib/rules/max-len.js
CHANGED
@@ -14,7 +14,8 @@ const OPTIONS_SCHEMA = {
|
|
14
14
|
properties: {
|
15
15
|
code: {
|
16
16
|
type: "integer",
|
17
|
-
minimum: 0
|
17
|
+
minimum: 0,
|
18
|
+
default: 80
|
18
19
|
},
|
19
20
|
comments: {
|
20
21
|
type: "integer",
|
@@ -22,28 +23,35 @@ const OPTIONS_SCHEMA = {
|
|
22
23
|
},
|
23
24
|
tabWidth: {
|
24
25
|
type: "integer",
|
25
|
-
minimum: 0
|
26
|
+
minimum: 0,
|
27
|
+
default: 4
|
26
28
|
},
|
27
29
|
ignorePattern: {
|
28
30
|
type: "string"
|
29
31
|
},
|
30
32
|
ignoreComments: {
|
31
|
-
type: "boolean"
|
33
|
+
type: "boolean",
|
34
|
+
default: false
|
32
35
|
},
|
33
36
|
ignoreStrings: {
|
34
|
-
type: "boolean"
|
37
|
+
type: "boolean",
|
38
|
+
default: false
|
35
39
|
},
|
36
40
|
ignoreUrls: {
|
37
|
-
type: "boolean"
|
41
|
+
type: "boolean",
|
42
|
+
default: false
|
38
43
|
},
|
39
44
|
ignoreTemplateLiterals: {
|
40
|
-
type: "boolean"
|
45
|
+
type: "boolean",
|
46
|
+
default: false
|
41
47
|
},
|
42
48
|
ignoreRegExpLiterals: {
|
43
|
-
type: "boolean"
|
49
|
+
type: "boolean",
|
50
|
+
default: false
|
44
51
|
},
|
45
52
|
ignoreTrailingComments: {
|
46
|
-
type: "boolean"
|
53
|
+
type: "boolean",
|
54
|
+
default: false
|
47
55
|
}
|
48
56
|
},
|
49
57
|
additionalProperties: false
|
@@ -95,7 +103,7 @@ module.exports = {
|
|
95
103
|
* too many false positives
|
96
104
|
* - We don't care about matching the entire URL, any small segment is fine
|
97
105
|
*/
|
98
|
-
const URL_REGEXP = /[^:/?#]:\/\/[^?#]
|
106
|
+
const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u;
|
99
107
|
|
100
108
|
const sourceCode = context.getSourceCode();
|
101
109
|
|
@@ -110,7 +118,7 @@ module.exports = {
|
|
110
118
|
function computeLineLength(line, tabWidth) {
|
111
119
|
let extraCharacterCount = 0;
|
112
120
|
|
113
|
-
line.replace(/\t/
|
121
|
+
line.replace(/\t/gu, (match, offset) => {
|
114
122
|
const totalOffset = offset + extraCharacterCount,
|
115
123
|
previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
|
116
124
|
spaceCount = tabWidth - previousTabStopOffset;
|
@@ -121,8 +129,7 @@ module.exports = {
|
|
121
129
|
}
|
122
130
|
|
123
131
|
// The options object must be the last option specified…
|
124
|
-
const
|
125
|
-
const options = typeof lastOption === "object" ? Object.create(lastOption) : {};
|
132
|
+
const options = Object.assign({}, context.options[context.options.length - 1]);
|
126
133
|
|
127
134
|
// …but max code length…
|
128
135
|
if (typeof context.options[0] === "number") {
|
@@ -146,7 +153,7 @@ module.exports = {
|
|
146
153
|
let ignorePattern = options.ignorePattern || null;
|
147
154
|
|
148
155
|
if (ignorePattern) {
|
149
|
-
ignorePattern = new RegExp(ignorePattern);
|
156
|
+
ignorePattern = new RegExp(ignorePattern); // eslint-disable-line require-unicode-regexp
|
150
157
|
}
|
151
158
|
|
152
159
|
//--------------------------------------------------------------------------
|
@@ -194,7 +201,7 @@ module.exports = {
|
|
194
201
|
function stripTrailingComment(line, comment) {
|
195
202
|
|
196
203
|
// loc.column is zero-indexed
|
197
|
-
return line.slice(0, comment.loc.start.column).replace(/\s
|
204
|
+
return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
|
198
205
|
}
|
199
206
|
|
200
207
|
/**
|
@@ -19,16 +19,20 @@ const OPTIONS_SCHEMA = {
|
|
19
19
|
properties: {
|
20
20
|
max: {
|
21
21
|
type: "integer",
|
22
|
-
minimum: 0
|
22
|
+
minimum: 0,
|
23
|
+
default: 50
|
23
24
|
},
|
24
25
|
skipComments: {
|
25
|
-
type: "boolean"
|
26
|
+
type: "boolean",
|
27
|
+
default: false
|
26
28
|
},
|
27
29
|
skipBlankLines: {
|
28
|
-
type: "boolean"
|
30
|
+
type: "boolean",
|
31
|
+
default: false
|
29
32
|
},
|
30
33
|
IIFEs: {
|
31
|
-
type: "boolean"
|
34
|
+
type: "boolean",
|
35
|
+
default: false
|
32
36
|
}
|
33
37
|
},
|
34
38
|
additionalProperties: false
|
@@ -97,18 +101,10 @@ module.exports = {
|
|
97
101
|
let IIFEs = false;
|
98
102
|
|
99
103
|
if (typeof option === "object") {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
skipComments = option.skipComments;
|
105
|
-
}
|
106
|
-
if (typeof option.skipBlankLines === "boolean") {
|
107
|
-
skipBlankLines = option.skipBlankLines;
|
108
|
-
}
|
109
|
-
if (typeof option.IIFEs === "boolean") {
|
110
|
-
IIFEs = option.IIFEs;
|
111
|
-
}
|
104
|
+
maxLines = option.max;
|
105
|
+
skipComments = option.skipComments;
|
106
|
+
skipBlankLines = option.skipBlankLines;
|
107
|
+
IIFEs = option.IIFEs;
|
112
108
|
} else if (typeof option === "number") {
|
113
109
|
maxLines = option;
|
114
110
|
}
|
@@ -191,7 +187,7 @@ module.exports = {
|
|
191
187
|
}
|
192
188
|
|
193
189
|
if (skipBlankLines) {
|
194
|
-
if (line.match(/^\s*$/)) {
|
190
|
+
if (line.match(/^\s*$/u)) {
|
195
191
|
continue;
|
196
192
|
}
|
197
193
|
}
|
package/lib/rules/max-lines.js
CHANGED
@@ -61,11 +61,9 @@ module.exports = {
|
|
61
61
|
const option = context.options[0];
|
62
62
|
let max = 300;
|
63
63
|
|
64
|
-
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max")
|
64
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max")) {
|
65
65
|
max = option.max;
|
66
|
-
}
|
67
|
-
|
68
|
-
if (typeof option === "number") {
|
66
|
+
} else if (typeof option === "number") {
|
69
67
|
max = option;
|
70
68
|
}
|
71
69
|
|
@@ -86,7 +84,7 @@ module.exports = {
|
|
86
84
|
/**
|
87
85
|
* Returns the line numbers of a comment that don't have any code on the same line
|
88
86
|
* @param {Node} comment The comment node to check
|
89
|
-
* @returns {
|
87
|
+
* @returns {number[]} The line numbers
|
90
88
|
*/
|
91
89
|
function getLinesWithoutCode(comment) {
|
92
90
|
let start = comment.loc.start.line;
|
@@ -57,13 +57,12 @@ module.exports = {
|
|
57
57
|
const option = context.options[0];
|
58
58
|
let THRESHOLD = 10;
|
59
59
|
|
60
|
-
if (
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
THRESHOLD = option.max;
|
65
|
-
}
|
66
|
-
if (typeof option === "number") {
|
60
|
+
if (
|
61
|
+
typeof option === "object" &&
|
62
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
63
|
+
) {
|
64
|
+
THRESHOLD = option.maximum || option.max;
|
65
|
+
} else if (typeof option === "number") {
|
67
66
|
THRESHOLD = option;
|
68
67
|
}
|
69
68
|
|
package/lib/rules/max-params.js
CHANGED
@@ -62,11 +62,11 @@ module.exports = {
|
|
62
62
|
const option = context.options[0];
|
63
63
|
let numParams = 3;
|
64
64
|
|
65
|
-
if (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
numParams = option.max;
|
65
|
+
if (
|
66
|
+
typeof option === "object" &&
|
67
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
68
|
+
) {
|
69
|
+
numParams = option.maximum || option.max;
|
70
70
|
}
|
71
71
|
if (typeof option === "number") {
|
72
72
|
numParams = option;
|
@@ -31,7 +31,8 @@ module.exports = {
|
|
31
31
|
properties: {
|
32
32
|
max: {
|
33
33
|
type: "integer",
|
34
|
-
minimum: 1
|
34
|
+
minimum: 1,
|
35
|
+
default: 1
|
35
36
|
}
|
36
37
|
},
|
37
38
|
additionalProperties: false
|
@@ -56,7 +57,7 @@ module.exports = {
|
|
56
57
|
// Helpers
|
57
58
|
//--------------------------------------------------------------------------
|
58
59
|
|
59
|
-
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;
|
60
61
|
|
61
62
|
/**
|
62
63
|
* Reports with the first extra statement, and clears it.
|
@@ -78,13 +78,12 @@ module.exports = {
|
|
78
78
|
topLevelFunctions = [];
|
79
79
|
let maxStatements = 10;
|
80
80
|
|
81
|
-
if (
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
maxStatements = option.max;
|
86
|
-
}
|
87
|
-
if (typeof option === "number") {
|
81
|
+
if (
|
82
|
+
typeof option === "object" &&
|
83
|
+
(Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))
|
84
|
+
) {
|
85
|
+
maxStatements = option.maximum || option.max;
|
86
|
+
} else if (typeof option === "number") {
|
88
87
|
maxStatements = option;
|
89
88
|
}
|
90
89
|
|
@@ -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
@@ -88,10 +88,12 @@ module.exports = {
|
|
88
88
|
type: "object",
|
89
89
|
properties: {
|
90
90
|
newIsCap: {
|
91
|
-
type: "boolean"
|
91
|
+
type: "boolean",
|
92
|
+
default: true
|
92
93
|
},
|
93
94
|
capIsNew: {
|
94
|
-
type: "boolean"
|
95
|
+
type: "boolean",
|
96
|
+
default: true
|
95
97
|
},
|
96
98
|
newIsCapExceptions: {
|
97
99
|
type: "array",
|
@@ -112,7 +114,8 @@ module.exports = {
|
|
112
114
|
type: "string"
|
113
115
|
},
|
114
116
|
properties: {
|
115
|
-
type: "boolean"
|
117
|
+
type: "boolean",
|
118
|
+
default: true
|
116
119
|
}
|
117
120
|
},
|
118
121
|
additionalProperties: false
|
@@ -126,17 +129,17 @@ module.exports = {
|
|
126
129
|
|
127
130
|
create(context) {
|
128
131
|
|
129
|
-
const config =
|
132
|
+
const config = Object.assign({}, context.options[0]);
|
130
133
|
|
131
134
|
config.newIsCap = config.newIsCap !== false;
|
132
135
|
config.capIsNew = config.capIsNew !== false;
|
133
136
|
const skipProperties = config.properties === false;
|
134
137
|
|
135
138
|
const newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {});
|
136
|
-
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
|
137
140
|
|
138
141
|
const capIsNewExceptions = calculateCapIsNewExceptions(config);
|
139
|
-
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
|
140
143
|
|
141
144
|
const listeners = {};
|
142
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-bitwise.js
CHANGED
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.
|
@@ -31,7 +31,8 @@ module.exports = {
|
|
31
31
|
type: "object",
|
32
32
|
properties: {
|
33
33
|
allowElseIf: {
|
34
|
-
type: "boolean"
|
34
|
+
type: "boolean",
|
35
|
+
default: true
|
35
36
|
}
|
36
37
|
},
|
37
38
|
additionalProperties: false
|
@@ -81,7 +82,7 @@ module.exports = {
|
|
81
82
|
* after the if block
|
82
83
|
*/
|
83
84
|
const ifBlockMaybeUnsafe = node.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";";
|
84
|
-
const elseBlockUnsafe = /^[([/+`-]
|
85
|
+
const elseBlockUnsafe = /^[([/+`-]/u.test(firstTokenOfElseBlock.value);
|
85
86
|
|
86
87
|
if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
|
87
88
|
return null;
|
@@ -93,7 +94,7 @@ module.exports = {
|
|
93
94
|
if (lastTokenOfElseBlock.value !== ";") {
|
94
95
|
const nextToken = sourceCode.getTokenAfter(endToken);
|
95
96
|
|
96
|
-
const nextTokenUnsafe = nextToken && /^[([/+`-]
|
97
|
+
const nextTokenUnsafe = nextToken && /^[([/+`-]/u.test(nextToken.value);
|
97
98
|
const nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line;
|
98
99
|
|
99
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
|
package/lib/rules/no-empty.js
CHANGED
package/lib/rules/no-eval.js
CHANGED
@@ -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.
|
@@ -69,7 +69,8 @@ module.exports = {
|
|
69
69
|
type: "object",
|
70
70
|
properties: {
|
71
71
|
commentPattern: {
|
72
|
-
type: "string"
|
72
|
+
type: "string",
|
73
|
+
default: ""
|
73
74
|
}
|
74
75
|
},
|
75
76
|
additionalProperties: false
|
@@ -94,7 +95,7 @@ module.exports = {
|
|
94
95
|
let fallthroughCommentPattern = null;
|
95
96
|
|
96
97
|
if (options.commentPattern) {
|
97
|
-
fallthroughCommentPattern = new RegExp(options.commentPattern);
|
98
|
+
fallthroughCommentPattern = new RegExp(options.commentPattern); // eslint-disable-line require-unicode-regexp
|
98
99
|
} else {
|
99
100
|
fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
|
100
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
|
/**
|
@@ -21,9 +21,9 @@ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
|
|
21
21
|
*/
|
22
22
|
function parseOptions(options) {
|
23
23
|
return {
|
24
|
-
boolean: "boolean" in options ?
|
25
|
-
number: "number" in options ?
|
26
|
-
string: "string" in options ?
|
24
|
+
boolean: "boolean" in options ? options.boolean : true,
|
25
|
+
number: "number" in options ? options.number : true,
|
26
|
+
string: "string" in options ? options.string : true,
|
27
27
|
allow: options.allow || []
|
28
28
|
};
|
29
29
|
}
|
@@ -167,13 +167,16 @@ module.exports = {
|
|
167
167
|
type: "object",
|
168
168
|
properties: {
|
169
169
|
boolean: {
|
170
|
-
type: "boolean"
|
170
|
+
type: "boolean",
|
171
|
+
default: true
|
171
172
|
},
|
172
173
|
number: {
|
173
|
-
type: "boolean"
|
174
|
+
type: "boolean",
|
175
|
+
default: true
|
174
176
|
},
|
175
177
|
string: {
|
176
|
-
type: "boolean"
|
178
|
+
type: "boolean",
|
179
|
+
default: true
|
177
180
|
},
|
178
181
|
allow: {
|
179
182
|
type: "array",
|
@@ -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
|
|