eslint 8.0.1 → 8.4.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 +8 -12
- package/conf/globals.js +144 -0
- package/lib/cli-engine/cli-engine.js +10 -21
- package/lib/cli.js +1 -1
- package/lib/config/default-config.js +11 -2
- package/lib/config/flat-config-array.js +2 -2
- package/lib/config/flat-config-helpers.js +67 -0
- package/lib/config/flat-config-schema.js +13 -8
- package/lib/config/rule-validator.js +28 -27
- package/lib/eslint/eslint.js +13 -18
- package/lib/linter/code-path-analysis/code-path-analyzer.js +6 -1
- package/lib/linter/code-path-analysis/code-path.js +1 -1
- package/lib/linter/linter.js +457 -45
- package/lib/linter/node-event-generator.js +7 -0
- package/lib/options.js +6 -6
- package/lib/rule-tester/rule-tester.js +5 -2
- package/lib/rules/accessor-pairs.js +1 -0
- package/lib/rules/array-bracket-newline.js +1 -0
- package/lib/rules/array-bracket-spacing.js +1 -0
- package/lib/rules/array-callback-return.js +1 -0
- package/lib/rules/array-element-newline.js +1 -0
- package/lib/rules/arrow-body-style.js +1 -0
- package/lib/rules/arrow-parens.js +1 -0
- package/lib/rules/arrow-spacing.js +1 -0
- package/lib/rules/block-scoped-var.js +3 -0
- package/lib/rules/block-spacing.js +11 -3
- package/lib/rules/brace-style.js +7 -0
- package/lib/rules/callback-return.js +1 -0
- package/lib/rules/camelcase.js +1 -0
- package/lib/rules/capitalized-comments.js +1 -0
- package/lib/rules/class-methods-use-this.js +11 -1
- package/lib/rules/comma-dangle.js +1 -0
- package/lib/rules/comma-spacing.js +1 -0
- package/lib/rules/comma-style.js +1 -0
- package/lib/rules/complexity.js +15 -6
- package/lib/rules/computed-property-spacing.js +1 -0
- package/lib/rules/consistent-return.js +1 -0
- package/lib/rules/consistent-this.js +1 -0
- package/lib/rules/constructor-super.js +1 -0
- package/lib/rules/curly.js +1 -0
- package/lib/rules/default-case-last.js +1 -0
- package/lib/rules/default-case.js +1 -0
- package/lib/rules/default-param-last.js +1 -0
- package/lib/rules/dot-location.js +1 -0
- package/lib/rules/dot-notation.js +1 -0
- package/lib/rules/eol-last.js +1 -0
- package/lib/rules/eqeqeq.js +1 -0
- package/lib/rules/for-direction.js +1 -0
- package/lib/rules/func-call-spacing.js +1 -0
- package/lib/rules/func-name-matching.js +1 -0
- package/lib/rules/func-names.js +1 -0
- package/lib/rules/func-style.js +1 -0
- package/lib/rules/function-call-argument-newline.js +1 -0
- package/lib/rules/function-paren-newline.js +1 -0
- package/lib/rules/generator-star-spacing.js +1 -0
- package/lib/rules/getter-return.js +1 -0
- package/lib/rules/global-require.js +1 -0
- package/lib/rules/grouped-accessor-pairs.js +1 -0
- package/lib/rules/guard-for-in.js +1 -0
- package/lib/rules/handle-callback-err.js +1 -0
- package/lib/rules/id-blacklist.js +1 -0
- package/lib/rules/id-denylist.js +1 -0
- package/lib/rules/id-length.js +1 -0
- package/lib/rules/id-match.js +1 -0
- package/lib/rules/implicit-arrow-linebreak.js +1 -0
- package/lib/rules/indent-legacy.js +1 -0
- package/lib/rules/indent.js +22 -0
- package/lib/rules/index.js +1 -0
- package/lib/rules/init-declarations.js +1 -0
- package/lib/rules/jsx-quotes.js +1 -0
- package/lib/rules/key-spacing.js +15 -13
- package/lib/rules/keyword-spacing.js +16 -1
- package/lib/rules/line-comment-position.js +1 -0
- package/lib/rules/linebreak-style.js +1 -0
- package/lib/rules/lines-around-comment.js +55 -7
- package/lib/rules/lines-around-directive.js +1 -0
- package/lib/rules/lines-between-class-members.js +1 -0
- package/lib/rules/max-classes-per-file.js +1 -0
- package/lib/rules/max-depth.js +3 -0
- package/lib/rules/max-len.js +1 -0
- package/lib/rules/max-lines-per-function.js +21 -2
- package/lib/rules/max-lines.js +1 -0
- package/lib/rules/max-nested-callbacks.js +1 -0
- package/lib/rules/max-params.js +1 -0
- package/lib/rules/max-statements-per-line.js +1 -0
- package/lib/rules/max-statements.js +11 -0
- package/lib/rules/multiline-comment-style.js +1 -0
- package/lib/rules/multiline-ternary.js +1 -0
- package/lib/rules/new-cap.js +1 -0
- package/lib/rules/new-parens.js +1 -0
- package/lib/rules/newline-after-var.js +1 -0
- package/lib/rules/newline-before-return.js +1 -0
- package/lib/rules/newline-per-chained-call.js +1 -0
- package/lib/rules/no-alert.js +1 -0
- package/lib/rules/no-array-constructor.js +1 -0
- package/lib/rules/no-async-promise-executor.js +1 -0
- package/lib/rules/no-await-in-loop.js +1 -0
- package/lib/rules/no-bitwise.js +1 -0
- package/lib/rules/no-buffer-constructor.js +1 -0
- package/lib/rules/no-caller.js +1 -0
- package/lib/rules/no-case-declarations.js +1 -0
- package/lib/rules/no-catch-shadow.js +1 -0
- package/lib/rules/no-class-assign.js +1 -0
- package/lib/rules/no-compare-neg-zero.js +1 -0
- package/lib/rules/no-cond-assign.js +1 -0
- package/lib/rules/no-confusing-arrow.js +1 -0
- package/lib/rules/no-console.js +1 -0
- package/lib/rules/no-const-assign.js +1 -0
- package/lib/rules/no-constant-condition.js +4 -1
- package/lib/rules/no-constructor-return.js +1 -0
- package/lib/rules/no-continue.js +1 -0
- package/lib/rules/no-control-regex.js +1 -0
- package/lib/rules/no-debugger.js +1 -0
- package/lib/rules/no-delete-var.js +1 -0
- package/lib/rules/no-div-regex.js +1 -0
- package/lib/rules/no-dupe-args.js +1 -0
- package/lib/rules/no-dupe-class-members.js +1 -0
- package/lib/rules/no-dupe-else-if.js +1 -0
- package/lib/rules/no-dupe-keys.js +1 -0
- package/lib/rules/no-duplicate-case.js +1 -0
- package/lib/rules/no-duplicate-imports.js +1 -0
- package/lib/rules/no-else-return.js +1 -0
- package/lib/rules/no-empty-character-class.js +1 -0
- package/lib/rules/no-empty-function.js +1 -0
- package/lib/rules/no-empty-pattern.js +1 -0
- package/lib/rules/no-empty.js +1 -0
- package/lib/rules/no-eq-null.js +1 -0
- package/lib/rules/no-eval.js +3 -0
- package/lib/rules/no-ex-assign.js +1 -0
- package/lib/rules/no-extend-native.js +1 -0
- package/lib/rules/no-extra-bind.js +1 -0
- package/lib/rules/no-extra-boolean-cast.js +1 -0
- package/lib/rules/no-extra-label.js +1 -0
- package/lib/rules/no-extra-parens.js +1 -0
- package/lib/rules/no-extra-semi.js +2 -1
- package/lib/rules/no-fallthrough.js +1 -0
- package/lib/rules/no-floating-decimal.js +1 -0
- package/lib/rules/no-func-assign.js +1 -0
- package/lib/rules/no-global-assign.js +1 -0
- package/lib/rules/no-implicit-coercion.js +1 -0
- package/lib/rules/no-implicit-globals.js +1 -0
- package/lib/rules/no-implied-eval.js +1 -0
- package/lib/rules/no-import-assign.js +1 -0
- package/lib/rules/no-inline-comments.js +1 -0
- package/lib/rules/no-inner-declarations.js +27 -4
- package/lib/rules/no-invalid-regexp.js +1 -0
- package/lib/rules/no-invalid-this.js +5 -0
- package/lib/rules/no-irregular-whitespace.js +1 -0
- package/lib/rules/no-iterator.js +1 -0
- package/lib/rules/no-label-var.js +1 -0
- package/lib/rules/no-labels.js +1 -0
- package/lib/rules/no-lone-blocks.js +9 -2
- package/lib/rules/no-lonely-if.js +1 -0
- package/lib/rules/no-loop-func.js +1 -0
- package/lib/rules/no-loss-of-precision.js +1 -0
- package/lib/rules/no-magic-numbers.js +1 -0
- package/lib/rules/no-misleading-character-class.js +1 -0
- package/lib/rules/no-mixed-operators.js +1 -0
- package/lib/rules/no-mixed-requires.js +1 -0
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -0
- package/lib/rules/no-multi-assign.js +1 -0
- package/lib/rules/no-multi-spaces.js +1 -0
- package/lib/rules/no-multi-str.js +1 -0
- package/lib/rules/no-multiple-empty-lines.js +1 -0
- package/lib/rules/no-native-reassign.js +1 -0
- package/lib/rules/no-negated-condition.js +1 -0
- package/lib/rules/no-negated-in-lhs.js +1 -0
- package/lib/rules/no-nested-ternary.js +1 -0
- package/lib/rules/no-new-func.js +1 -0
- package/lib/rules/no-new-object.js +1 -0
- package/lib/rules/no-new-require.js +1 -0
- package/lib/rules/no-new-symbol.js +1 -0
- package/lib/rules/no-new-wrappers.js +1 -0
- package/lib/rules/no-new.js +1 -0
- package/lib/rules/no-nonoctal-decimal-escape.js +1 -0
- package/lib/rules/no-obj-calls.js +1 -0
- package/lib/rules/no-octal-escape.js +1 -0
- package/lib/rules/no-octal.js +1 -0
- package/lib/rules/no-param-reassign.js +1 -0
- package/lib/rules/no-path-concat.js +1 -0
- package/lib/rules/no-plusplus.js +1 -0
- package/lib/rules/no-process-env.js +1 -0
- package/lib/rules/no-process-exit.js +1 -0
- package/lib/rules/no-promise-executor-return.js +1 -0
- package/lib/rules/no-proto.js +1 -0
- package/lib/rules/no-prototype-builtins.js +1 -0
- package/lib/rules/no-redeclare.js +3 -0
- package/lib/rules/no-regex-spaces.js +1 -0
- package/lib/rules/no-restricted-exports.js +1 -0
- package/lib/rules/no-restricted-globals.js +1 -0
- package/lib/rules/no-restricted-imports.js +1 -0
- package/lib/rules/no-restricted-modules.js +1 -0
- package/lib/rules/no-restricted-properties.js +1 -0
- package/lib/rules/no-restricted-syntax.js +1 -0
- package/lib/rules/no-return-assign.js +1 -0
- package/lib/rules/no-return-await.js +1 -0
- package/lib/rules/no-script-url.js +1 -0
- package/lib/rules/no-self-assign.js +1 -0
- package/lib/rules/no-self-compare.js +1 -0
- package/lib/rules/no-sequences.js +1 -0
- package/lib/rules/no-setter-return.js +1 -0
- package/lib/rules/no-shadow-restricted-names.js +1 -0
- package/lib/rules/no-shadow.js +1 -0
- package/lib/rules/no-spaced-func.js +1 -0
- package/lib/rules/no-sparse-arrays.js +1 -0
- package/lib/rules/no-sync.js +1 -0
- package/lib/rules/no-tabs.js +1 -0
- package/lib/rules/no-template-curly-in-string.js +1 -0
- package/lib/rules/no-ternary.js +1 -0
- package/lib/rules/no-this-before-super.js +1 -0
- package/lib/rules/no-throw-literal.js +1 -0
- package/lib/rules/no-trailing-spaces.js +1 -0
- package/lib/rules/no-undef-init.js +1 -0
- package/lib/rules/no-undef.js +1 -0
- package/lib/rules/no-undefined.js +1 -0
- package/lib/rules/no-underscore-dangle.js +1 -0
- package/lib/rules/no-unexpected-multiline.js +1 -0
- package/lib/rules/no-unmodified-loop-condition.js +1 -0
- package/lib/rules/no-unneeded-ternary.js +1 -0
- package/lib/rules/no-unreachable-loop.js +1 -0
- package/lib/rules/no-unreachable.js +1 -0
- package/lib/rules/no-unsafe-finally.js +1 -0
- package/lib/rules/no-unsafe-negation.js +1 -0
- package/lib/rules/no-unsafe-optional-chaining.js +1 -0
- package/lib/rules/no-unused-expressions.js +7 -0
- package/lib/rules/no-unused-labels.js +1 -0
- package/lib/rules/no-unused-private-class-members.js +195 -0
- package/lib/rules/no-unused-vars.js +1 -0
- package/lib/rules/no-use-before-define.js +176 -74
- package/lib/rules/no-useless-backreference.js +1 -0
- package/lib/rules/no-useless-call.js +1 -0
- package/lib/rules/no-useless-catch.js +1 -0
- package/lib/rules/no-useless-computed-key.js +1 -0
- package/lib/rules/no-useless-concat.js +1 -0
- package/lib/rules/no-useless-constructor.js +1 -0
- package/lib/rules/no-useless-escape.js +1 -0
- package/lib/rules/no-useless-rename.js +1 -0
- package/lib/rules/no-useless-return.js +1 -0
- package/lib/rules/no-var.js +1 -0
- package/lib/rules/no-void.js +1 -0
- package/lib/rules/no-warning-comments.js +1 -0
- package/lib/rules/no-whitespace-before-property.js +1 -0
- package/lib/rules/no-with.js +1 -0
- package/lib/rules/nonblock-statement-body-position.js +1 -0
- package/lib/rules/object-curly-newline.js +1 -0
- package/lib/rules/object-curly-spacing.js +1 -0
- package/lib/rules/object-property-newline.js +1 -0
- package/lib/rules/object-shorthand.js +1 -0
- package/lib/rules/one-var-declaration-per-line.js +1 -0
- package/lib/rules/one-var.js +6 -1
- package/lib/rules/operator-assignment.js +1 -0
- package/lib/rules/operator-linebreak.js +1 -0
- package/lib/rules/padded-blocks.js +9 -0
- package/lib/rules/padding-line-between-statements.js +3 -0
- package/lib/rules/prefer-arrow-callback.js +1 -0
- package/lib/rules/prefer-const.js +2 -1
- package/lib/rules/prefer-destructuring.js +1 -0
- package/lib/rules/prefer-exponentiation-operator.js +1 -0
- package/lib/rules/prefer-named-capture-group.js +1 -0
- package/lib/rules/prefer-numeric-literals.js +1 -0
- package/lib/rules/prefer-object-spread.js +1 -0
- package/lib/rules/prefer-promise-reject-errors.js +1 -0
- package/lib/rules/prefer-reflect.js +1 -0
- package/lib/rules/prefer-regex-literals.js +1 -0
- package/lib/rules/prefer-rest-params.js +1 -0
- package/lib/rules/prefer-spread.js +1 -0
- package/lib/rules/prefer-template.js +1 -0
- package/lib/rules/quote-props.js +1 -0
- package/lib/rules/quotes.js +1 -0
- package/lib/rules/radix.js +1 -0
- package/lib/rules/require-atomic-updates.js +15 -2
- package/lib/rules/require-await.js +1 -0
- package/lib/rules/require-jsdoc.js +1 -0
- package/lib/rules/require-unicode-regexp.js +1 -0
- package/lib/rules/require-yield.js +1 -0
- package/lib/rules/rest-spread-spacing.js +1 -0
- package/lib/rules/semi-spacing.js +1 -0
- package/lib/rules/semi-style.js +9 -2
- package/lib/rules/semi.js +19 -9
- package/lib/rules/sort-imports.js +1 -0
- package/lib/rules/sort-keys.js +1 -0
- package/lib/rules/sort-vars.js +1 -0
- package/lib/rules/space-before-blocks.js +1 -0
- package/lib/rules/space-before-function-paren.js +1 -0
- package/lib/rules/space-in-parens.js +1 -0
- package/lib/rules/space-infix-ops.js +1 -0
- package/lib/rules/space-unary-ops.js +1 -0
- package/lib/rules/spaced-comment.js +1 -0
- package/lib/rules/strict.js +1 -0
- package/lib/rules/switch-colon-spacing.js +1 -0
- package/lib/rules/symbol-description.js +1 -0
- package/lib/rules/template-curly-spacing.js +1 -0
- package/lib/rules/template-tag-spacing.js +1 -0
- package/lib/rules/unicode-bom.js +1 -0
- package/lib/rules/use-isnan.js +1 -0
- package/lib/rules/utils/ast-utils.js +15 -3
- package/lib/rules/valid-jsdoc.js +1 -0
- package/lib/rules/valid-typeof.js +1 -0
- package/lib/rules/vars-on-top.js +26 -12
- package/lib/rules/wrap-iife.js +1 -0
- package/lib/rules/wrap-regex.js +1 -0
- package/lib/rules/yield-star-spacing.js +1 -0
- package/lib/rules/yoda.js +1 -0
- package/lib/shared/types.js +10 -0
- package/package.json +12 -12
package/lib/rules/no-caller.js
CHANGED
package/lib/rules/no-console.js
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
// Rule Definition
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
|
16
|
+
/** @type {import('../shared/types').Rule} */
|
16
17
|
module.exports = {
|
17
18
|
meta: {
|
18
19
|
type: "problem",
|
@@ -138,6 +139,7 @@ module.exports = {
|
|
138
139
|
case "ArrowFunctionExpression":
|
139
140
|
case "FunctionExpression":
|
140
141
|
case "ObjectExpression":
|
142
|
+
case "ClassExpression":
|
141
143
|
return true;
|
142
144
|
case "TemplateLiteral":
|
143
145
|
return (inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length)) ||
|
@@ -179,7 +181,8 @@ module.exports = {
|
|
179
181
|
isLeftShortCircuit ||
|
180
182
|
isRightShortCircuit;
|
181
183
|
}
|
182
|
-
|
184
|
+
case "NewExpression":
|
185
|
+
return inBooleanPosition;
|
183
186
|
case "AssignmentExpression":
|
184
187
|
if (node.operator === "=") {
|
185
188
|
return isConstant(node.right, inBooleanPosition);
|
package/lib/rules/no-continue.js
CHANGED
package/lib/rules/no-debugger.js
CHANGED
@@ -46,6 +46,7 @@ const splitByAnd = splitByLogicalOperator.bind(null, "&&");
|
|
46
46
|
// Rule Definition
|
47
47
|
//------------------------------------------------------------------------------
|
48
48
|
|
49
|
+
/** @type {import('../shared/types').Rule} */
|
49
50
|
module.exports = {
|
50
51
|
meta: {
|
51
52
|
type: "problem",
|
@@ -16,6 +16,7 @@ const FixTracker = require("./utils/fix-tracker");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
+
/** @type {import('../shared/types').Rule} */
|
19
20
|
module.exports = {
|
20
21
|
meta: {
|
21
22
|
type: "suggestion",
|
@@ -24,6 +24,7 @@ const regex = /^([^\\[]|\\.|\[([^\\\]]|\\.)+\])*$/u;
|
|
24
24
|
// Rule Definition
|
25
25
|
//------------------------------------------------------------------------------
|
26
26
|
|
27
|
+
/** @type {import('../shared/types').Rule} */
|
27
28
|
module.exports = {
|
28
29
|
meta: {
|
29
30
|
type: "problem",
|
package/lib/rules/no-empty.js
CHANGED
package/lib/rules/no-eq-null.js
CHANGED
package/lib/rules/no-eval.js
CHANGED
@@ -37,6 +37,7 @@ function isMember(node, name) {
|
|
37
37
|
// Rule Definition
|
38
38
|
//------------------------------------------------------------------------------
|
39
39
|
|
40
|
+
/** @type {import('../shared/types').Rule} */
|
40
41
|
module.exports = {
|
41
42
|
meta: {
|
42
43
|
type: "suggestion",
|
@@ -248,6 +249,8 @@ module.exports = {
|
|
248
249
|
"ArrowFunctionExpression:exit": exitVarScope,
|
249
250
|
"PropertyDefinition > *.value": enterVarScope,
|
250
251
|
"PropertyDefinition > *.value:exit": exitVarScope,
|
252
|
+
StaticBlock: enterVarScope,
|
253
|
+
"StaticBlock:exit": exitVarScope,
|
251
254
|
|
252
255
|
ThisExpression(node) {
|
253
256
|
if (!isMember(node.parent, "eval")) {
|
@@ -20,6 +20,7 @@ const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpre
|
|
20
20
|
// Rule Definition
|
21
21
|
//------------------------------------------------------------------------------
|
22
22
|
|
23
|
+
/** @type {import('../shared/types').Rule} */
|
23
24
|
module.exports = {
|
24
25
|
meta: {
|
25
26
|
type: "suggestion",
|
@@ -16,6 +16,7 @@ const astUtils = require("./utils/ast-utils");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
+
/** @type {import('../shared/types').Rule} */
|
19
20
|
module.exports = {
|
20
21
|
meta: {
|
21
22
|
type: "suggestion",
|
@@ -116,7 +117,7 @@ module.exports = {
|
|
116
117
|
* @param {Node} node A MethodDefinition node of the start point.
|
117
118
|
* @returns {void}
|
118
119
|
*/
|
119
|
-
"MethodDefinition, PropertyDefinition"(node) {
|
120
|
+
"MethodDefinition, PropertyDefinition, StaticBlock"(node) {
|
120
121
|
checkForPartOfClassBody(sourceCode.getTokenAfter(node));
|
121
122
|
}
|
122
123
|
};
|
@@ -167,6 +167,7 @@ function getNonEmptyOperand(node) {
|
|
167
167
|
// Rule Definition
|
168
168
|
//------------------------------------------------------------------------------
|
169
169
|
|
170
|
+
/** @type {import('../shared/types').Rule} */
|
170
171
|
module.exports = {
|
171
172
|
meta: {
|
172
173
|
type: "suggestion",
|
@@ -16,6 +16,7 @@ const { getStaticValue } = require("eslint-utils");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
+
/** @type {import('../shared/types').Rule} */
|
19
20
|
module.exports = {
|
20
21
|
meta: {
|
21
22
|
type: "suggestion",
|
@@ -15,9 +15,34 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
const validParent = new Set(["Program", "ExportNamedDeclaration", "ExportDefaultDeclaration"]);
|
18
|
+
const validParent = new Set(["Program", "StaticBlock", "ExportNamedDeclaration", "ExportDefaultDeclaration"]);
|
19
19
|
const validBlockStatementParent = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
|
20
20
|
|
21
|
+
/**
|
22
|
+
* Finds the nearest enclosing context where this rule allows declarations and returns its description.
|
23
|
+
* @param {ASTNode} node Node to search from.
|
24
|
+
* @returns {string} Description. One of "program", "function body", "class static block body".
|
25
|
+
*/
|
26
|
+
function getAllowedBodyDescription(node) {
|
27
|
+
let { parent } = node;
|
28
|
+
|
29
|
+
while (parent) {
|
30
|
+
|
31
|
+
if (parent.type === "StaticBlock") {
|
32
|
+
return "class static block body";
|
33
|
+
}
|
34
|
+
|
35
|
+
if (astUtils.isFunction(parent)) {
|
36
|
+
return "function body";
|
37
|
+
}
|
38
|
+
|
39
|
+
({ parent } = parent);
|
40
|
+
}
|
41
|
+
|
42
|
+
return "program";
|
43
|
+
}
|
44
|
+
|
45
|
+
/** @type {import('../shared/types').Rule} */
|
21
46
|
module.exports = {
|
22
47
|
meta: {
|
23
48
|
type: "problem",
|
@@ -59,14 +84,12 @@ module.exports = {
|
|
59
84
|
return;
|
60
85
|
}
|
61
86
|
|
62
|
-
const upperFunction = astUtils.getUpperFunction(parent);
|
63
|
-
|
64
87
|
context.report({
|
65
88
|
node,
|
66
89
|
messageId: "moveDeclToRoot",
|
67
90
|
data: {
|
68
91
|
type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
|
69
|
-
body: (
|
92
|
+
body: getAllowedBodyDescription(node)
|
70
93
|
}
|
71
94
|
});
|
72
95
|
}
|
@@ -15,6 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
+
/** @type {import('../shared/types').Rule} */
|
18
19
|
module.exports = {
|
19
20
|
meta: {
|
20
21
|
type: "suggestion",
|
@@ -132,6 +133,10 @@ module.exports = {
|
|
132
133
|
"PropertyDefinition > *.value": enterFunction,
|
133
134
|
"PropertyDefinition > *.value:exit": exitFunction,
|
134
135
|
|
136
|
+
// Class static blocks are implicit functions.
|
137
|
+
StaticBlock: enterFunction,
|
138
|
+
"StaticBlock:exit": exitFunction,
|
139
|
+
|
135
140
|
// Reports if `this` of the current context is invalid.
|
136
141
|
ThisExpression(node) {
|
137
142
|
const current = stack.getCurrent();
|
@@ -25,6 +25,7 @@ const LINE_BREAK = astUtils.createGlobalLinebreakMatcher();
|
|
25
25
|
// Rule Definition
|
26
26
|
//------------------------------------------------------------------------------
|
27
27
|
|
28
|
+
/** @type {import('../shared/types').Rule} */
|
28
29
|
module.exports = {
|
29
30
|
meta: {
|
30
31
|
type: "problem",
|
package/lib/rules/no-iterator.js
CHANGED
@@ -15,6 +15,7 @@ const { getStaticPropertyName } = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
+
/** @type {import('../shared/types').Rule} */
|
18
19
|
module.exports = {
|
19
20
|
meta: {
|
20
21
|
type: "suggestion",
|
package/lib/rules/no-labels.js
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
+
/** @type {import('../shared/types').Rule} */
|
12
13
|
module.exports = {
|
13
14
|
meta: {
|
14
15
|
type: "suggestion",
|
@@ -39,7 +40,9 @@ module.exports = {
|
|
39
40
|
* @returns {void}
|
40
41
|
*/
|
41
42
|
function report(node) {
|
42
|
-
const messageId = node.parent.type === "BlockStatement"
|
43
|
+
const messageId = node.parent.type === "BlockStatement" || node.parent.type === "StaticBlock"
|
44
|
+
? "redundantNestedBlock"
|
45
|
+
: "redundantBlock";
|
43
46
|
|
44
47
|
context.report({
|
45
48
|
node,
|
@@ -54,6 +57,7 @@ module.exports = {
|
|
54
57
|
*/
|
55
58
|
function isLoneBlock(node) {
|
56
59
|
return node.parent.type === "BlockStatement" ||
|
60
|
+
node.parent.type === "StaticBlock" ||
|
57
61
|
node.parent.type === "Program" ||
|
58
62
|
|
59
63
|
// Don't report blocks in switch cases if the block is the only statement of the case.
|
@@ -99,7 +103,10 @@ module.exports = {
|
|
99
103
|
loneBlocks.pop();
|
100
104
|
report(node);
|
101
105
|
} else if (
|
102
|
-
|
106
|
+
(
|
107
|
+
node.parent.type === "BlockStatement" ||
|
108
|
+
node.parent.type === "StaticBlock"
|
109
|
+
) &&
|
103
110
|
node.parent.body.length === 1
|
104
111
|
) {
|
105
112
|
report(node);
|
@@ -148,6 +148,7 @@ function isSafe(loopNode, reference) {
|
|
148
148
|
// Rule Definition
|
149
149
|
//------------------------------------------------------------------------------
|
150
150
|
|
151
|
+
/** @type {import('../shared/types').Rule} */
|
151
152
|
module.exports = {
|
152
153
|
meta: {
|
153
154
|
type: "suggestion",
|