oxlint-plugin-eslint 1.52.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/LICENSE +22 -0
- package/README.md +36 -0
- package/common/ast-utils.cjs +5843 -0
- package/common/chunk.cjs +9 -0
- package/common/eslint-utils.cjs +1633 -0
- package/common/fix-tracker.cjs +89 -0
- package/common/ignore.cjs +123 -0
- package/common/keywords.cjs +15 -0
- package/common/regexpp.cjs +1720 -0
- package/common/regular-expressions.cjs +40 -0
- package/common/string-utils.cjs +39 -0
- package/index.js +7477 -0
- package/package.json +34 -0
- package/rules/accessor-pairs.cjs +233 -0
- package/rules/array-bracket-newline.cjs +172 -0
- package/rules/array-bracket-spacing.cjs +184 -0
- package/rules/array-callback-return.cjs +262 -0
- package/rules/array-element-newline.cjs +178 -0
- package/rules/arrow-body-style.cjs +135 -0
- package/rules/arrow-parens.cjs +130 -0
- package/rules/arrow-spacing.cjs +129 -0
- package/rules/block-scoped-var.cjs +101 -0
- package/rules/block-spacing.cjs +125 -0
- package/rules/brace-style.cjs +141 -0
- package/rules/callback-return.cjs +117 -0
- package/rules/camelcase.cjs +194 -0
- package/rules/capitalized-comments.cjs +168 -0
- package/rules/class-methods-use-this.cjs +155 -0
- package/rules/comma-dangle.cjs +274 -0
- package/rules/comma-spacing.cjs +111 -0
- package/rules/comma-style.cjs +180 -0
- package/rules/complexity.cjs +100 -0
- package/rules/computed-property-spacing.cjs +155 -0
- package/rules/consistent-return.cjs +113 -0
- package/rules/consistent-this.cjs +109 -0
- package/rules/constructor-super.cjs +207 -0
- package/rules/curly.cjs +173 -0
- package/rules/default-case-last.cjs +36 -0
- package/rules/default-case.cjs +50 -0
- package/rules/default-param-last.cjs +61 -0
- package/rules/dot-location.cjs +87 -0
- package/rules/dot-notation.cjs +77 -0
- package/rules/eol-last.cjs +91 -0
- package/rules/eqeqeq.cjs +127 -0
- package/rules/for-direction.cjs +94 -0
- package/rules/func-call-spacing.cjs +127 -0
- package/rules/func-name-matching.cjs +138 -0
- package/rules/func-names.cjs +121 -0
- package/rules/func-style.cjs +103 -0
- package/rules/function-call-argument-newline.cjs +109 -0
- package/rules/function-paren-newline.cjs +173 -0
- package/rules/generator-star-spacing.cjs +174 -0
- package/rules/getter-return.cjs +129 -0
- package/rules/global-require.cjs +84 -0
- package/rules/grouped-accessor-pairs.cjs +146 -0
- package/rules/guard-for-in.cjs +39 -0
- package/rules/handle-callback-err.cjs +86 -0
- package/rules/id-blacklist.cjs +135 -0
- package/rules/id-denylist.cjs +126 -0
- package/rules/id-length.cjs +119 -0
- package/rules/id-match.cjs +139 -0
- package/rules/implicit-arrow-linebreak.cjs +76 -0
- package/rules/indent-legacy.cjs +520 -0
- package/rules/indent.cjs +842 -0
- package/rules/init-declarations.cjs +88 -0
- package/rules/jsx-quotes.cjs +84 -0
- package/rules/key-spacing.cjs +399 -0
- package/rules/keyword-spacing.cjs +464 -0
- package/rules/line-comment-position.cjs +75 -0
- package/rules/linebreak-style.cjs +89 -0
- package/rules/lines-around-comment.cjs +290 -0
- package/rules/lines-around-directive.cjs +129 -0
- package/rules/lines-between-class-members.cjs +212 -0
- package/rules/logical-assignment-operators.cjs +305 -0
- package/rules/max-classes-per-file.cjs +61 -0
- package/rules/max-depth.cjs +117 -0
- package/rules/max-len.cjs +256 -0
- package/rules/max-lines-per-function.cjs +116 -0
- package/rules/max-lines.cjs +109 -0
- package/rules/max-nested-callbacks.cjs +78 -0
- package/rules/max-params.cjs +78 -0
- package/rules/max-statements-per-line.cjs +147 -0
- package/rules/max-statements.cjs +119 -0
- package/rules/multiline-comment-style.cjs +319 -0
- package/rules/multiline-ternary.cjs +106 -0
- package/rules/new-cap.cjs +139 -0
- package/rules/new-parens.cjs +70 -0
- package/rules/newline-after-var.cjs +159 -0
- package/rules/newline-before-return.cjs +128 -0
- package/rules/newline-per-chained-call.cjs +100 -0
- package/rules/no-alert.cjs +84 -0
- package/rules/no-array-constructor.cjs +91 -0
- package/rules/no-async-promise-executor.cjs +33 -0
- package/rules/no-await-in-loop.cjs +75 -0
- package/rules/no-bitwise.cjs +106 -0
- package/rules/no-buffer-constructor.cjs +51 -0
- package/rules/no-caller.cjs +34 -0
- package/rules/no-case-declarations.cjs +56 -0
- package/rules/no-catch-shadow.cjs +57 -0
- package/rules/no-class-assign.cjs +55 -0
- package/rules/no-compare-neg-zero.cjs +52 -0
- package/rules/no-cond-assign.cjs +104 -0
- package/rules/no-confusing-arrow.cjs +87 -0
- package/rules/no-console.cjs +138 -0
- package/rules/no-const-assign.cjs +50 -0
- package/rules/no-constant-binary-expression.cjs +284 -0
- package/rules/no-constant-condition.cjs +119 -0
- package/rules/no-constructor-return.cjs +43 -0
- package/rules/no-continue.cjs +33 -0
- package/rules/no-control-regex.cjs +74 -0
- package/rules/no-debugger.cjs +33 -0
- package/rules/no-delete-var.cjs +32 -0
- package/rules/no-div-regex.cjs +39 -0
- package/rules/no-dupe-args.cjs +61 -0
- package/rules/no-dupe-class-members.cjs +77 -0
- package/rules/no-dupe-else-if.cjs +74 -0
- package/rules/no-dupe-keys.cjs +88 -0
- package/rules/no-duplicate-case.cjs +49 -0
- package/rules/no-duplicate-imports.cjs +166 -0
- package/rules/no-else-return.cjs +182 -0
- package/rules/no-empty-character-class.cjs +47 -0
- package/rules/no-empty-function.cjs +141 -0
- package/rules/no-empty-pattern.cjs +50 -0
- package/rules/no-empty-static-block.cjs +50 -0
- package/rules/no-empty.cjs +78 -0
- package/rules/no-eq-null.cjs +34 -0
- package/rules/no-eval.cjs +165 -0
- package/rules/no-ex-assign.cjs +45 -0
- package/rules/no-extend-native.cjs +103 -0
- package/rules/no-extra-bind.cjs +127 -0
- package/rules/no-extra-boolean-cast.cjs +159 -0
- package/rules/no-extra-label.cjs +116 -0
- package/rules/no-extra-parens.cjs +665 -0
- package/rules/no-extra-semi.cjs +103 -0
- package/rules/no-fallthrough.cjs +136 -0
- package/rules/no-floating-decimal.cjs +66 -0
- package/rules/no-func-assign.cjs +63 -0
- package/rules/no-global-assign.cjs +62 -0
- package/rules/no-implicit-coercion.cjs +219 -0
- package/rules/no-implicit-globals.cjs +77 -0
- package/rules/no-implied-eval.cjs +87 -0
- package/rules/no-import-assign.cjs +123 -0
- package/rules/no-inline-comments.cjs +57 -0
- package/rules/no-inner-declarations.cjs +82 -0
- package/rules/no-invalid-regexp.cjs +130 -0
- package/rules/no-invalid-this.cjs +90 -0
- package/rules/no-irregular-whitespace.cjs +157 -0
- package/rules/no-iterator.cjs +34 -0
- package/rules/no-label-var.cjs +46 -0
- package/rules/no-labels.cjs +106 -0
- package/rules/no-lone-blocks.cjs +75 -0
- package/rules/no-lonely-if.cjs +42 -0
- package/rules/no-loop-func.cjs +143 -0
- package/rules/no-loss-of-precision.cjs +160 -0
- package/rules/no-magic-numbers.cjs +222 -0
- package/rules/no-misleading-character-class.cjs +500 -0
- package/rules/no-mixed-operators.cjs +197 -0
- package/rules/no-mixed-requires.cjs +117 -0
- package/rules/no-mixed-spaces-and-tabs.cjs +87 -0
- package/rules/no-multi-assign.cjs +38 -0
- package/rules/no-multi-spaces.cjs +95 -0
- package/rules/no-multi-str.cjs +44 -0
- package/rules/no-multiple-empty-lines.cjs +112 -0
- package/rules/no-native-reassign.cjs +72 -0
- package/rules/no-negated-condition.cjs +77 -0
- package/rules/no-negated-in-lhs.cjs +43 -0
- package/rules/no-nested-ternary.cjs +33 -0
- package/rules/no-new-func.cjs +50 -0
- package/rules/no-new-native-nonconstructor.cjs +42 -0
- package/rules/no-new-object.cjs +47 -0
- package/rules/no-new-require.cjs +50 -0
- package/rules/no-new-symbol.cjs +48 -0
- package/rules/no-new-wrappers.cjs +44 -0
- package/rules/no-new.cjs +33 -0
- package/rules/no-nonoctal-decimal-escape.cjs +80 -0
- package/rules/no-obj-calls.cjs +64 -0
- package/rules/no-object-constructor.cjs +69 -0
- package/rules/no-octal-escape.cjs +35 -0
- package/rules/no-octal.cjs +32 -0
- package/rules/no-param-reassign.cjs +135 -0
- package/rules/no-path-concat.cjs +52 -0
- package/rules/no-plusplus.cjs +64 -0
- package/rules/no-process-env.cjs +51 -0
- package/rules/no-process-exit.cjs +50 -0
- package/rules/no-promise-executor-return.cjs +131 -0
- package/rules/no-proto.cjs +34 -0
- package/rules/no-prototype-builtins.cjs +85 -0
- package/rules/no-redeclare.cjs +103 -0
- package/rules/no-regex-spaces.cjs +115 -0
- package/rules/no-restricted-exports.cjs +117 -0
- package/rules/no-restricted-globals.cjs +147 -0
- package/rules/no-restricted-imports.cjs +421 -0
- package/rules/no-restricted-modules.cjs +144 -0
- package/rules/no-restricted-properties.cjs +123 -0
- package/rules/no-restricted-syntax.cjs +49 -0
- package/rules/no-return-assign.cjs +45 -0
- package/rules/no-return-await.cjs +88 -0
- package/rules/no-script-url.cjs +49 -0
- package/rules/no-self-assign.cjs +88 -0
- package/rules/no-self-compare.cjs +53 -0
- package/rules/no-sequences.cjs +81 -0
- package/rules/no-setter-return.cjs +110 -0
- package/rules/no-shadow-restricted-names.cjs +60 -0
- package/rules/no-shadow.cjs +302 -0
- package/rules/no-spaced-func.cjs +69 -0
- package/rules/no-sparse-arrays.cjs +40 -0
- package/rules/no-sync.cjs +58 -0
- package/rules/no-tabs.cjs +73 -0
- package/rules/no-template-curly-in-string.cjs +33 -0
- package/rules/no-ternary.cjs +33 -0
- package/rules/no-this-before-super.cjs +177 -0
- package/rules/no-throw-literal.cjs +40 -0
- package/rules/no-trailing-spaces.cjs +123 -0
- package/rules/no-unassigned-vars.cjs +54 -0
- package/rules/no-undef-init.cjs +46 -0
- package/rules/no-undef.cjs +51 -0
- package/rules/no-undefined.cjs +58 -0
- package/rules/no-underscore-dangle.cjs +211 -0
- package/rules/no-unexpected-multiline.cjs +76 -0
- package/rules/no-unmodified-loop-condition.cjs +849 -0
- package/rules/no-unneeded-ternary.cjs +112 -0
- package/rules/no-unreachable-loop.cjs +128 -0
- package/rules/no-unreachable.cjs +195 -0
- package/rules/no-unsafe-finally.cjs +67 -0
- package/rules/no-unsafe-negation.cjs +86 -0
- package/rules/no-unsafe-optional-chaining.cjs +164 -0
- package/rules/no-unused-expressions.cjs +163 -0
- package/rules/no-unused-labels.cjs +97 -0
- package/rules/no-unused-private-class-members.cjs +69 -0
- package/rules/no-unused-vars.cjs +639 -0
- package/rules/no-use-before-define.cjs +245 -0
- package/rules/no-useless-assignment.cjs +250 -0
- package/rules/no-useless-backreference.cjs +137 -0
- package/rules/no-useless-call.cjs +57 -0
- package/rules/no-useless-catch.cjs +38 -0
- package/rules/no-useless-computed-key.cjs +106 -0
- package/rules/no-useless-concat.cjs +78 -0
- package/rules/no-useless-constructor.cjs +152 -0
- package/rules/no-useless-escape.cjs +164 -0
- package/rules/no-useless-rename.cjs +94 -0
- package/rules/no-useless-return.cjs +229 -0
- package/rules/no-var.cjs +235 -0
- package/rules/no-void.cjs +39 -0
- package/rules/no-warning-comments.cjs +112 -0
- package/rules/no-whitespace-before-property.cjs +72 -0
- package/rules/no-with.cjs +32 -0
- package/rules/nonblock-statement-body-position.cjs +107 -0
- package/rules/object-curly-newline.cjs +194 -0
- package/rules/object-curly-spacing.cjs +225 -0
- package/rules/object-property-newline.cjs +81 -0
- package/rules/object-shorthand.cjs +284 -0
- package/rules/one-var-declaration-per-line.cjs +75 -0
- package/rules/one-var.cjs +378 -0
- package/rules/operator-assignment.cjs +146 -0
- package/rules/operator-linebreak.cjs +150 -0
- package/rules/padded-blocks.cjs +192 -0
- package/rules/padding-line-between-statements.cjs +377 -0
- package/rules/prefer-arrow-callback.cjs +185 -0
- package/rules/prefer-const.cjs +240 -0
- package/rules/prefer-destructuring.cjs +188 -0
- package/rules/prefer-exponentiation-operator.cjs +100 -0
- package/rules/prefer-named-capture-group.cjs +111 -0
- package/rules/prefer-numeric-literals.cjs +75 -0
- package/rules/prefer-object-has-own.cjs +54 -0
- package/rules/prefer-object-spread.cjs +170 -0
- package/rules/prefer-promise-reject-errors.cjs +62 -0
- package/rules/prefer-reflect.cjs +100 -0
- package/rules/prefer-regex-literals.cjs +256 -0
- package/rules/prefer-rest-params.cjs +80 -0
- package/rules/prefer-spread.cjs +57 -0
- package/rules/prefer-template.cjs +147 -0
- package/rules/preserve-caught-error.cjs +196 -0
- package/rules/quote-props.cjs +224 -0
- package/rules/quotes.cjs +187 -0
- package/rules/radix.cjs +124 -0
- package/rules/require-atomic-updates.cjs +197 -0
- package/rules/require-await.cjs +90 -0
- package/rules/require-unicode-regexp.cjs +101 -0
- package/rules/require-yield.cjs +56 -0
- package/rules/rest-spread-spacing.cjs +99 -0
- package/rules/semi-spacing.cjs +215 -0
- package/rules/semi-style.cjs +116 -0
- package/rules/semi.cjs +239 -0
- package/rules/sort-imports.cjs +140 -0
- package/rules/sort-keys.cjs +165 -0
- package/rules/sort-vars.cjs +50 -0
- package/rules/space-before-blocks.cjs +132 -0
- package/rules/space-before-function-paren.cjs +126 -0
- package/rules/space-in-parens.cjs +175 -0
- package/rules/space-infix-ops.cjs +133 -0
- package/rules/space-unary-ops.cjs +237 -0
- package/rules/spaced-comment.cjs +233 -0
- package/rules/strict.cjs +206 -0
- package/rules/switch-colon-spacing.cjs +114 -0
- package/rules/symbol-description.cjs +49 -0
- package/rules/template-curly-spacing.cjs +112 -0
- package/rules/template-tag-spacing.cjs +82 -0
- package/rules/unicode-bom.cjs +52 -0
- package/rules/use-isnan.cjs +144 -0
- package/rules/valid-typeof.cjs +104 -0
- package/rules/vars-on-top.cjs +94 -0
- package/rules/wrap-iife.cjs +131 -0
- package/rules/wrap-regex.cjs +57 -0
- package/rules/yield-star-spacing.cjs +115 -0
- package/rules/yoda.cjs +185 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-constant-binary-expression.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag constant comparisons and logical expressions that always/never short circuit
|
|
5
|
+
* @author Jordan Eldredge <https://jordaneldredge.com>
|
|
6
|
+
*/
|
|
7
|
+
var require_no_constant_binary_expression = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let { isNullLiteral, isConstant, isReferenceToGlobalVariable, isLogicalAssignmentOperator, ECMASCRIPT_GLOBALS } = require_ast_utils$1.t(), NUMERIC_OR_STRING_BINARY_OPERATORS = new Set([
|
|
9
|
+
"+",
|
|
10
|
+
"-",
|
|
11
|
+
"*",
|
|
12
|
+
"/",
|
|
13
|
+
"%",
|
|
14
|
+
"|",
|
|
15
|
+
"^",
|
|
16
|
+
"&",
|
|
17
|
+
"**",
|
|
18
|
+
"<<",
|
|
19
|
+
">>",
|
|
20
|
+
">>>"
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether or not a node is `null` or `undefined`. Similar to the one
|
|
24
|
+
* found in ast-utils.js, but this one correctly handles the edge case that
|
|
25
|
+
* `undefined` has been redefined.
|
|
26
|
+
* @param {Scope} scope Scope in which the expression was found.
|
|
27
|
+
* @param {ASTNode} node A node to check.
|
|
28
|
+
* @returns {boolean} Whether or not the node is a `null` or `undefined`.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
function isNullOrUndefined(scope, node) {
|
|
32
|
+
return isNullLiteral(node) || node.type === "Identifier" && node.name === "undefined" && isReferenceToGlobalVariable(scope, node) || node.type === "UnaryExpression" && node.operator === "void";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Test if an AST node has a statically knowable constant nullishness. Meaning,
|
|
36
|
+
* it will always resolve to a constant value of either: `null`, `undefined`
|
|
37
|
+
* or not `null` _or_ `undefined`. An expression that can vary between those
|
|
38
|
+
* three states at runtime would return `false`.
|
|
39
|
+
* @param {Scope} scope The scope in which the node was found.
|
|
40
|
+
* @param {ASTNode} node The AST node being tested.
|
|
41
|
+
* @param {boolean} nonNullish if `true` then nullish values are not considered constant.
|
|
42
|
+
* @returns {boolean} Does `node` have constant nullishness?
|
|
43
|
+
*/
|
|
44
|
+
function hasConstantNullishness(scope, node, nonNullish) {
|
|
45
|
+
if (nonNullish && isNullOrUndefined(scope, node)) return !1;
|
|
46
|
+
switch (node.type) {
|
|
47
|
+
case "ObjectExpression":
|
|
48
|
+
case "ArrayExpression":
|
|
49
|
+
case "ArrowFunctionExpression":
|
|
50
|
+
case "FunctionExpression":
|
|
51
|
+
case "ClassExpression":
|
|
52
|
+
case "NewExpression":
|
|
53
|
+
case "Literal":
|
|
54
|
+
case "TemplateLiteral":
|
|
55
|
+
case "UpdateExpression":
|
|
56
|
+
case "BinaryExpression": return !0;
|
|
57
|
+
case "CallExpression": {
|
|
58
|
+
if (node.callee.type !== "Identifier") return !1;
|
|
59
|
+
let functionName = node.callee.name;
|
|
60
|
+
return (functionName === "Boolean" || functionName === "String" || functionName === "Number") && isReferenceToGlobalVariable(scope, node.callee);
|
|
61
|
+
}
|
|
62
|
+
case "LogicalExpression": return node.operator === "??" && hasConstantNullishness(scope, node.right, !0);
|
|
63
|
+
case "AssignmentExpression": return node.operator === "=" ? hasConstantNullishness(scope, node.right, nonNullish) : !isLogicalAssignmentOperator(node.operator);
|
|
64
|
+
case "UnaryExpression": return !0;
|
|
65
|
+
case "SequenceExpression": return hasConstantNullishness(scope, node.expressions.at(-1), nonNullish);
|
|
66
|
+
case "Identifier": return node.name === "undefined" && isReferenceToGlobalVariable(scope, node);
|
|
67
|
+
case "JSXElement":
|
|
68
|
+
case "JSXFragment": return !1;
|
|
69
|
+
default: return !1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Test if an AST node is a boolean value that never changes. Specifically we
|
|
74
|
+
* test for:
|
|
75
|
+
* 1. Literal booleans (`true` or `false`)
|
|
76
|
+
* 2. Unary `!` expressions with a constant value
|
|
77
|
+
* 3. Constant booleans created via the `Boolean` global function
|
|
78
|
+
* @param {Scope} scope The scope in which the node was found.
|
|
79
|
+
* @param {ASTNode} node The node to test
|
|
80
|
+
* @returns {boolean} Is `node` guaranteed to be a boolean?
|
|
81
|
+
*/
|
|
82
|
+
function isStaticBoolean(scope, node) {
|
|
83
|
+
switch (node.type) {
|
|
84
|
+
case "Literal": return typeof node.value == "boolean";
|
|
85
|
+
case "CallExpression": return node.callee.type === "Identifier" && node.callee.name === "Boolean" && isReferenceToGlobalVariable(scope, node.callee) && (node.arguments.length === 0 || isConstant(scope, node.arguments[0], !0));
|
|
86
|
+
case "UnaryExpression": return node.operator === "!" && isConstant(scope, node.argument, !0);
|
|
87
|
+
default: return !1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Test if an AST node will always give the same result when compared to a
|
|
92
|
+
* boolean value. Note that comparison to boolean values is different than
|
|
93
|
+
* truthiness.
|
|
94
|
+
* https://262.ecma-international.org/5.1/#sec-11.9.3
|
|
95
|
+
*
|
|
96
|
+
* JavaScript `==` operator works by converting the boolean to `1` (true) or
|
|
97
|
+
* `+0` (false) and then checks the values `==` equality to that number.
|
|
98
|
+
* @param {Scope} scope The scope in which node was found.
|
|
99
|
+
* @param {ASTNode} node The node to test.
|
|
100
|
+
* @returns {boolean} Will `node` always coerce to the same boolean value?
|
|
101
|
+
*/
|
|
102
|
+
function hasConstantLooseBooleanComparison(scope, node) {
|
|
103
|
+
switch (node.type) {
|
|
104
|
+
case "ObjectExpression":
|
|
105
|
+
case "ClassExpression":
|
|
106
|
+
/**
|
|
107
|
+
* In theory objects like:
|
|
108
|
+
*
|
|
109
|
+
* `{toString: () => a}`
|
|
110
|
+
* `{valueOf: () => a}`
|
|
111
|
+
*
|
|
112
|
+
* Or a classes like:
|
|
113
|
+
*
|
|
114
|
+
* `class { static toString() { return a } }`
|
|
115
|
+
* `class { static valueOf() { return a } }`
|
|
116
|
+
*
|
|
117
|
+
* Are not constant verifiably when `inBooleanPosition` is
|
|
118
|
+
* false, but it's an edge case we've opted not to handle.
|
|
119
|
+
*/
|
|
120
|
+
return !0;
|
|
121
|
+
case "ArrayExpression": {
|
|
122
|
+
let nonSpreadElements = node.elements.filter((e) => e !== null && e.type !== "SpreadElement");
|
|
123
|
+
return node.elements.length === 0 || nonSpreadElements.length > 1;
|
|
124
|
+
}
|
|
125
|
+
case "ArrowFunctionExpression":
|
|
126
|
+
case "FunctionExpression": return !0;
|
|
127
|
+
case "UnaryExpression": return node.operator === "void" || node.operator === "typeof" ? !0 : node.operator === "!" ? isConstant(scope, node.argument, !0) : !1;
|
|
128
|
+
case "NewExpression": return !1;
|
|
129
|
+
case "CallExpression": return node.callee.type === "Identifier" && node.callee.name === "Boolean" && isReferenceToGlobalVariable(scope, node.callee) ? node.arguments.length === 0 || isConstant(scope, node.arguments[0], !0) : !1;
|
|
130
|
+
case "Literal": return !0;
|
|
131
|
+
case "Identifier": return node.name === "undefined" && isReferenceToGlobalVariable(scope, node);
|
|
132
|
+
case "TemplateLiteral": return node.expressions.length === 0;
|
|
133
|
+
case "AssignmentExpression": return node.operator === "=" ? hasConstantLooseBooleanComparison(scope, node.right) : !1;
|
|
134
|
+
case "SequenceExpression": return hasConstantLooseBooleanComparison(scope, node.expressions.at(-1));
|
|
135
|
+
case "JSXElement":
|
|
136
|
+
case "JSXFragment": return !1;
|
|
137
|
+
default: return !1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Test if an AST node will always give the same result when _strictly_ compared
|
|
142
|
+
* to a boolean value. This can happen if the expression can never be boolean, or
|
|
143
|
+
* if it is always the same boolean value.
|
|
144
|
+
* @param {Scope} scope The scope in which the node was found.
|
|
145
|
+
* @param {ASTNode} node The node to test
|
|
146
|
+
* @returns {boolean} Will `node` always give the same result when compared to a
|
|
147
|
+
* static boolean value?
|
|
148
|
+
*/
|
|
149
|
+
function hasConstantStrictBooleanComparison(scope, node) {
|
|
150
|
+
switch (node.type) {
|
|
151
|
+
case "ObjectExpression":
|
|
152
|
+
case "ArrayExpression":
|
|
153
|
+
case "ArrowFunctionExpression":
|
|
154
|
+
case "FunctionExpression":
|
|
155
|
+
case "ClassExpression":
|
|
156
|
+
case "NewExpression":
|
|
157
|
+
case "TemplateLiteral":
|
|
158
|
+
case "Literal":
|
|
159
|
+
case "UpdateExpression": return !0;
|
|
160
|
+
case "BinaryExpression": return NUMERIC_OR_STRING_BINARY_OPERATORS.has(node.operator);
|
|
161
|
+
case "UnaryExpression": return node.operator === "delete" ? !1 : node.operator === "!" ? isConstant(scope, node.argument, !0) : !0;
|
|
162
|
+
case "SequenceExpression": return hasConstantStrictBooleanComparison(scope, node.expressions.at(-1));
|
|
163
|
+
case "Identifier": return node.name === "undefined" && isReferenceToGlobalVariable(scope, node);
|
|
164
|
+
case "AssignmentExpression": return node.operator === "=" ? hasConstantStrictBooleanComparison(scope, node.right) : !isLogicalAssignmentOperator(node.operator);
|
|
165
|
+
case "CallExpression": {
|
|
166
|
+
if (node.callee.type !== "Identifier") return !1;
|
|
167
|
+
let functionName = node.callee.name;
|
|
168
|
+
return (functionName === "String" || functionName === "Number") && isReferenceToGlobalVariable(scope, node.callee) ? !0 : functionName === "Boolean" && isReferenceToGlobalVariable(scope, node.callee) ? node.arguments.length === 0 || isConstant(scope, node.arguments[0], !0) : !1;
|
|
169
|
+
}
|
|
170
|
+
case "JSXElement":
|
|
171
|
+
case "JSXFragment": return !1;
|
|
172
|
+
default: return !1;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Test if an AST node will always result in a newly constructed object
|
|
177
|
+
* @param {Scope} scope The scope in which the node was found.
|
|
178
|
+
* @param {ASTNode} node The node to test
|
|
179
|
+
* @returns {boolean} Will `node` always be new?
|
|
180
|
+
*/
|
|
181
|
+
function isAlwaysNew(scope, node) {
|
|
182
|
+
switch (node.type) {
|
|
183
|
+
case "ObjectExpression":
|
|
184
|
+
case "ArrayExpression":
|
|
185
|
+
case "ArrowFunctionExpression":
|
|
186
|
+
case "FunctionExpression":
|
|
187
|
+
case "ClassExpression": return !0;
|
|
188
|
+
case "NewExpression": return node.callee.type === "Identifier" ? Object.hasOwn(ECMASCRIPT_GLOBALS, node.callee.name) && isReferenceToGlobalVariable(scope, node.callee) : !1;
|
|
189
|
+
case "Literal": return typeof node.regex == "object";
|
|
190
|
+
case "SequenceExpression": return isAlwaysNew(scope, node.expressions.at(-1));
|
|
191
|
+
case "AssignmentExpression": return node.operator === "=" ? isAlwaysNew(scope, node.right) : !1;
|
|
192
|
+
case "ConditionalExpression": return isAlwaysNew(scope, node.consequent) && isAlwaysNew(scope, node.alternate);
|
|
193
|
+
case "JSXElement":
|
|
194
|
+
case "JSXFragment": return !1;
|
|
195
|
+
default: return !1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Checks if one operand will cause the result to be constant.
|
|
200
|
+
* @param {Scope} scope Scope in which the expression was found.
|
|
201
|
+
* @param {ASTNode} a One side of the expression
|
|
202
|
+
* @param {ASTNode} b The other side of the expression
|
|
203
|
+
* @param {string} operator The binary expression operator
|
|
204
|
+
* @returns {ASTNode | null} The node which will cause the expression to have a constant result.
|
|
205
|
+
*/
|
|
206
|
+
function findBinaryExpressionConstantOperand(scope, a, b, operator) {
|
|
207
|
+
if (operator === "==" || operator === "!=") {
|
|
208
|
+
if (isNullOrUndefined(scope, a) && hasConstantNullishness(scope, b, !1) || isStaticBoolean(scope, a) && hasConstantLooseBooleanComparison(scope, b)) return b;
|
|
209
|
+
} else if ((operator === "===" || operator === "!==") && (isNullOrUndefined(scope, a) && hasConstantNullishness(scope, b, !1) || isStaticBoolean(scope, a) && hasConstantStrictBooleanComparison(scope, b))) return b;
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
213
|
+
module.exports = {
|
|
214
|
+
meta: {
|
|
215
|
+
type: "problem",
|
|
216
|
+
docs: {
|
|
217
|
+
description: "Disallow expressions where the operation doesn't affect the value",
|
|
218
|
+
recommended: !0,
|
|
219
|
+
url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression"
|
|
220
|
+
},
|
|
221
|
+
schema: [],
|
|
222
|
+
messages: {
|
|
223
|
+
constantBinaryOperand: "Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the `{{operator}}`.",
|
|
224
|
+
constantShortCircuit: "Unexpected constant {{property}} on the left-hand side of a `{{operator}}` expression.",
|
|
225
|
+
alwaysNew: "Unexpected comparison to newly constructed object. These two values can never be equal.",
|
|
226
|
+
bothAlwaysNew: "Unexpected comparison of two newly constructed objects. These two values can never be equal."
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
create(context) {
|
|
230
|
+
let sourceCode = context.sourceCode;
|
|
231
|
+
return {
|
|
232
|
+
LogicalExpression(node) {
|
|
233
|
+
let { operator, left } = node, scope = sourceCode.getScope(node);
|
|
234
|
+
(operator === "&&" || operator === "||") && isConstant(scope, left, !0) ? context.report({
|
|
235
|
+
node: left,
|
|
236
|
+
messageId: "constantShortCircuit",
|
|
237
|
+
data: {
|
|
238
|
+
property: "truthiness",
|
|
239
|
+
operator
|
|
240
|
+
}
|
|
241
|
+
}) : operator === "??" && hasConstantNullishness(scope, left, !1) && context.report({
|
|
242
|
+
node: left,
|
|
243
|
+
messageId: "constantShortCircuit",
|
|
244
|
+
data: {
|
|
245
|
+
property: "nullishness",
|
|
246
|
+
operator
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
BinaryExpression(node) {
|
|
251
|
+
let scope = sourceCode.getScope(node), { right, left, operator } = node, rightConstantOperand = findBinaryExpressionConstantOperand(scope, left, right, operator), leftConstantOperand = findBinaryExpressionConstantOperand(scope, right, left, operator);
|
|
252
|
+
rightConstantOperand ? context.report({
|
|
253
|
+
node: rightConstantOperand,
|
|
254
|
+
messageId: "constantBinaryOperand",
|
|
255
|
+
data: {
|
|
256
|
+
operator,
|
|
257
|
+
otherSide: "left"
|
|
258
|
+
}
|
|
259
|
+
}) : leftConstantOperand ? context.report({
|
|
260
|
+
node: leftConstantOperand,
|
|
261
|
+
messageId: "constantBinaryOperand",
|
|
262
|
+
data: {
|
|
263
|
+
operator,
|
|
264
|
+
otherSide: "right"
|
|
265
|
+
}
|
|
266
|
+
}) : operator === "===" || operator === "!==" ? isAlwaysNew(scope, left) ? context.report({
|
|
267
|
+
node: left,
|
|
268
|
+
messageId: "alwaysNew"
|
|
269
|
+
}) : isAlwaysNew(scope, right) && context.report({
|
|
270
|
+
node: right,
|
|
271
|
+
messageId: "alwaysNew"
|
|
272
|
+
}) : (operator === "==" || operator === "!=") && isAlwaysNew(scope, left) && isAlwaysNew(scope, right) && context.report({
|
|
273
|
+
node: left,
|
|
274
|
+
messageId: "bothAlwaysNew"
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}));
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src-js/generated/plugin-eslint/rules/no-constant-binary-expression.cjs
|
|
283
|
+
module.exports = require_no_constant_binary_expression().create;
|
|
284
|
+
//#endregion
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-constant-condition.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag use constant conditions
|
|
5
|
+
* @author Christian Schulz <http://rndm.de>
|
|
6
|
+
*/
|
|
7
|
+
var require_no_constant_condition = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let { isConstant } = require_ast_utils$1.t();
|
|
9
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
10
|
+
module.exports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "problem",
|
|
13
|
+
defaultOptions: [{ checkLoops: "allExceptWhileTrue" }],
|
|
14
|
+
docs: {
|
|
15
|
+
description: "Disallow constant expressions in conditions",
|
|
16
|
+
recommended: !0,
|
|
17
|
+
url: "https://eslint.org/docs/latest/rules/no-constant-condition"
|
|
18
|
+
},
|
|
19
|
+
schema: [{
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: { checkLoops: { enum: [
|
|
22
|
+
"all",
|
|
23
|
+
"allExceptWhileTrue",
|
|
24
|
+
"none",
|
|
25
|
+
!0,
|
|
26
|
+
!1
|
|
27
|
+
] } },
|
|
28
|
+
additionalProperties: !1
|
|
29
|
+
}],
|
|
30
|
+
messages: { unexpected: "Unexpected constant condition." }
|
|
31
|
+
},
|
|
32
|
+
create(context) {
|
|
33
|
+
let loopSetStack = [], sourceCode = context.sourceCode, [{ checkLoops }] = context.options;
|
|
34
|
+
checkLoops === !0 ? checkLoops = "all" : checkLoops === !1 && (checkLoops = "none");
|
|
35
|
+
let loopsInCurrentScope = /* @__PURE__ */ new Set();
|
|
36
|
+
/**
|
|
37
|
+
* Tracks when the given node contains a constant condition.
|
|
38
|
+
* @param {ASTNode} node The AST node to check.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
function trackConstantConditionLoop(node) {
|
|
43
|
+
node.test && isConstant(sourceCode.getScope(node), node.test, !0) && loopsInCurrentScope.add(node);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reports when the set contains the given constant condition node
|
|
47
|
+
* @param {ASTNode} node The AST node to check.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
function checkConstantConditionLoopInSet(node) {
|
|
52
|
+
loopsInCurrentScope.has(node) && (loopsInCurrentScope.delete(node), context.report({
|
|
53
|
+
node: node.test,
|
|
54
|
+
messageId: "unexpected"
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reports when the given node contains a constant condition.
|
|
59
|
+
* @param {ASTNode} node The AST node to check.
|
|
60
|
+
* @returns {void}
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
function reportIfConstant(node) {
|
|
64
|
+
node.test && isConstant(sourceCode.getScope(node), node.test, !0) && context.report({
|
|
65
|
+
node: node.test,
|
|
66
|
+
messageId: "unexpected"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Stores current set of constant loops in loopSetStack temporarily
|
|
71
|
+
* and uses a new set to track constant loops
|
|
72
|
+
* @returns {void}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
function enterFunction() {
|
|
76
|
+
loopSetStack.push(loopsInCurrentScope), loopsInCurrentScope = /* @__PURE__ */ new Set();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reports when the set still contains stored constant conditions
|
|
80
|
+
* @returns {void}
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
function exitFunction() {
|
|
84
|
+
loopsInCurrentScope = loopSetStack.pop();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks node when checkLoops option is enabled
|
|
88
|
+
* @param {ASTNode} node The AST node to check.
|
|
89
|
+
* @returns {void}
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
function checkLoop(node) {
|
|
93
|
+
(checkLoops === "all" || checkLoops === "allExceptWhileTrue") && trackConstantConditionLoop(node);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
ConditionalExpression: reportIfConstant,
|
|
97
|
+
IfStatement: reportIfConstant,
|
|
98
|
+
WhileStatement(node) {
|
|
99
|
+
node.test.type === "Literal" && node.test.value === !0 && checkLoops === "allExceptWhileTrue" || checkLoop(node);
|
|
100
|
+
},
|
|
101
|
+
"WhileStatement:exit": checkConstantConditionLoopInSet,
|
|
102
|
+
DoWhileStatement: checkLoop,
|
|
103
|
+
"DoWhileStatement:exit": checkConstantConditionLoopInSet,
|
|
104
|
+
ForStatement: checkLoop,
|
|
105
|
+
"ForStatement > .test": (node) => checkLoop(node.parent),
|
|
106
|
+
"ForStatement:exit": checkConstantConditionLoopInSet,
|
|
107
|
+
FunctionDeclaration: enterFunction,
|
|
108
|
+
"FunctionDeclaration:exit": exitFunction,
|
|
109
|
+
FunctionExpression: enterFunction,
|
|
110
|
+
"FunctionExpression:exit": exitFunction,
|
|
111
|
+
YieldExpression: () => loopsInCurrentScope.clear()
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src-js/generated/plugin-eslint/rules/no-constant-condition.cjs
|
|
118
|
+
module.exports = require_no_constant_condition().create;
|
|
119
|
+
//#endregion
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-constructor-return.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to disallow returning value from constructor.
|
|
4
|
+
* @author Pig Fang <https://github.com/g-plane>
|
|
5
|
+
*/
|
|
6
|
+
var require_no_constructor_return = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "problem",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow returning value from constructor",
|
|
13
|
+
recommended: !1,
|
|
14
|
+
url: "https://eslint.org/docs/latest/rules/no-constructor-return"
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
fixable: null,
|
|
18
|
+
messages: { unexpected: "Unexpected return statement in constructor." }
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
let stack = [];
|
|
22
|
+
return {
|
|
23
|
+
onCodePathStart(_, node) {
|
|
24
|
+
stack.push(node);
|
|
25
|
+
},
|
|
26
|
+
onCodePathEnd() {
|
|
27
|
+
stack.pop();
|
|
28
|
+
},
|
|
29
|
+
ReturnStatement(node) {
|
|
30
|
+
let last = stack.at(-1);
|
|
31
|
+
last.parent && last.parent.type === "MethodDefinition" && last.parent.kind === "constructor" && node.argument && context.report({
|
|
32
|
+
node,
|
|
33
|
+
messageId: "unexpected"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}));
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src-js/generated/plugin-eslint/rules/no-constructor-return.cjs
|
|
42
|
+
module.exports = require_no_constructor_return().create;
|
|
43
|
+
//#endregion
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-continue.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to flag use of continue statement
|
|
4
|
+
* @author Borislav Zhivkov
|
|
5
|
+
*/
|
|
6
|
+
var require_no_continue = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "suggestion",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow `continue` statements",
|
|
13
|
+
recommended: !1,
|
|
14
|
+
frozen: !0,
|
|
15
|
+
url: "https://eslint.org/docs/latest/rules/no-continue"
|
|
16
|
+
},
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: { unexpected: "Unexpected use of continue statement." }
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
return { ContinueStatement(node) {
|
|
22
|
+
context.report({
|
|
23
|
+
node,
|
|
24
|
+
messageId: "unexpected"
|
|
25
|
+
});
|
|
26
|
+
} };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}));
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src-js/generated/plugin-eslint/rules/no-continue.cjs
|
|
32
|
+
module.exports = require_no_continue().create;
|
|
33
|
+
//#endregion
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_regexpp$1 = require("../common/regexpp.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-control-regex.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to forbid control characters from regular expressions.
|
|
5
|
+
* @author Nicholas C. Zakas
|
|
6
|
+
*/
|
|
7
|
+
var require_no_control_regex = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let RegExpValidator = require_regexpp$1.t().RegExpValidator, collector = new class {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._source = "", this._controlChars = [], this._validator = new RegExpValidator(this);
|
|
11
|
+
}
|
|
12
|
+
onPatternEnter() {
|
|
13
|
+
this._controlChars = [];
|
|
14
|
+
}
|
|
15
|
+
onCharacter(start, end, cp) {
|
|
16
|
+
cp >= 0 && cp <= 31 && (this._source.codePointAt(start) === cp || this._source.slice(start, end).startsWith("\\x") || this._source.slice(start, end).startsWith("\\u")) && this._controlChars.push(`\\x${`0${cp.toString(16)}`.slice(-2)}`);
|
|
17
|
+
}
|
|
18
|
+
collectControlChars(regexpStr, flags) {
|
|
19
|
+
let uFlag = typeof flags == "string" && flags.includes("u"), vFlag = typeof flags == "string" && flags.includes("v");
|
|
20
|
+
this._controlChars = [], this._source = regexpStr;
|
|
21
|
+
try {
|
|
22
|
+
this._validator.validatePattern(regexpStr, void 0, void 0, {
|
|
23
|
+
unicode: uFlag,
|
|
24
|
+
unicodeSets: vFlag
|
|
25
|
+
});
|
|
26
|
+
} catch {}
|
|
27
|
+
return this._controlChars;
|
|
28
|
+
}
|
|
29
|
+
}();
|
|
30
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
31
|
+
module.exports = {
|
|
32
|
+
meta: {
|
|
33
|
+
type: "problem",
|
|
34
|
+
docs: {
|
|
35
|
+
description: "Disallow control characters in regular expressions",
|
|
36
|
+
recommended: !0,
|
|
37
|
+
url: "https://eslint.org/docs/latest/rules/no-control-regex"
|
|
38
|
+
},
|
|
39
|
+
schema: [],
|
|
40
|
+
messages: { unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}." }
|
|
41
|
+
},
|
|
42
|
+
create(context) {
|
|
43
|
+
/**
|
|
44
|
+
* Get the regex expression
|
|
45
|
+
* @param {ASTNode} node `Literal` node to evaluate
|
|
46
|
+
* @returns {{ pattern: string, flags: string | null } | null} Regex if found (the given node is either a regex literal
|
|
47
|
+
* or a string literal that is the pattern argument of a RegExp constructor call). Otherwise `null`. If flags cannot be determined,
|
|
48
|
+
* the `flags` property will be `null`.
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
function getRegExp(node) {
|
|
52
|
+
return node.regex ? node.regex : typeof node.value == "string" && (node.parent.type === "NewExpression" || node.parent.type === "CallExpression") && node.parent.callee.type === "Identifier" && node.parent.callee.name === "RegExp" && node.parent.arguments[0] === node ? {
|
|
53
|
+
pattern: node.value,
|
|
54
|
+
flags: node.parent.arguments.length > 1 && node.parent.arguments[1].type === "Literal" && typeof node.parent.arguments[1].value == "string" ? node.parent.arguments[1].value : null
|
|
55
|
+
} : null;
|
|
56
|
+
}
|
|
57
|
+
return { Literal(node) {
|
|
58
|
+
let regExp = getRegExp(node);
|
|
59
|
+
if (regExp) {
|
|
60
|
+
let { pattern, flags } = regExp, controlCharacters = collector.collectControlChars(pattern, flags);
|
|
61
|
+
controlCharacters.length > 0 && context.report({
|
|
62
|
+
node,
|
|
63
|
+
messageId: "unexpected",
|
|
64
|
+
data: { controlChars: controlCharacters.join(", ") }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}));
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src-js/generated/plugin-eslint/rules/no-control-regex.cjs
|
|
73
|
+
module.exports = require_no_control_regex().create;
|
|
74
|
+
//#endregion
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-debugger.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to flag use of a debugger statement
|
|
4
|
+
* @author Nicholas C. Zakas
|
|
5
|
+
*/
|
|
6
|
+
var require_no_debugger = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "problem",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow the use of `debugger`",
|
|
13
|
+
recommended: !0,
|
|
14
|
+
url: "https://eslint.org/docs/latest/rules/no-debugger"
|
|
15
|
+
},
|
|
16
|
+
fixable: null,
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: { unexpected: "Unexpected 'debugger' statement." }
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
return { DebuggerStatement(node) {
|
|
22
|
+
context.report({
|
|
23
|
+
node,
|
|
24
|
+
messageId: "unexpected"
|
|
25
|
+
});
|
|
26
|
+
} };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}));
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src-js/generated/plugin-eslint/rules/no-debugger.cjs
|
|
32
|
+
module.exports = require_no_debugger().create;
|
|
33
|
+
//#endregion
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-delete-var.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to flag when deleting variables
|
|
4
|
+
* @author Ilya Volodin
|
|
5
|
+
*/
|
|
6
|
+
var require_no_delete_var = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "suggestion",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow deleting variables",
|
|
13
|
+
recommended: !0,
|
|
14
|
+
url: "https://eslint.org/docs/latest/rules/no-delete-var"
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: { unexpected: "Variables should not be deleted." }
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
return { UnaryExpression(node) {
|
|
21
|
+
node.operator === "delete" && node.argument.type === "Identifier" && context.report({
|
|
22
|
+
node,
|
|
23
|
+
messageId: "unexpected"
|
|
24
|
+
});
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}));
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src-js/generated/plugin-eslint/rules/no-delete-var.cjs
|
|
31
|
+
module.exports = require_no_delete_var().create;
|
|
32
|
+
//#endregion
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-div-regex.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to check for ambiguous div operator in regexes
|
|
4
|
+
* @author Matt DuVall <http://www.mattduvall.com>
|
|
5
|
+
*/
|
|
6
|
+
var require_no_div_regex = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "suggestion",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow equal signs explicitly at the beginning of regular expressions",
|
|
13
|
+
recommended: !1,
|
|
14
|
+
frozen: !0,
|
|
15
|
+
url: "https://eslint.org/docs/latest/rules/no-div-regex"
|
|
16
|
+
},
|
|
17
|
+
fixable: "code",
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: { unexpected: "A regular expression literal can be confused with '/='." }
|
|
20
|
+
},
|
|
21
|
+
create(context) {
|
|
22
|
+
let sourceCode = context.sourceCode;
|
|
23
|
+
return { Literal(node) {
|
|
24
|
+
let token = sourceCode.getFirstToken(node);
|
|
25
|
+
token.type === "RegularExpression" && token.value[1] === "=" && context.report({
|
|
26
|
+
node,
|
|
27
|
+
messageId: "unexpected",
|
|
28
|
+
fix(fixer) {
|
|
29
|
+
return fixer.replaceTextRange([token.range[0] + 1, token.range[0] + 2], "[=]");
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
} };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src-js/generated/plugin-eslint/rules/no-div-regex.cjs
|
|
38
|
+
module.exports = require_no_div_regex().create;
|
|
39
|
+
//#endregion
|