eslint 9.13.0 → 9.15.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/README.md +2 -2
- package/lib/cli-engine/formatters/stylish.js +3 -3
- package/lib/cli-engine/lint-result-cache.js +1 -1
- package/lib/config/config-loader.js +193 -177
- package/lib/config/config.js +40 -24
- package/lib/eslint/eslint-helpers.js +18 -22
- package/lib/eslint/eslint.js +2 -2
- package/lib/languages/js/index.js +76 -0
- package/lib/languages/js/source-code/token-store/index.js +1 -1
- package/lib/linter/code-path-analysis/code-path-analyzer.js +1 -1
- package/lib/linter/code-path-analysis/fork-context.js +1 -1
- package/lib/linter/linter.js +36 -35
- package/lib/linter/report-translator.js +1 -1
- package/lib/rule-tester/rule-tester.js +1 -1
- package/lib/rules/accessor-pairs.js +10 -7
- package/lib/rules/array-callback-return.js +10 -8
- package/lib/rules/arrow-body-style.js +3 -1
- package/lib/rules/camelcase.js +27 -14
- package/lib/rules/class-methods-use-this.js +9 -5
- package/lib/rules/complexity.js +9 -5
- package/lib/rules/consistent-return.js +4 -4
- package/lib/rules/consistent-this.js +3 -7
- package/lib/rules/curly.js +3 -140
- package/lib/rules/default-case.js +3 -1
- package/lib/rules/dot-notation.js +9 -6
- package/lib/rules/func-names.js +3 -3
- package/lib/rules/func-style.js +10 -8
- package/lib/rules/getter-return.js +5 -5
- package/lib/rules/grouped-accessor-pairs.js +3 -1
- package/lib/rules/id-denylist.js +14 -1
- package/lib/rules/id-length.js +12 -8
- package/lib/rules/id-match.js +20 -17
- package/lib/rules/new-cap.js +15 -34
- package/lib/rules/no-bitwise.js +4 -5
- package/lib/rules/no-cond-assign.js +3 -3
- package/lib/rules/no-console.js +3 -2
- package/lib/rules/no-constant-condition.js +5 -4
- package/lib/rules/no-duplicate-imports.js +5 -4
- package/lib/rules/no-else-return.js +4 -5
- package/lib/rules/no-empty-function.js +4 -4
- package/lib/rules/no-empty-pattern.js +4 -4
- package/lib/rules/no-empty.js +6 -5
- package/lib/rules/no-eval.js +4 -5
- package/lib/rules/no-extend-native.js +3 -3
- package/lib/rules/no-extra-boolean-cast.js +3 -3
- package/lib/rules/no-fallthrough.js +12 -15
- package/lib/rules/no-global-assign.js +3 -2
- package/lib/rules/no-implicit-coercion.js +13 -24
- package/lib/rules/no-implicit-globals.js +4 -4
- package/lib/rules/no-inline-comments.js +4 -6
- package/lib/rules/no-inner-declarations.js +4 -2
- package/lib/rules/no-invalid-regexp.js +5 -4
- package/lib/rules/no-invalid-this.js +4 -4
- package/lib/rules/no-irregular-whitespace.js +24 -22
- package/lib/rules/no-labels.js +8 -7
- package/lib/rules/no-lonely-if.js +8 -2
- package/lib/rules/no-multi-assign.js +5 -10
- package/lib/rules/no-plusplus.js +4 -9
- package/lib/rules/no-promise-executor-return.js +4 -6
- package/lib/rules/no-redeclare.js +5 -8
- package/lib/rules/no-return-assign.js +3 -1
- package/lib/rules/no-self-assign.js +4 -3
- package/lib/rules/no-sequences.js +7 -7
- package/lib/rules/no-shadow.js +18 -14
- package/lib/rules/no-undef.js +4 -4
- package/lib/rules/no-underscore-dangle.js +31 -28
- package/lib/rules/no-unneeded-ternary.js +4 -4
- package/lib/rules/no-unreachable-loop.js +4 -2
- package/lib/rules/no-unsafe-negation.js +4 -4
- package/lib/rules/no-unsafe-optional-chaining.js +4 -4
- package/lib/rules/no-unused-expressions.js +17 -13
- package/lib/rules/no-use-before-define.js +14 -13
- package/lib/rules/no-useless-computed-key.js +9 -3
- package/lib/rules/no-useless-rename.js +7 -8
- package/lib/rules/no-void.js +4 -4
- package/lib/rules/no-warning-comments.js +9 -7
- package/lib/rules/operator-assignment.js +4 -2
- package/lib/rules/prefer-arrow-callback.js +5 -8
- package/lib/rules/prefer-const.js +5 -3
- package/lib/rules/prefer-promise-reject-errors.js +5 -3
- package/lib/rules/prefer-regex-literals.js +4 -3
- package/lib/rules/radix.js +3 -1
- package/lib/rules/require-atomic-updates.js +4 -3
- package/lib/rules/sort-imports.js +20 -16
- package/lib/rules/sort-keys.js +13 -16
- package/lib/rules/sort-vars.js +4 -4
- package/lib/rules/strict.js +3 -2
- package/lib/rules/unicode-bom.js +4 -2
- package/lib/rules/use-isnan.js +7 -4
- package/lib/rules/utils/ast-utils.js +186 -2
- package/lib/rules/valid-typeof.js +3 -2
- package/lib/rules/yoda.js +9 -12
- package/lib/shared/assert.js +22 -0
- package/lib/shared/deep-merge-arrays.js +60 -0
- package/lib/shared/text-table.js +67 -0
- package/lib/shared/types.js +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/rules/ecmascript-6.d.ts +36 -16
- package/lib/types/rules/stylistic-issues.d.ts +3 -0
- package/package.json +19 -20
@@ -28,6 +28,8 @@ module.exports = {
|
|
28
28
|
meta: {
|
29
29
|
type: "suggestion",
|
30
30
|
|
31
|
+
defaultOptions: [{ defaultAssignment: true }],
|
32
|
+
|
31
33
|
docs: {
|
32
34
|
description: "Disallow ternary operators when simpler alternatives exist",
|
33
35
|
recommended: false,
|
@@ -39,8 +41,7 @@ module.exports = {
|
|
39
41
|
type: "object",
|
40
42
|
properties: {
|
41
43
|
defaultAssignment: {
|
42
|
-
type: "boolean"
|
43
|
-
default: true
|
44
|
+
type: "boolean"
|
44
45
|
}
|
45
46
|
},
|
46
47
|
additionalProperties: false
|
@@ -56,8 +57,7 @@ module.exports = {
|
|
56
57
|
},
|
57
58
|
|
58
59
|
create(context) {
|
59
|
-
const
|
60
|
-
const defaultAssignment = options.defaultAssignment !== false;
|
60
|
+
const [{ defaultAssignment }] = context.options;
|
61
61
|
const sourceCode = context.sourceCode;
|
62
62
|
|
63
63
|
/**
|
@@ -74,6 +74,8 @@ module.exports = {
|
|
74
74
|
meta: {
|
75
75
|
type: "problem",
|
76
76
|
|
77
|
+
defaultOptions: [{ ignore: [] }],
|
78
|
+
|
77
79
|
docs: {
|
78
80
|
description: "Disallow loops with a body that allows only one iteration",
|
79
81
|
recommended: false,
|
@@ -100,8 +102,8 @@ module.exports = {
|
|
100
102
|
},
|
101
103
|
|
102
104
|
create(context) {
|
103
|
-
const ignoredLoopTypes
|
104
|
-
|
105
|
+
const [{ ignore: ignoredLoopTypes }] = context.options;
|
106
|
+
const loopTypesToCheck = getDifference(allLoopTypes, ignoredLoopTypes),
|
105
107
|
loopSelector = loopTypesToCheck.join(","),
|
106
108
|
loopsByTargetSegments = new Map(),
|
107
109
|
loopsToReport = new Set();
|
@@ -51,6 +51,8 @@ module.exports = {
|
|
51
51
|
meta: {
|
52
52
|
type: "problem",
|
53
53
|
|
54
|
+
defaultOptions: [{}],
|
55
|
+
|
54
56
|
docs: {
|
55
57
|
description: "Disallow negating the left operand of relational operators",
|
56
58
|
recommended: true,
|
@@ -64,8 +66,7 @@ module.exports = {
|
|
64
66
|
type: "object",
|
65
67
|
properties: {
|
66
68
|
enforceForOrderingRelations: {
|
67
|
-
type: "boolean"
|
68
|
-
default: false
|
69
|
+
type: "boolean"
|
69
70
|
}
|
70
71
|
},
|
71
72
|
additionalProperties: false
|
@@ -83,8 +84,7 @@ module.exports = {
|
|
83
84
|
|
84
85
|
create(context) {
|
85
86
|
const sourceCode = context.sourceCode;
|
86
|
-
const
|
87
|
-
const enforceForOrderingRelations = options.enforceForOrderingRelations === true;
|
87
|
+
const [{ enforceForOrderingRelations }] = context.options;
|
88
88
|
|
89
89
|
return {
|
90
90
|
BinaryExpression(node) {
|
@@ -23,6 +23,8 @@ module.exports = {
|
|
23
23
|
meta: {
|
24
24
|
type: "problem",
|
25
25
|
|
26
|
+
defaultOptions: [{}],
|
27
|
+
|
26
28
|
docs: {
|
27
29
|
description: "Disallow use of optional chaining in contexts where the `undefined` value is not allowed",
|
28
30
|
recommended: true,
|
@@ -32,8 +34,7 @@ module.exports = {
|
|
32
34
|
type: "object",
|
33
35
|
properties: {
|
34
36
|
disallowArithmeticOperators: {
|
35
|
-
type: "boolean"
|
36
|
-
default: false
|
37
|
+
type: "boolean"
|
37
38
|
}
|
38
39
|
},
|
39
40
|
additionalProperties: false
|
@@ -46,8 +47,7 @@ module.exports = {
|
|
46
47
|
},
|
47
48
|
|
48
49
|
create(context) {
|
49
|
-
const
|
50
|
-
const disallowArithmeticOperators = (options.disallowArithmeticOperators) || false;
|
50
|
+
const [{ disallowArithmeticOperators }] = context.options;
|
51
51
|
|
52
52
|
/**
|
53
53
|
* Reports unsafe usage of optional chaining
|
@@ -42,37 +42,41 @@ module.exports = {
|
|
42
42
|
type: "object",
|
43
43
|
properties: {
|
44
44
|
allowShortCircuit: {
|
45
|
-
type: "boolean"
|
46
|
-
default: false
|
45
|
+
type: "boolean"
|
47
46
|
},
|
48
47
|
allowTernary: {
|
49
|
-
type: "boolean"
|
50
|
-
default: false
|
48
|
+
type: "boolean"
|
51
49
|
},
|
52
50
|
allowTaggedTemplates: {
|
53
|
-
type: "boolean"
|
54
|
-
default: false
|
51
|
+
type: "boolean"
|
55
52
|
},
|
56
53
|
enforceForJSX: {
|
57
|
-
type: "boolean"
|
58
|
-
default: false
|
54
|
+
type: "boolean"
|
59
55
|
}
|
60
56
|
},
|
61
57
|
additionalProperties: false
|
62
58
|
}
|
63
59
|
],
|
64
60
|
|
61
|
+
defaultOptions: [{
|
62
|
+
allowShortCircuit: false,
|
63
|
+
allowTernary: false,
|
64
|
+
allowTaggedTemplates: false,
|
65
|
+
enforceForJSX: false
|
66
|
+
}],
|
67
|
+
|
65
68
|
messages: {
|
66
69
|
unusedExpression: "Expected an assignment or function call and instead saw an expression."
|
67
70
|
}
|
68
71
|
},
|
69
72
|
|
70
73
|
create(context) {
|
71
|
-
const
|
72
|
-
allowShortCircuit
|
73
|
-
allowTernary
|
74
|
-
allowTaggedTemplates
|
75
|
-
enforceForJSX
|
74
|
+
const [{
|
75
|
+
allowShortCircuit,
|
76
|
+
allowTernary,
|
77
|
+
allowTaggedTemplates,
|
78
|
+
enforceForJSX
|
79
|
+
}] = context.options;
|
76
80
|
|
77
81
|
/**
|
78
82
|
* Has AST suggesting a directive.
|
@@ -18,21 +18,16 @@ const FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/u;
|
|
18
18
|
* @returns {Object} The parsed options.
|
19
19
|
*/
|
20
20
|
function parseOptions(options) {
|
21
|
-
|
22
|
-
|
23
|
-
let variables = true;
|
24
|
-
let allowNamedExports = false;
|
25
|
-
|
26
|
-
if (typeof options === "string") {
|
27
|
-
functions = (options !== "nofunc");
|
28
|
-
} else if (typeof options === "object" && options !== null) {
|
29
|
-
functions = options.functions !== false;
|
30
|
-
classes = options.classes !== false;
|
31
|
-
variables = options.variables !== false;
|
32
|
-
allowNamedExports = !!options.allowNamedExports;
|
21
|
+
if (typeof options === "object" && options !== null) {
|
22
|
+
return options;
|
33
23
|
}
|
34
24
|
|
35
|
-
|
25
|
+
const functions =
|
26
|
+
typeof options === "string"
|
27
|
+
? options !== "nofunc"
|
28
|
+
: true;
|
29
|
+
|
30
|
+
return { functions, classes: true, variables: true, allowNamedExports: false };
|
36
31
|
}
|
37
32
|
|
38
33
|
/**
|
@@ -251,6 +246,12 @@ module.exports = {
|
|
251
246
|
}
|
252
247
|
],
|
253
248
|
|
249
|
+
defaultOptions: [{
|
250
|
+
classes: true,
|
251
|
+
functions: true,
|
252
|
+
variables: true
|
253
|
+
}],
|
254
|
+
|
254
255
|
messages: {
|
255
256
|
usedBeforeDefined: "'{{name}}' was used before it was defined."
|
256
257
|
}
|
@@ -58,7 +58,10 @@ function hasUselessComputedKey(node) {
|
|
58
58
|
|
59
59
|
switch (node.type) {
|
60
60
|
case "Property":
|
61
|
-
|
61
|
+
if (node.parent.type === "ObjectExpression") {
|
62
|
+
return value !== "__proto__";
|
63
|
+
}
|
64
|
+
return true;
|
62
65
|
|
63
66
|
case "PropertyDefinition":
|
64
67
|
if (node.static) {
|
@@ -90,6 +93,10 @@ module.exports = {
|
|
90
93
|
meta: {
|
91
94
|
type: "suggestion",
|
92
95
|
|
96
|
+
defaultOptions: [{
|
97
|
+
enforceForClassMembers: true
|
98
|
+
}],
|
99
|
+
|
93
100
|
docs: {
|
94
101
|
description: "Disallow unnecessary computed property keys in objects and classes",
|
95
102
|
recommended: false,
|
@@ -100,8 +107,7 @@ module.exports = {
|
|
100
107
|
type: "object",
|
101
108
|
properties: {
|
102
109
|
enforceForClassMembers: {
|
103
|
-
type: "boolean"
|
104
|
-
default: true
|
110
|
+
type: "boolean"
|
105
111
|
}
|
106
112
|
},
|
107
113
|
additionalProperties: false
|
@@ -20,6 +20,8 @@ module.exports = {
|
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|
22
22
|
|
23
|
+
defaultOptions: [{}],
|
24
|
+
|
23
25
|
docs: {
|
24
26
|
description: "Disallow renaming import, export, and destructured assignments to the same name",
|
25
27
|
recommended: false,
|
@@ -32,9 +34,9 @@ module.exports = {
|
|
32
34
|
{
|
33
35
|
type: "object",
|
34
36
|
properties: {
|
35
|
-
ignoreDestructuring: { type: "boolean"
|
36
|
-
ignoreImport: { type: "boolean"
|
37
|
-
ignoreExport: { type: "boolean"
|
37
|
+
ignoreDestructuring: { type: "boolean" },
|
38
|
+
ignoreImport: { type: "boolean" },
|
39
|
+
ignoreExport: { type: "boolean" }
|
38
40
|
},
|
39
41
|
additionalProperties: false
|
40
42
|
}
|
@@ -46,11 +48,8 @@ module.exports = {
|
|
46
48
|
},
|
47
49
|
|
48
50
|
create(context) {
|
49
|
-
const sourceCode = context.sourceCode
|
50
|
-
|
51
|
-
ignoreDestructuring = options.ignoreDestructuring === true,
|
52
|
-
ignoreImport = options.ignoreImport === true,
|
53
|
-
ignoreExport = options.ignoreExport === true;
|
51
|
+
const sourceCode = context.sourceCode;
|
52
|
+
const [{ ignoreDestructuring, ignoreImport, ignoreExport }] = context.options;
|
54
53
|
|
55
54
|
//--------------------------------------------------------------------------
|
56
55
|
// Helpers
|
package/lib/rules/no-void.js
CHANGED
@@ -13,6 +13,8 @@ module.exports = {
|
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
15
15
|
|
16
|
+
defaultOptions: [{}],
|
17
|
+
|
16
18
|
docs: {
|
17
19
|
description: "Disallow `void` operators",
|
18
20
|
recommended: false,
|
@@ -28,8 +30,7 @@ module.exports = {
|
|
28
30
|
type: "object",
|
29
31
|
properties: {
|
30
32
|
allowAsStatement: {
|
31
|
-
type: "boolean"
|
32
|
-
default: false
|
33
|
+
type: "boolean"
|
33
34
|
}
|
34
35
|
},
|
35
36
|
additionalProperties: false
|
@@ -38,8 +39,7 @@ module.exports = {
|
|
38
39
|
},
|
39
40
|
|
40
41
|
create(context) {
|
41
|
-
const allowAsStatement =
|
42
|
-
context.options[0] && context.options[0].allowAsStatement;
|
42
|
+
const [{ allowAsStatement }] = context.options;
|
43
43
|
|
44
44
|
//--------------------------------------------------------------------------
|
45
45
|
// Public
|
@@ -19,6 +19,11 @@ module.exports = {
|
|
19
19
|
meta: {
|
20
20
|
type: "suggestion",
|
21
21
|
|
22
|
+
defaultOptions: [{
|
23
|
+
location: "start",
|
24
|
+
terms: ["todo", "fixme", "xxx"]
|
25
|
+
}],
|
26
|
+
|
22
27
|
docs: {
|
23
28
|
description: "Disallow specified warning terms in comments",
|
24
29
|
recommended: false,
|
@@ -58,12 +63,10 @@ module.exports = {
|
|
58
63
|
},
|
59
64
|
|
60
65
|
create(context) {
|
61
|
-
const sourceCode = context.sourceCode
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
decoration = [...configuration.decoration || []].join(""),
|
66
|
-
selfConfigRegEx = /\bno-warning-comments\b/u;
|
66
|
+
const sourceCode = context.sourceCode;
|
67
|
+
const [{ decoration, location, terms: warningTerms }] = context.options;
|
68
|
+
const escapedDecoration = escapeRegExp(decoration ? decoration.join("") : "");
|
69
|
+
const selfConfigRegEx = /\bno-warning-comments\b/u;
|
67
70
|
|
68
71
|
/**
|
69
72
|
* Convert a warning term into a RegExp which will match a comment containing that whole word in the specified
|
@@ -74,7 +77,6 @@ module.exports = {
|
|
74
77
|
*/
|
75
78
|
function convertToRegExp(term) {
|
76
79
|
const escaped = escapeRegExp(term);
|
77
|
-
const escapedDecoration = escapeRegExp(decoration);
|
78
80
|
|
79
81
|
/*
|
80
82
|
* When matching at the start, ignore leading whitespace, and
|
@@ -62,6 +62,8 @@ module.exports = {
|
|
62
62
|
meta: {
|
63
63
|
type: "suggestion",
|
64
64
|
|
65
|
+
defaultOptions: ["always"],
|
66
|
+
|
65
67
|
docs: {
|
66
68
|
description: "Require or disallow assignment operator shorthand where possible",
|
67
69
|
recommended: false,
|
@@ -82,7 +84,7 @@ module.exports = {
|
|
82
84
|
},
|
83
85
|
|
84
86
|
create(context) {
|
85
|
-
|
87
|
+
const never = context.options[0] === "never";
|
86
88
|
const sourceCode = context.sourceCode;
|
87
89
|
|
88
90
|
/**
|
@@ -202,7 +204,7 @@ module.exports = {
|
|
202
204
|
}
|
203
205
|
|
204
206
|
return {
|
205
|
-
AssignmentExpression:
|
207
|
+
AssignmentExpression: !never ? verify : prohibit
|
206
208
|
};
|
207
209
|
|
208
210
|
}
|
@@ -150,6 +150,8 @@ module.exports = {
|
|
150
150
|
meta: {
|
151
151
|
type: "suggestion",
|
152
152
|
|
153
|
+
defaultOptions: [{ allowNamedFunctions: false, allowUnboundThis: true }],
|
154
|
+
|
153
155
|
docs: {
|
154
156
|
description: "Require using arrow functions for callbacks",
|
155
157
|
recommended: false,
|
@@ -161,12 +163,10 @@ module.exports = {
|
|
161
163
|
type: "object",
|
162
164
|
properties: {
|
163
165
|
allowNamedFunctions: {
|
164
|
-
type: "boolean"
|
165
|
-
default: false
|
166
|
+
type: "boolean"
|
166
167
|
},
|
167
168
|
allowUnboundThis: {
|
168
|
-
type: "boolean"
|
169
|
-
default: true
|
169
|
+
type: "boolean"
|
170
170
|
}
|
171
171
|
},
|
172
172
|
additionalProperties: false
|
@@ -181,10 +181,7 @@ module.exports = {
|
|
181
181
|
},
|
182
182
|
|
183
183
|
create(context) {
|
184
|
-
const
|
185
|
-
|
186
|
-
const allowUnboundThis = options.allowUnboundThis !== false; // default to true
|
187
|
-
const allowNamedFunctions = options.allowNamedFunctions;
|
184
|
+
const [{ allowNamedFunctions, allowUnboundThis }] = context.options;
|
188
185
|
const sourceCode = context.sourceCode;
|
189
186
|
|
190
187
|
/*
|
@@ -331,6 +331,8 @@ module.exports = {
|
|
331
331
|
meta: {
|
332
332
|
type: "suggestion",
|
333
333
|
|
334
|
+
defaultOptions: [{ destructuring: "any" }],
|
335
|
+
|
334
336
|
docs: {
|
335
337
|
description: "Require `const` declarations for variables that are never reassigned after declared",
|
336
338
|
recommended: false,
|
@@ -343,8 +345,8 @@ module.exports = {
|
|
343
345
|
{
|
344
346
|
type: "object",
|
345
347
|
properties: {
|
346
|
-
destructuring: { enum: ["any", "all"]
|
347
|
-
ignoreReadBeforeAssign: { type: "boolean"
|
348
|
+
destructuring: { enum: ["any", "all"] },
|
349
|
+
ignoreReadBeforeAssign: { type: "boolean" }
|
348
350
|
},
|
349
351
|
additionalProperties: false
|
350
352
|
}
|
@@ -355,7 +357,7 @@ module.exports = {
|
|
355
357
|
},
|
356
358
|
|
357
359
|
create(context) {
|
358
|
-
const options = context.options
|
360
|
+
const [options] = context.options;
|
359
361
|
const sourceCode = context.sourceCode;
|
360
362
|
const shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
|
361
363
|
const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
|
@@ -15,6 +15,8 @@ module.exports = {
|
|
15
15
|
meta: {
|
16
16
|
type: "suggestion",
|
17
17
|
|
18
|
+
defaultOptions: [{}],
|
19
|
+
|
18
20
|
docs: {
|
19
21
|
description: "Require using Error objects as Promise rejection reasons",
|
20
22
|
recommended: false,
|
@@ -27,7 +29,7 @@ module.exports = {
|
|
27
29
|
{
|
28
30
|
type: "object",
|
29
31
|
properties: {
|
30
|
-
allowEmptyReject: { type: "boolean"
|
32
|
+
allowEmptyReject: { type: "boolean" }
|
31
33
|
},
|
32
34
|
additionalProperties: false
|
33
35
|
}
|
@@ -40,7 +42,7 @@ module.exports = {
|
|
40
42
|
|
41
43
|
create(context) {
|
42
44
|
|
43
|
-
const
|
45
|
+
const [{ allowEmptyReject }] = context.options;
|
44
46
|
const sourceCode = context.sourceCode;
|
45
47
|
|
46
48
|
//----------------------------------------------------------------------
|
@@ -53,7 +55,7 @@ module.exports = {
|
|
53
55
|
* @returns {void}
|
54
56
|
*/
|
55
57
|
function checkRejectCall(callExpression) {
|
56
|
-
if (!callExpression.arguments.length &&
|
58
|
+
if (!callExpression.arguments.length && allowEmptyReject) {
|
57
59
|
return;
|
58
60
|
}
|
59
61
|
if (
|
@@ -112,6 +112,8 @@ module.exports = {
|
|
112
112
|
meta: {
|
113
113
|
type: "suggestion",
|
114
114
|
|
115
|
+
defaultOptions: [{}],
|
116
|
+
|
115
117
|
docs: {
|
116
118
|
description: "Disallow use of the `RegExp` constructor in favor of regular expression literals",
|
117
119
|
recommended: false,
|
@@ -125,8 +127,7 @@ module.exports = {
|
|
125
127
|
type: "object",
|
126
128
|
properties: {
|
127
129
|
disallowRedundantWrapping: {
|
128
|
-
type: "boolean"
|
129
|
-
default: false
|
130
|
+
type: "boolean"
|
130
131
|
}
|
131
132
|
},
|
132
133
|
additionalProperties: false
|
@@ -144,7 +145,7 @@ module.exports = {
|
|
144
145
|
},
|
145
146
|
|
146
147
|
create(context) {
|
147
|
-
const [{ disallowRedundantWrapping
|
148
|
+
const [{ disallowRedundantWrapping }] = context.options;
|
148
149
|
const sourceCode = context.sourceCode;
|
149
150
|
|
150
151
|
/**
|
package/lib/rules/radix.js
CHANGED
@@ -79,6 +79,8 @@ module.exports = {
|
|
79
79
|
meta: {
|
80
80
|
type: "suggestion",
|
81
81
|
|
82
|
+
defaultOptions: [MODE_ALWAYS],
|
83
|
+
|
82
84
|
docs: {
|
83
85
|
description: "Enforce the consistent use of the radix argument when using `parseInt()`",
|
84
86
|
recommended: false,
|
@@ -103,7 +105,7 @@ module.exports = {
|
|
103
105
|
},
|
104
106
|
|
105
107
|
create(context) {
|
106
|
-
const mode = context.options
|
108
|
+
const [mode] = context.options;
|
107
109
|
const sourceCode = context.sourceCode;
|
108
110
|
|
109
111
|
/**
|
@@ -170,6 +170,8 @@ module.exports = {
|
|
170
170
|
meta: {
|
171
171
|
type: "problem",
|
172
172
|
|
173
|
+
defaultOptions: [{}],
|
174
|
+
|
173
175
|
docs: {
|
174
176
|
description: "Disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
|
175
177
|
recommended: false,
|
@@ -182,8 +184,7 @@ module.exports = {
|
|
182
184
|
type: "object",
|
183
185
|
properties: {
|
184
186
|
allowProperties: {
|
185
|
-
type: "boolean"
|
186
|
-
default: false
|
187
|
+
type: "boolean"
|
187
188
|
}
|
188
189
|
},
|
189
190
|
additionalProperties: false
|
@@ -196,7 +197,7 @@ module.exports = {
|
|
196
197
|
},
|
197
198
|
|
198
199
|
create(context) {
|
199
|
-
const allowProperties
|
200
|
+
const [{ allowProperties }] = context.options;
|
200
201
|
|
201
202
|
const sourceCode = context.sourceCode;
|
202
203
|
const assignmentReferences = new Map();
|
@@ -14,6 +14,14 @@ module.exports = {
|
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
16
16
|
|
17
|
+
defaultOptions: [{
|
18
|
+
allowSeparatedGroups: false,
|
19
|
+
ignoreCase: false,
|
20
|
+
ignoreDeclarationSort: false,
|
21
|
+
ignoreMemberSort: false,
|
22
|
+
memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
|
23
|
+
}],
|
24
|
+
|
17
25
|
docs: {
|
18
26
|
description: "Enforce sorted import declarations within modules",
|
19
27
|
recommended: false,
|
@@ -25,8 +33,7 @@ module.exports = {
|
|
25
33
|
type: "object",
|
26
34
|
properties: {
|
27
35
|
ignoreCase: {
|
28
|
-
type: "boolean"
|
29
|
-
default: false
|
36
|
+
type: "boolean"
|
30
37
|
},
|
31
38
|
memberSyntaxSortOrder: {
|
32
39
|
type: "array",
|
@@ -38,16 +45,13 @@ module.exports = {
|
|
38
45
|
maxItems: 4
|
39
46
|
},
|
40
47
|
ignoreDeclarationSort: {
|
41
|
-
type: "boolean"
|
42
|
-
default: false
|
48
|
+
type: "boolean"
|
43
49
|
},
|
44
50
|
ignoreMemberSort: {
|
45
|
-
type: "boolean"
|
46
|
-
default: false
|
51
|
+
type: "boolean"
|
47
52
|
},
|
48
53
|
allowSeparatedGroups: {
|
49
|
-
type: "boolean"
|
50
|
-
default: false
|
54
|
+
type: "boolean"
|
51
55
|
}
|
52
56
|
},
|
53
57
|
additionalProperties: false
|
@@ -64,14 +68,14 @@ module.exports = {
|
|
64
68
|
},
|
65
69
|
|
66
70
|
create(context) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
const [{
|
72
|
+
ignoreCase,
|
73
|
+
ignoreDeclarationSort,
|
74
|
+
ignoreMemberSort,
|
75
|
+
memberSyntaxSortOrder,
|
76
|
+
allowSeparatedGroups
|
77
|
+
}] = context.options;
|
78
|
+
const sourceCode = context.sourceCode;
|
75
79
|
let previousDeclaration = null;
|
76
80
|
|
77
81
|
/**
|
package/lib/rules/sort-keys.js
CHANGED
@@ -80,6 +80,13 @@ module.exports = {
|
|
80
80
|
meta: {
|
81
81
|
type: "suggestion",
|
82
82
|
|
83
|
+
defaultOptions: ["asc", {
|
84
|
+
allowLineSeparatedGroups: false,
|
85
|
+
caseSensitive: true,
|
86
|
+
minKeys: 2,
|
87
|
+
natural: false
|
88
|
+
}],
|
89
|
+
|
83
90
|
docs: {
|
84
91
|
description: "Require object keys to be sorted",
|
85
92
|
recommended: false,
|
@@ -94,21 +101,17 @@ module.exports = {
|
|
94
101
|
type: "object",
|
95
102
|
properties: {
|
96
103
|
caseSensitive: {
|
97
|
-
type: "boolean"
|
98
|
-
default: true
|
104
|
+
type: "boolean"
|
99
105
|
},
|
100
106
|
natural: {
|
101
|
-
type: "boolean"
|
102
|
-
default: false
|
107
|
+
type: "boolean"
|
103
108
|
},
|
104
109
|
minKeys: {
|
105
110
|
type: "integer",
|
106
|
-
minimum: 2
|
107
|
-
default: 2
|
111
|
+
minimum: 2
|
108
112
|
},
|
109
113
|
allowLineSeparatedGroups: {
|
110
|
-
type: "boolean"
|
111
|
-
default: false
|
114
|
+
type: "boolean"
|
112
115
|
}
|
113
116
|
},
|
114
117
|
additionalProperties: false
|
@@ -121,14 +124,8 @@ module.exports = {
|
|
121
124
|
},
|
122
125
|
|
123
126
|
create(context) {
|
124
|
-
|
125
|
-
|
126
|
-
const order = context.options[0] || "asc";
|
127
|
-
const options = context.options[1];
|
128
|
-
const insensitive = options && options.caseSensitive === false;
|
129
|
-
const natural = options && options.natural;
|
130
|
-
const minKeys = options && options.minKeys;
|
131
|
-
const allowLineSeparatedGroups = options && options.allowLineSeparatedGroups || false;
|
127
|
+
const [order, { caseSensitive, natural, minKeys, allowLineSeparatedGroups }] = context.options;
|
128
|
+
const insensitive = !caseSensitive;
|
132
129
|
const isValidOrder = isValidOrders[
|
133
130
|
order + (insensitive ? "I" : "") + (natural ? "N" : "")
|
134
131
|
];
|