eslint 9.14.0 → 9.16.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 +1 -1
- package/lib/cli-engine/formatters/stylish.js +3 -3
- package/lib/cli-engine/lint-result-cache.js +1 -1
- package/lib/config/config.js +40 -24
- package/lib/eslint/eslint-helpers.js +9 -13
- 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 +14 -10
- package/lib/rules/array-callback-return.js +10 -8
- package/lib/rules/arrow-body-style.js +3 -1
- package/lib/rules/camelcase.js +18 -12
- 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 +7 -5
- package/lib/rules/grouped-accessor-pairs.js +3 -1
- package/lib/rules/id-denylist.js +2 -1
- package/lib/rules/id-length.js +11 -6
- package/lib/rules/id-match.js +18 -16
- package/lib/rules/new-cap.js +16 -35
- package/lib/rules/no-bitwise.js +7 -5
- package/lib/rules/no-compare-neg-zero.js +1 -1
- 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 +7 -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 +6 -4
- package/lib/rules/no-empty.js +6 -5
- package/lib/rules/no-eval.js +6 -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 +6 -4
- package/lib/rules/no-inline-comments.js +4 -6
- package/lib/rules/no-inner-declarations.js +5 -3
- 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 +7 -10
- package/lib/rules/no-plusplus.js +6 -9
- package/lib/rules/no-promise-executor-return.js +6 -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 +21 -15
- package/lib/rules/no-undef.js +6 -4
- package/lib/rules/no-underscore-dangle.js +32 -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 +6 -4
- package/lib/rules/no-unsafe-optional-chaining.js +6 -4
- package/lib/rules/no-unused-expressions.js +17 -13
- package/lib/rules/no-use-before-define.js +15 -13
- package/lib/rules/no-useless-computed-key.js +10 -4
- package/lib/rules/no-useless-rename.js +11 -8
- package/lib/rules/no-void.js +6 -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 +9 -5
- package/lib/rules/prefer-promise-reject-errors.js +7 -3
- package/lib/rules/prefer-regex-literals.js +6 -3
- package/lib/rules/radix.js +3 -1
- package/lib/rules/require-atomic-updates.js +6 -3
- package/lib/rules/sort-imports.js +20 -16
- package/lib/rules/sort-keys.js +22 -16
- package/lib/rules/sort-vars.js +7 -6
- package/lib/rules/strict.js +3 -2
- package/lib/rules/unicode-bom.js +4 -2
- package/lib/rules/use-isnan.js +8 -6
- package/lib/rules/utils/ast-utils.js +141 -0
- package/lib/rules/valid-typeof.js +6 -4
- 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 +7 -0
- package/package.json +11 -12
@@ -14,6 +14,18 @@ module.exports = {
|
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
16
16
|
|
17
|
+
defaultOptions: [{
|
18
|
+
allow: [],
|
19
|
+
allowAfterSuper: false,
|
20
|
+
allowAfterThis: false,
|
21
|
+
allowAfterThisConstructor: false,
|
22
|
+
allowFunctionParams: true,
|
23
|
+
allowInArrayDestructuring: true,
|
24
|
+
allowInObjectDestructuring: true,
|
25
|
+
enforceInClassFields: false,
|
26
|
+
enforceInMethodNames: false
|
27
|
+
}],
|
28
|
+
|
17
29
|
docs: {
|
18
30
|
description: "Disallow dangling underscores in identifiers",
|
19
31
|
recommended: false,
|
@@ -31,36 +43,28 @@ module.exports = {
|
|
31
43
|
}
|
32
44
|
},
|
33
45
|
allowAfterThis: {
|
34
|
-
type: "boolean"
|
35
|
-
default: false
|
46
|
+
type: "boolean"
|
36
47
|
},
|
37
48
|
allowAfterSuper: {
|
38
|
-
type: "boolean"
|
39
|
-
default: false
|
49
|
+
type: "boolean"
|
40
50
|
},
|
41
51
|
allowAfterThisConstructor: {
|
42
|
-
type: "boolean"
|
43
|
-
default: false
|
52
|
+
type: "boolean"
|
44
53
|
},
|
45
54
|
enforceInMethodNames: {
|
46
|
-
type: "boolean"
|
47
|
-
default: false
|
55
|
+
type: "boolean"
|
48
56
|
},
|
49
57
|
allowFunctionParams: {
|
50
|
-
type: "boolean"
|
51
|
-
default: true
|
58
|
+
type: "boolean"
|
52
59
|
},
|
53
60
|
enforceInClassFields: {
|
54
|
-
type: "boolean"
|
55
|
-
default: false
|
61
|
+
type: "boolean"
|
56
62
|
},
|
57
63
|
allowInArrayDestructuring: {
|
58
|
-
type: "boolean"
|
59
|
-
default: true
|
64
|
+
type: "boolean"
|
60
65
|
},
|
61
66
|
allowInObjectDestructuring: {
|
62
|
-
type: "boolean"
|
63
|
-
default: true
|
67
|
+
type: "boolean"
|
64
68
|
}
|
65
69
|
},
|
66
70
|
additionalProperties: false
|
@@ -73,17 +77,17 @@ module.exports = {
|
|
73
77
|
},
|
74
78
|
|
75
79
|
create(context) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
const [{
|
81
|
+
allow,
|
82
|
+
allowAfterSuper,
|
83
|
+
allowAfterThis,
|
84
|
+
allowAfterThisConstructor,
|
85
|
+
allowFunctionParams,
|
86
|
+
allowInArrayDestructuring,
|
87
|
+
allowInObjectDestructuring,
|
88
|
+
enforceInClassFields,
|
89
|
+
enforceInMethodNames
|
90
|
+
}] = context.options;
|
87
91
|
const sourceCode = context.sourceCode;
|
88
92
|
|
89
93
|
//-------------------------------------------------------------------------
|
@@ -97,7 +101,7 @@ module.exports = {
|
|
97
101
|
* @private
|
98
102
|
*/
|
99
103
|
function isAllowed(identifier) {
|
100
|
-
return
|
104
|
+
return allow.includes(identifier);
|
101
105
|
}
|
102
106
|
|
103
107
|
/**
|
@@ -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,10 @@ module.exports = {
|
|
51
51
|
meta: {
|
52
52
|
type: "problem",
|
53
53
|
|
54
|
+
defaultOptions: [{
|
55
|
+
enforceForOrderingRelations: false
|
56
|
+
}],
|
57
|
+
|
54
58
|
docs: {
|
55
59
|
description: "Disallow negating the left operand of relational operators",
|
56
60
|
recommended: true,
|
@@ -64,8 +68,7 @@ module.exports = {
|
|
64
68
|
type: "object",
|
65
69
|
properties: {
|
66
70
|
enforceForOrderingRelations: {
|
67
|
-
type: "boolean"
|
68
|
-
default: false
|
71
|
+
type: "boolean"
|
69
72
|
}
|
70
73
|
},
|
71
74
|
additionalProperties: false
|
@@ -83,8 +86,7 @@ module.exports = {
|
|
83
86
|
|
84
87
|
create(context) {
|
85
88
|
const sourceCode = context.sourceCode;
|
86
|
-
const
|
87
|
-
const enforceForOrderingRelations = options.enforceForOrderingRelations === true;
|
89
|
+
const [{ enforceForOrderingRelations }] = context.options;
|
88
90
|
|
89
91
|
return {
|
90
92
|
BinaryExpression(node) {
|
@@ -23,6 +23,10 @@ module.exports = {
|
|
23
23
|
meta: {
|
24
24
|
type: "problem",
|
25
25
|
|
26
|
+
defaultOptions: [{
|
27
|
+
disallowArithmeticOperators: false
|
28
|
+
}],
|
29
|
+
|
26
30
|
docs: {
|
27
31
|
description: "Disallow use of optional chaining in contexts where the `undefined` value is not allowed",
|
28
32
|
recommended: true,
|
@@ -32,8 +36,7 @@ module.exports = {
|
|
32
36
|
type: "object",
|
33
37
|
properties: {
|
34
38
|
disallowArithmeticOperators: {
|
35
|
-
type: "boolean"
|
36
|
-
default: false
|
39
|
+
type: "boolean"
|
37
40
|
}
|
38
41
|
},
|
39
42
|
additionalProperties: false
|
@@ -46,8 +49,7 @@ module.exports = {
|
|
46
49
|
},
|
47
50
|
|
48
51
|
create(context) {
|
49
|
-
const
|
50
|
-
const disallowArithmeticOperators = (options.disallowArithmeticOperators) || false;
|
52
|
+
const [{ disallowArithmeticOperators }] = context.options;
|
51
53
|
|
52
54
|
/**
|
53
55
|
* 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,13 @@ module.exports = {
|
|
251
246
|
}
|
252
247
|
],
|
253
248
|
|
249
|
+
defaultOptions: [{
|
250
|
+
classes: true,
|
251
|
+
functions: true,
|
252
|
+
variables: true,
|
253
|
+
allowNamedExports: false
|
254
|
+
}],
|
255
|
+
|
254
256
|
messages: {
|
255
257
|
usedBeforeDefined: "'{{name}}' was used before it was defined."
|
256
258
|
}
|
@@ -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
|
@@ -114,7 +120,7 @@ module.exports = {
|
|
114
120
|
},
|
115
121
|
create(context) {
|
116
122
|
const sourceCode = context.sourceCode;
|
117
|
-
const enforceForClassMembers = context.options
|
123
|
+
const [{ enforceForClassMembers }] = context.options;
|
118
124
|
|
119
125
|
/**
|
120
126
|
* Reports a given node if it violated this rule.
|
@@ -20,6 +20,12 @@ module.exports = {
|
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|
22
22
|
|
23
|
+
defaultOptions: [{
|
24
|
+
ignoreDestructuring: false,
|
25
|
+
ignoreImport: false,
|
26
|
+
ignoreExport: false
|
27
|
+
}],
|
28
|
+
|
23
29
|
docs: {
|
24
30
|
description: "Disallow renaming import, export, and destructured assignments to the same name",
|
25
31
|
recommended: false,
|
@@ -32,9 +38,9 @@ module.exports = {
|
|
32
38
|
{
|
33
39
|
type: "object",
|
34
40
|
properties: {
|
35
|
-
ignoreDestructuring: { type: "boolean"
|
36
|
-
ignoreImport: { type: "boolean"
|
37
|
-
ignoreExport: { type: "boolean"
|
41
|
+
ignoreDestructuring: { type: "boolean" },
|
42
|
+
ignoreImport: { type: "boolean" },
|
43
|
+
ignoreExport: { type: "boolean" }
|
38
44
|
},
|
39
45
|
additionalProperties: false
|
40
46
|
}
|
@@ -46,11 +52,8 @@ module.exports = {
|
|
46
52
|
},
|
47
53
|
|
48
54
|
create(context) {
|
49
|
-
const sourceCode = context.sourceCode
|
50
|
-
|
51
|
-
ignoreDestructuring = options.ignoreDestructuring === true,
|
52
|
-
ignoreImport = options.ignoreImport === true,
|
53
|
-
ignoreExport = options.ignoreExport === true;
|
55
|
+
const sourceCode = context.sourceCode;
|
56
|
+
const [{ ignoreDestructuring, ignoreImport, ignoreExport }] = context.options;
|
54
57
|
|
55
58
|
//--------------------------------------------------------------------------
|
56
59
|
// Helpers
|
package/lib/rules/no-void.js
CHANGED
@@ -13,6 +13,10 @@ module.exports = {
|
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
15
15
|
|
16
|
+
defaultOptions: [{
|
17
|
+
allowAsStatement: false
|
18
|
+
}],
|
19
|
+
|
16
20
|
docs: {
|
17
21
|
description: "Disallow `void` operators",
|
18
22
|
recommended: false,
|
@@ -28,8 +32,7 @@ module.exports = {
|
|
28
32
|
type: "object",
|
29
33
|
properties: {
|
30
34
|
allowAsStatement: {
|
31
|
-
type: "boolean"
|
32
|
-
default: false
|
35
|
+
type: "boolean"
|
33
36
|
}
|
34
37
|
},
|
35
38
|
additionalProperties: false
|
@@ -38,8 +41,7 @@ module.exports = {
|
|
38
41
|
},
|
39
42
|
|
40
43
|
create(context) {
|
41
|
-
const allowAsStatement =
|
42
|
-
context.options[0] && context.options[0].allowAsStatement;
|
44
|
+
const [{ allowAsStatement }] = context.options;
|
43
45
|
|
44
46
|
//--------------------------------------------------------------------------
|
45
47
|
// 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,11 @@ module.exports = {
|
|
331
331
|
meta: {
|
332
332
|
type: "suggestion",
|
333
333
|
|
334
|
+
defaultOptions: [{
|
335
|
+
destructuring: "any",
|
336
|
+
ignoreReadBeforeAssign: false
|
337
|
+
}],
|
338
|
+
|
334
339
|
docs: {
|
335
340
|
description: "Require `const` declarations for variables that are never reassigned after declared",
|
336
341
|
recommended: false,
|
@@ -343,8 +348,8 @@ module.exports = {
|
|
343
348
|
{
|
344
349
|
type: "object",
|
345
350
|
properties: {
|
346
|
-
destructuring: { enum: ["any", "all"]
|
347
|
-
ignoreReadBeforeAssign: { type: "boolean"
|
351
|
+
destructuring: { enum: ["any", "all"] },
|
352
|
+
ignoreReadBeforeAssign: { type: "boolean" }
|
348
353
|
},
|
349
354
|
additionalProperties: false
|
350
355
|
}
|
@@ -355,10 +360,9 @@ module.exports = {
|
|
355
360
|
},
|
356
361
|
|
357
362
|
create(context) {
|
358
|
-
const
|
363
|
+
const [{ destructuring, ignoreReadBeforeAssign }] = context.options;
|
364
|
+
const shouldMatchAnyDestructuredVariable = destructuring !== "all";
|
359
365
|
const sourceCode = context.sourceCode;
|
360
|
-
const shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
|
361
|
-
const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
|
362
366
|
const variables = [];
|
363
367
|
let reportCount = 0;
|
364
368
|
let checkedId = null;
|
@@ -15,6 +15,10 @@ module.exports = {
|
|
15
15
|
meta: {
|
16
16
|
type: "suggestion",
|
17
17
|
|
18
|
+
defaultOptions: [{
|
19
|
+
allowEmptyReject: false
|
20
|
+
}],
|
21
|
+
|
18
22
|
docs: {
|
19
23
|
description: "Require using Error objects as Promise rejection reasons",
|
20
24
|
recommended: false,
|
@@ -27,7 +31,7 @@ module.exports = {
|
|
27
31
|
{
|
28
32
|
type: "object",
|
29
33
|
properties: {
|
30
|
-
allowEmptyReject: { type: "boolean"
|
34
|
+
allowEmptyReject: { type: "boolean" }
|
31
35
|
},
|
32
36
|
additionalProperties: false
|
33
37
|
}
|
@@ -40,7 +44,7 @@ module.exports = {
|
|
40
44
|
|
41
45
|
create(context) {
|
42
46
|
|
43
|
-
const
|
47
|
+
const [{ allowEmptyReject }] = context.options;
|
44
48
|
const sourceCode = context.sourceCode;
|
45
49
|
|
46
50
|
//----------------------------------------------------------------------
|
@@ -53,7 +57,7 @@ module.exports = {
|
|
53
57
|
* @returns {void}
|
54
58
|
*/
|
55
59
|
function checkRejectCall(callExpression) {
|
56
|
-
if (!callExpression.arguments.length &&
|
60
|
+
if (!callExpression.arguments.length && allowEmptyReject) {
|
57
61
|
return;
|
58
62
|
}
|
59
63
|
if (
|
@@ -112,6 +112,10 @@ module.exports = {
|
|
112
112
|
meta: {
|
113
113
|
type: "suggestion",
|
114
114
|
|
115
|
+
defaultOptions: [{
|
116
|
+
disallowRedundantWrapping: false
|
117
|
+
}],
|
118
|
+
|
115
119
|
docs: {
|
116
120
|
description: "Disallow use of the `RegExp` constructor in favor of regular expression literals",
|
117
121
|
recommended: false,
|
@@ -125,8 +129,7 @@ module.exports = {
|
|
125
129
|
type: "object",
|
126
130
|
properties: {
|
127
131
|
disallowRedundantWrapping: {
|
128
|
-
type: "boolean"
|
129
|
-
default: false
|
132
|
+
type: "boolean"
|
130
133
|
}
|
131
134
|
},
|
132
135
|
additionalProperties: false
|
@@ -144,7 +147,7 @@ module.exports = {
|
|
144
147
|
},
|
145
148
|
|
146
149
|
create(context) {
|
147
|
-
const [{ disallowRedundantWrapping
|
150
|
+
const [{ disallowRedundantWrapping }] = context.options;
|
148
151
|
const sourceCode = context.sourceCode;
|
149
152
|
|
150
153
|
/**
|
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
|
/**
|