eslint 5.12.0 → 5.14.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 +70 -0
- package/README.md +76 -143
- package/conf/eslint-all.js +3 -5
- package/conf/eslint-recommended.js +4 -268
- package/lib/built-in-rules-index.js +277 -0
- package/lib/cli-engine.js +6 -2
- package/lib/config/config-file.js +25 -2
- package/lib/config/config-initializer.js +150 -143
- package/lib/config/config-ops.js +30 -0
- package/lib/config/config-rule.js +2 -4
- package/lib/config/plugins.js +12 -4
- package/lib/config.js +1 -1
- package/lib/formatters/table.js +13 -4
- package/lib/formatters/tap.js +7 -4
- package/lib/linter.js +31 -31
- package/lib/load-rules.js +2 -5
- package/lib/rules/accessor-pairs.js +4 -2
- package/lib/rules/array-bracket-newline.js +4 -2
- package/lib/rules/array-callback-return.js +2 -1
- package/lib/rules/array-element-newline.js +4 -2
- 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 +3 -2
- package/lib/rules/capitalized-comments.js +15 -14
- package/lib/rules/class-methods-use-this.js +1 -1
- package/lib/rules/comma-spacing.js +10 -4
- package/lib/rules/complexity.js +7 -9
- package/lib/rules/consistent-return.js +2 -1
- package/lib/rules/dot-notation.js +5 -3
- package/lib/rules/eqeqeq.js +2 -1
- package/lib/rules/for-direction.js +30 -17
- package/lib/rules/func-call-spacing.js +2 -1
- package/lib/rules/func-style.js +3 -2
- package/lib/rules/getter-return.js +2 -1
- package/lib/rules/global-require.js +5 -2
- package/lib/rules/guard-for-in.js +5 -2
- package/lib/rules/handle-callback-err.js +5 -2
- package/lib/rules/id-blacklist.js +4 -1
- package/lib/rules/id-length.js +9 -6
- package/lib/rules/id-match.js +11 -5
- package/lib/rules/implicit-arrow-linebreak.js +7 -3
- package/lib/rules/indent-legacy.js +11 -5
- package/lib/rules/indent.js +18 -9
- package/lib/rules/init-declarations.js +13 -13
- package/lib/rules/jsx-quotes.js +5 -2
- package/lib/rules/key-spacing.js +70 -35
- package/lib/rules/keyword-spacing.js +18 -12
- package/lib/rules/line-comment-position.js +15 -8
- package/lib/rules/linebreak-style.js +6 -6
- package/lib/rules/lines-around-comment.js +20 -16
- package/lib/rules/lines-around-directive.js +5 -2
- package/lib/rules/lines-between-class-members.js +8 -6
- package/lib/rules/max-depth.js +11 -9
- package/lib/rules/max-len.js +24 -13
- package/lib/rules/max-lines-per-function.js +17 -18
- package/lib/rules/max-lines.js +14 -10
- package/lib/rules/max-nested-callbacks.js +12 -11
- package/lib/rules/max-params.js +11 -9
- package/lib/rules/max-statements-per-line.js +8 -5
- package/lib/rules/max-statements.js +12 -11
- package/lib/rules/multiline-comment-style.js +18 -17
- package/lib/rules/multiline-ternary.js +8 -6
- package/lib/rules/new-cap.js +18 -11
- package/lib/rules/new-parens.js +5 -2
- package/lib/rules/newline-after-var.js +6 -8
- package/lib/rules/newline-before-return.js +5 -1
- package/lib/rules/newline-per-chained-call.js +7 -3
- package/lib/rules/no-async-promise-executor.js +5 -2
- package/lib/rules/no-bitwise.js +2 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-constant-condition.js +24 -2
- package/lib/rules/no-duplicate-imports.js +17 -11
- package/lib/rules/no-else-return.js +2 -1
- package/lib/rules/no-empty.js +2 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-extra-parens.js +4 -4
- package/lib/rules/no-fallthrough.js +8 -4
- package/lib/rules/no-floating-decimal.js +7 -3
- package/lib/rules/no-implicit-coercion.js +9 -6
- package/lib/rules/no-irregular-whitespace.js +8 -4
- package/lib/rules/no-labels.js +6 -4
- package/lib/rules/no-magic-numbers.js +6 -3
- package/lib/rules/no-mixed-operators.js +5 -4
- package/lib/rules/no-mixed-requires.js +4 -2
- package/lib/rules/no-multi-spaces.js +2 -1
- package/lib/rules/no-param-reassign.js +1 -1
- package/lib/rules/no-plusplus.js +2 -1
- package/lib/rules/no-redeclare.js +2 -2
- package/lib/rules/no-self-assign.js +2 -1
- 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 +2 -1
- package/lib/rules/no-trailing-spaces.js +5 -3
- package/lib/rules/no-undef.js +7 -3
- package/lib/rules/no-underscore-dangle.js +6 -3
- package/lib/rules/no-unexpected-multiline.js +14 -13
- package/lib/rules/no-unneeded-ternary.js +2 -1
- package/lib/rules/no-unsafe-negation.js +6 -3
- package/lib/rules/no-unused-expressions.js +6 -3
- package/lib/rules/no-unused-labels.js +7 -2
- package/lib/rules/no-unused-vars.js +8 -4
- package/lib/rules/no-use-before-define.js +3 -3
- package/lib/rules/no-useless-rename.js +3 -3
- package/lib/rules/object-curly-newline.js +6 -4
- package/lib/rules/object-property-newline.js +5 -3
- package/lib/rules/object-shorthand.js +9 -5
- package/lib/rules/one-var.js +24 -38
- package/lib/rules/operator-assignment.js +8 -4
- package/lib/rules/padded-blocks.js +32 -9
- package/lib/rules/prefer-arrow-callback.js +4 -2
- package/lib/rules/prefer-const.js +7 -4
- package/lib/rules/prefer-destructuring.js +70 -12
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-spread.js +2 -13
- package/lib/rules/quote-props.js +10 -5
- package/lib/rules/quotes.js +4 -2
- package/lib/rules/require-jsdoc.js +13 -7
- package/lib/rules/semi-spacing.js +6 -8
- package/lib/rules/semi.js +5 -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-before-function-paren.js +6 -3
- package/lib/rules/space-infix-ops.js +2 -1
- package/lib/rules/space-unary-ops.js +20 -10
- package/lib/rules/spaced-comment.js +2 -1
- package/lib/rules/strict.js +34 -35
- package/lib/rules/switch-colon-spacing.js +11 -8
- package/lib/rules/symbol-description.js +6 -3
- package/lib/rules/template-curly-spacing.js +10 -10
- package/lib/rules/template-tag-spacing.js +7 -3
- package/lib/rules/unicode-bom.js +7 -3
- package/lib/rules/use-isnan.js +5 -2
- package/lib/rules/valid-jsdoc.js +40 -19
- package/lib/rules/valid-typeof.js +9 -4
- package/lib/rules/vars-on-top.js +6 -4
- package/lib/rules/wrap-iife.js +12 -6
- package/lib/rules/yield-star-spacing.js +17 -10
- package/lib/rules/yoda.js +9 -4
- package/lib/rules.js +4 -34
- package/lib/util/ajv.js +1 -0
- package/lib/util/config-comment-parser.js +7 -10
- package/package.json +20 -20
@@ -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",
|
@@ -41,16 +41,20 @@ module.exports = {
|
|
41
41
|
type: "object",
|
42
42
|
properties: {
|
43
43
|
skipComments: {
|
44
|
-
type: "boolean"
|
44
|
+
type: "boolean",
|
45
|
+
default: false
|
45
46
|
},
|
46
47
|
skipStrings: {
|
47
|
-
type: "boolean"
|
48
|
+
type: "boolean",
|
49
|
+
default: true
|
48
50
|
},
|
49
51
|
skipTemplates: {
|
50
|
-
type: "boolean"
|
52
|
+
type: "boolean",
|
53
|
+
default: false
|
51
54
|
},
|
52
55
|
skipRegExps: {
|
53
|
-
type: "boolean"
|
56
|
+
type: "boolean",
|
57
|
+
default: false
|
54
58
|
}
|
55
59
|
},
|
56
60
|
additionalProperties: false
|
package/lib/rules/no-labels.js
CHANGED
@@ -30,10 +30,12 @@ module.exports = {
|
|
30
30
|
type: "object",
|
31
31
|
properties: {
|
32
32
|
allowLoop: {
|
33
|
-
type: "boolean"
|
33
|
+
type: "boolean",
|
34
|
+
default: false
|
34
35
|
},
|
35
36
|
allowSwitch: {
|
36
|
-
type: "boolean"
|
37
|
+
type: "boolean",
|
38
|
+
default: false
|
37
39
|
}
|
38
40
|
},
|
39
41
|
additionalProperties: false
|
@@ -43,8 +45,8 @@ module.exports = {
|
|
43
45
|
|
44
46
|
create(context) {
|
45
47
|
const options = context.options[0];
|
46
|
-
const allowLoop =
|
47
|
-
const allowSwitch =
|
48
|
+
const allowLoop = options && options.allowLoop;
|
49
|
+
const allowSwitch = options && options.allowSwitch;
|
48
50
|
let scopeInfo = null;
|
49
51
|
|
50
52
|
/**
|
@@ -24,10 +24,12 @@ module.exports = {
|
|
24
24
|
type: "object",
|
25
25
|
properties: {
|
26
26
|
detectObjects: {
|
27
|
-
type: "boolean"
|
27
|
+
type: "boolean",
|
28
|
+
default: false
|
28
29
|
},
|
29
30
|
enforceConst: {
|
30
|
-
type: "boolean"
|
31
|
+
type: "boolean",
|
32
|
+
default: false
|
31
33
|
},
|
32
34
|
ignore: {
|
33
35
|
type: "array",
|
@@ -37,7 +39,8 @@ module.exports = {
|
|
37
39
|
uniqueItems: true
|
38
40
|
},
|
39
41
|
ignoreArrayIndexes: {
|
40
|
-
type: "boolean"
|
42
|
+
type: "boolean",
|
43
|
+
default: false
|
41
44
|
}
|
42
45
|
},
|
43
46
|
additionalProperties: false
|
@@ -42,10 +42,10 @@ const TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/;
|
|
42
42
|
* @param {Object|undefined} options - A options object to normalize.
|
43
43
|
* @returns {Object} Normalized option object.
|
44
44
|
*/
|
45
|
-
function normalizeOptions(options) {
|
46
|
-
const hasGroups =
|
45
|
+
function normalizeOptions(options = {}) {
|
46
|
+
const hasGroups = options.groups && options.groups.length > 0;
|
47
47
|
const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
|
48
|
-
const allowSamePrecedence =
|
48
|
+
const allowSamePrecedence = options.allowSamePrecedence !== false;
|
49
49
|
|
50
50
|
return {
|
51
51
|
groups,
|
@@ -95,7 +95,8 @@ module.exports = {
|
|
95
95
|
uniqueItems: true
|
96
96
|
},
|
97
97
|
allowSamePrecedence: {
|
98
|
-
type: "boolean"
|
98
|
+
type: "boolean",
|
99
|
+
default: true
|
99
100
|
}
|
100
101
|
},
|
101
102
|
additionalProperties: false
|
@@ -30,10 +30,12 @@ module.exports = {
|
|
30
30
|
type: "object",
|
31
31
|
properties: {
|
32
32
|
grouping: {
|
33
|
-
type: "boolean"
|
33
|
+
type: "boolean",
|
34
|
+
default: false
|
34
35
|
},
|
35
36
|
allowCall: {
|
36
|
-
type: "boolean"
|
37
|
+
type: "boolean",
|
38
|
+
default: false
|
37
39
|
}
|
38
40
|
},
|
39
41
|
additionalProperties: false
|
@@ -55,7 +55,7 @@ module.exports = {
|
|
55
55
|
},
|
56
56
|
|
57
57
|
create(context) {
|
58
|
-
const props = context.options[0] &&
|
58
|
+
const props = context.options[0] && context.options[0].props;
|
59
59
|
const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
|
60
60
|
|
61
61
|
/**
|
package/lib/rules/no-plusplus.js
CHANGED
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
{
|
25
25
|
type: "object",
|
26
26
|
properties: {
|
27
|
-
builtinGlobals: { type: "boolean" }
|
27
|
+
builtinGlobals: { type: "boolean", default: false }
|
28
28
|
},
|
29
29
|
additionalProperties: false
|
30
30
|
}
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
|
34
34
|
create(context) {
|
35
35
|
const options = {
|
36
|
-
builtinGlobals:
|
36
|
+
builtinGlobals: context.options[0] && context.options[0].builtinGlobals
|
37
37
|
};
|
38
38
|
|
39
39
|
/**
|
@@ -4,6 +4,19 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
/**
|
8
|
+
* Determines if a variable safely shadows undefined.
|
9
|
+
* This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
|
10
|
+
* as the global).
|
11
|
+
* @param {eslintScope.Variable} variable The variable to check
|
12
|
+
* @returns {boolean} true if this variable safely shadows `undefined`
|
13
|
+
*/
|
14
|
+
function safelyShadowsUndefined(variable) {
|
15
|
+
return variable.name === "undefined" &&
|
16
|
+
variable.references.every(ref => !ref.isWrite()) &&
|
17
|
+
variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
|
18
|
+
}
|
19
|
+
|
7
20
|
//------------------------------------------------------------------------------
|
8
21
|
// Rule Definition
|
9
22
|
//------------------------------------------------------------------------------
|
@@ -24,12 +37,13 @@ module.exports = {
|
|
24
37
|
|
25
38
|
create(context) {
|
26
39
|
|
27
|
-
|
40
|
+
|
41
|
+
const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
|
28
42
|
|
29
43
|
return {
|
30
44
|
"VariableDeclaration, :function, CatchClause"(node) {
|
31
45
|
for (const variable of context.getDeclaredVariables(node)) {
|
32
|
-
if (variable.defs.length > 0 && RESTRICTED.
|
46
|
+
if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
|
33
47
|
context.report({
|
34
48
|
node: variable.defs[0].name,
|
35
49
|
message: "Shadowing of global property '{{idName}}'.",
|
package/lib/rules/no-shadow.js
CHANGED
@@ -30,8 +30,8 @@ module.exports = {
|
|
30
30
|
{
|
31
31
|
type: "object",
|
32
32
|
properties: {
|
33
|
-
builtinGlobals: { type: "boolean" },
|
34
|
-
hoist: { enum: ["all", "functions", "never"] },
|
33
|
+
builtinGlobals: { type: "boolean", default: false },
|
34
|
+
hoist: { enum: ["all", "functions", "never"], default: "functions" },
|
35
35
|
allow: {
|
36
36
|
type: "array",
|
37
37
|
items: {
|
@@ -47,7 +47,7 @@ module.exports = {
|
|
47
47
|
create(context) {
|
48
48
|
|
49
49
|
const options = {
|
50
|
-
builtinGlobals:
|
50
|
+
builtinGlobals: context.options[0] && context.options[0].builtinGlobals,
|
51
51
|
hoist: (context.options[0] && context.options[0].hoist) || "functions",
|
52
52
|
allow: (context.options[0] && context.options[0].allow) || []
|
53
53
|
};
|
package/lib/rules/no-sync.js
CHANGED
package/lib/rules/no-tabs.js
CHANGED
@@ -32,10 +32,12 @@ module.exports = {
|
|
32
32
|
type: "object",
|
33
33
|
properties: {
|
34
34
|
skipBlankLines: {
|
35
|
-
type: "boolean"
|
35
|
+
type: "boolean",
|
36
|
+
default: false
|
36
37
|
},
|
37
38
|
ignoreComments: {
|
38
|
-
type: "boolean"
|
39
|
+
type: "boolean",
|
40
|
+
default: false
|
39
41
|
}
|
40
42
|
},
|
41
43
|
additionalProperties: false
|
@@ -52,7 +54,7 @@ module.exports = {
|
|
52
54
|
|
53
55
|
const options = context.options[0] || {},
|
54
56
|
skipBlankLines = options.skipBlankLines || false,
|
55
|
-
ignoreComments =
|
57
|
+
ignoreComments = options.ignoreComments || false;
|
56
58
|
|
57
59
|
/**
|
58
60
|
* Report the error message
|
package/lib/rules/no-undef.js
CHANGED
@@ -39,12 +39,16 @@ module.exports = {
|
|
39
39
|
type: "object",
|
40
40
|
properties: {
|
41
41
|
typeof: {
|
42
|
-
type: "boolean"
|
42
|
+
type: "boolean",
|
43
|
+
default: false
|
43
44
|
}
|
44
45
|
},
|
45
46
|
additionalProperties: false
|
46
47
|
}
|
47
|
-
]
|
48
|
+
],
|
49
|
+
messages: {
|
50
|
+
undef: "'{{name}}' is not defined."
|
51
|
+
}
|
48
52
|
},
|
49
53
|
|
50
54
|
create(context) {
|
@@ -64,7 +68,7 @@ module.exports = {
|
|
64
68
|
|
65
69
|
context.report({
|
66
70
|
node: identifier,
|
67
|
-
|
71
|
+
messageId: "undef",
|
68
72
|
data: identifier
|
69
73
|
});
|
70
74
|
});
|
@@ -31,13 +31,16 @@ module.exports = {
|
|
31
31
|
}
|
32
32
|
},
|
33
33
|
allowAfterThis: {
|
34
|
-
type: "boolean"
|
34
|
+
type: "boolean",
|
35
|
+
default: false
|
35
36
|
},
|
36
37
|
allowAfterSuper: {
|
37
|
-
type: "boolean"
|
38
|
+
type: "boolean",
|
39
|
+
default: false
|
38
40
|
},
|
39
41
|
enforceInMethodNames: {
|
40
|
-
type: "boolean"
|
42
|
+
type: "boolean",
|
43
|
+
default: false
|
41
44
|
}
|
42
45
|
},
|
43
46
|
additionalProperties: false
|
@@ -25,16 +25,17 @@ module.exports = {
|
|
25
25
|
url: "https://eslint.org/docs/rules/no-unexpected-multiline"
|
26
26
|
},
|
27
27
|
|
28
|
-
schema: []
|
28
|
+
schema: [],
|
29
|
+
messages: {
|
30
|
+
function: "Unexpected newline between function and ( of function call.",
|
31
|
+
property: "Unexpected newline between object and [ of property access.",
|
32
|
+
taggedTemplate: "Unexpected newline between template tag and template literal.",
|
33
|
+
division: "Unexpected newline between numerator and division operator."
|
34
|
+
}
|
29
35
|
},
|
30
36
|
|
31
37
|
create(context) {
|
32
38
|
|
33
|
-
const FUNCTION_MESSAGE = "Unexpected newline between function and ( of function call.";
|
34
|
-
const PROPERTY_MESSAGE = "Unexpected newline between object and [ of property access.";
|
35
|
-
const TAGGED_TEMPLATE_MESSAGE = "Unexpected newline between template tag and template literal.";
|
36
|
-
const DIVISION_MESSAGE = "Unexpected newline between numerator and division operator.";
|
37
|
-
|
38
39
|
const REGEX_FLAG_MATCHER = /^[gimsuy]+$/;
|
39
40
|
|
40
41
|
const sourceCode = context.getSourceCode();
|
@@ -43,16 +44,16 @@ module.exports = {
|
|
43
44
|
* Check to see if there is a newline between the node and the following open bracket
|
44
45
|
* line's expression
|
45
46
|
* @param {ASTNode} node The node to check.
|
46
|
-
* @param {string}
|
47
|
+
* @param {string} messageId The error messageId to use.
|
47
48
|
* @returns {void}
|
48
49
|
* @private
|
49
50
|
*/
|
50
|
-
function checkForBreakAfter(node,
|
51
|
+
function checkForBreakAfter(node, messageId) {
|
51
52
|
const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
|
52
53
|
const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
|
53
54
|
|
54
55
|
if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
|
55
|
-
context.report({ node, loc: openParen.loc.start,
|
56
|
+
context.report({ node, loc: openParen.loc.start, messageId, data: { char: openParen.value } });
|
56
57
|
}
|
57
58
|
}
|
58
59
|
|
@@ -66,21 +67,21 @@ module.exports = {
|
|
66
67
|
if (!node.computed) {
|
67
68
|
return;
|
68
69
|
}
|
69
|
-
checkForBreakAfter(node.object,
|
70
|
+
checkForBreakAfter(node.object, "property");
|
70
71
|
},
|
71
72
|
|
72
73
|
TaggedTemplateExpression(node) {
|
73
74
|
if (node.tag.loc.end.line === node.quasi.loc.start.line) {
|
74
75
|
return;
|
75
76
|
}
|
76
|
-
context.report({ node, loc: node.loc.start,
|
77
|
+
context.report({ node, loc: node.loc.start, messageId: "taggedTemplate" });
|
77
78
|
},
|
78
79
|
|
79
80
|
CallExpression(node) {
|
80
81
|
if (node.arguments.length === 0) {
|
81
82
|
return;
|
82
83
|
}
|
83
|
-
checkForBreakAfter(node.callee,
|
84
|
+
checkForBreakAfter(node.callee, "function");
|
84
85
|
},
|
85
86
|
|
86
87
|
"BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left"(node) {
|
@@ -92,7 +93,7 @@ module.exports = {
|
|
92
93
|
REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) &&
|
93
94
|
secondSlash.range[1] === tokenAfterOperator.range[0]
|
94
95
|
) {
|
95
|
-
checkForBreakAfter(node.left,
|
96
|
+
checkForBreakAfter(node.left, "division");
|
96
97
|
}
|
97
98
|
}
|
98
99
|
};
|
@@ -51,7 +51,10 @@ module.exports = {
|
|
51
51
|
},
|
52
52
|
|
53
53
|
schema: [],
|
54
|
-
fixable: "code"
|
54
|
+
fixable: "code",
|
55
|
+
messages: {
|
56
|
+
unexpected: "Unexpected negating the left operand of '{{operator}}' operator."
|
57
|
+
}
|
55
58
|
},
|
56
59
|
|
57
60
|
create(context) {
|
@@ -66,8 +69,8 @@ module.exports = {
|
|
66
69
|
context.report({
|
67
70
|
node,
|
68
71
|
loc: node.left.loc,
|
69
|
-
|
70
|
-
data: node,
|
72
|
+
messageId: "unexpected",
|
73
|
+
data: { operator: node.operator },
|
71
74
|
|
72
75
|
fix(fixer) {
|
73
76
|
const negationToken = sourceCode.getFirstToken(node.left);
|
@@ -24,13 +24,16 @@ module.exports = {
|
|
24
24
|
type: "object",
|
25
25
|
properties: {
|
26
26
|
allowShortCircuit: {
|
27
|
-
type: "boolean"
|
27
|
+
type: "boolean",
|
28
|
+
default: false
|
28
29
|
},
|
29
30
|
allowTernary: {
|
30
|
-
type: "boolean"
|
31
|
+
type: "boolean",
|
32
|
+
default: false
|
31
33
|
},
|
32
34
|
allowTaggedTemplates: {
|
33
|
-
type: "boolean"
|
35
|
+
type: "boolean",
|
36
|
+
default: false
|
34
37
|
}
|
35
38
|
},
|
36
39
|
additionalProperties: false
|
@@ -21,7 +21,12 @@ module.exports = {
|
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
24
|
-
|
24
|
+
|
25
|
+
fixable: "code",
|
26
|
+
|
27
|
+
messages: {
|
28
|
+
unused: "'{{name}}:' is defined but never used."
|
29
|
+
}
|
25
30
|
},
|
26
31
|
|
27
32
|
create(context) {
|
@@ -53,7 +58,7 @@ module.exports = {
|
|
53
58
|
if (!scopeInfo.used) {
|
54
59
|
context.report({
|
55
60
|
node: node.label,
|
56
|
-
|
61
|
+
messageId: "unused",
|
57
62
|
data: node.label,
|
58
63
|
fix(fixer) {
|
59
64
|
|
@@ -37,22 +37,26 @@ module.exports = {
|
|
37
37
|
type: "object",
|
38
38
|
properties: {
|
39
39
|
vars: {
|
40
|
-
enum: ["all", "local"]
|
40
|
+
enum: ["all", "local"],
|
41
|
+
default: "all"
|
41
42
|
},
|
42
43
|
varsIgnorePattern: {
|
43
44
|
type: "string"
|
44
45
|
},
|
45
46
|
args: {
|
46
|
-
enum: ["all", "after-used", "none"]
|
47
|
+
enum: ["all", "after-used", "none"],
|
48
|
+
default: "after-used"
|
47
49
|
},
|
48
50
|
ignoreRestSiblings: {
|
49
|
-
type: "boolean"
|
51
|
+
type: "boolean",
|
52
|
+
default: false
|
50
53
|
},
|
51
54
|
argsIgnorePattern: {
|
52
55
|
type: "string"
|
53
56
|
},
|
54
57
|
caughtErrors: {
|
55
|
-
enum: ["all", "none"]
|
58
|
+
enum: ["all", "none"],
|
59
|
+
default: "none"
|
56
60
|
},
|
57
61
|
caughtErrorsIgnorePattern: {
|
58
62
|
type: "string"
|
@@ -154,9 +154,9 @@ module.exports = {
|
|
154
154
|
{
|
155
155
|
type: "object",
|
156
156
|
properties: {
|
157
|
-
functions: { type: "boolean" },
|
158
|
-
classes: { type: "boolean" },
|
159
|
-
variables: { type: "boolean" }
|
157
|
+
functions: { type: "boolean", default: true },
|
158
|
+
classes: { type: "boolean", default: true },
|
159
|
+
variables: { type: "boolean", default: true }
|
160
160
|
},
|
161
161
|
additionalProperties: false
|
162
162
|
}
|
@@ -26,9 +26,9 @@ module.exports = {
|
|
26
26
|
{
|
27
27
|
type: "object",
|
28
28
|
properties: {
|
29
|
-
ignoreDestructuring: { type: "boolean" },
|
30
|
-
ignoreImport: { type: "boolean" },
|
31
|
-
ignoreExport: { type: "boolean" }
|
29
|
+
ignoreDestructuring: { type: "boolean", default: false },
|
30
|
+
ignoreImport: { type: "boolean", default: false },
|
31
|
+
ignoreExport: { type: "boolean", default: false }
|
32
32
|
},
|
33
33
|
additionalProperties: false
|
34
34
|
}
|
@@ -26,14 +26,16 @@ const OPTION_VALUE = {
|
|
26
26
|
type: "object",
|
27
27
|
properties: {
|
28
28
|
multiline: {
|
29
|
-
type: "boolean"
|
29
|
+
type: "boolean",
|
30
|
+
default: false
|
30
31
|
},
|
31
32
|
minProperties: {
|
32
33
|
type: "integer",
|
33
34
|
minimum: 0
|
34
35
|
},
|
35
36
|
consistent: {
|
36
|
-
type: "boolean"
|
37
|
+
type: "boolean",
|
38
|
+
default: false
|
37
39
|
}
|
38
40
|
},
|
39
41
|
additionalProperties: false,
|
@@ -59,9 +61,9 @@ function normalizeOptionValue(value) {
|
|
59
61
|
} else if (value === "never") {
|
60
62
|
minProperties = Number.POSITIVE_INFINITY;
|
61
63
|
} else {
|
62
|
-
multiline =
|
64
|
+
multiline = value.multiline;
|
63
65
|
minProperties = value.minProperties || Number.POSITIVE_INFINITY;
|
64
|
-
consistent =
|
66
|
+
consistent = value.consistent;
|
65
67
|
}
|
66
68
|
} else {
|
67
69
|
consistent = true;
|
@@ -25,10 +25,12 @@ module.exports = {
|
|
25
25
|
type: "object",
|
26
26
|
properties: {
|
27
27
|
allowAllPropertiesOnSameLine: {
|
28
|
-
type: "boolean"
|
28
|
+
type: "boolean",
|
29
|
+
default: false
|
29
30
|
},
|
30
31
|
allowMultiplePropertiesPerLine: { // Deprecated
|
31
|
-
type: "boolean"
|
32
|
+
type: "boolean",
|
33
|
+
default: false
|
32
34
|
}
|
33
35
|
},
|
34
36
|
additionalProperties: false
|
@@ -40,7 +42,7 @@ module.exports = {
|
|
40
42
|
|
41
43
|
create(context) {
|
42
44
|
const allowSameLine = context.options[0] && (
|
43
|
-
(
|
45
|
+
(context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */)
|
44
46
|
);
|
45
47
|
const errorMessage = allowSameLine
|
46
48
|
? "Object properties must go on a new line if they aren't all on the same line."
|