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,77 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-implicit-globals.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to check for implicit global variables, functions and classes.
|
|
4
|
+
* @author Joshua Peek
|
|
5
|
+
*/
|
|
6
|
+
var require_no_implicit_globals = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
let ASSIGNMENT_NODES = new Set([
|
|
8
|
+
"AssignmentExpression",
|
|
9
|
+
"ForInStatement",
|
|
10
|
+
"ForOfStatement"
|
|
11
|
+
]);
|
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
13
|
+
module.exports = {
|
|
14
|
+
meta: {
|
|
15
|
+
type: "suggestion",
|
|
16
|
+
defaultOptions: [{ lexicalBindings: !1 }],
|
|
17
|
+
docs: {
|
|
18
|
+
description: "Disallow declarations in the global scope",
|
|
19
|
+
recommended: !1,
|
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-implicit-globals"
|
|
21
|
+
},
|
|
22
|
+
schema: [{
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: { lexicalBindings: { type: "boolean" } },
|
|
25
|
+
additionalProperties: !1
|
|
26
|
+
}],
|
|
27
|
+
messages: {
|
|
28
|
+
globalNonLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable.",
|
|
29
|
+
globalLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in a block or in an IIFE.",
|
|
30
|
+
globalVariableLeak: "Global variable leak, declare the variable if it is intended to be local.",
|
|
31
|
+
assignmentToReadonlyGlobal: "Unexpected assignment to read-only global variable.",
|
|
32
|
+
redeclarationOfReadonlyGlobal: "Unexpected redeclaration of read-only global variable."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
create(context) {
|
|
36
|
+
let [{ lexicalBindings: checkLexicalBindings }] = context.options, sourceCode = context.sourceCode;
|
|
37
|
+
/**
|
|
38
|
+
* Reports the node.
|
|
39
|
+
* @param {ASTNode} node Node to report.
|
|
40
|
+
* @param {string} messageId Id of the message to report.
|
|
41
|
+
* @param {string|undefined} kind Declaration kind, can be 'var', 'const', 'let', function or class.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
function report(node, messageId, kind) {
|
|
45
|
+
context.report({
|
|
46
|
+
node,
|
|
47
|
+
messageId,
|
|
48
|
+
data: { kind }
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return { Program(node) {
|
|
52
|
+
let scope = sourceCode.getScope(node);
|
|
53
|
+
scope.variables.forEach((variable) => {
|
|
54
|
+
let isReadonlyEslintGlobalVariable = variable.writeable === !1;
|
|
55
|
+
variable.writeable !== !0 && (variable.eslintExported || (variable.defs.forEach((def) => {
|
|
56
|
+
let defNode = def.node;
|
|
57
|
+
(def.type === "FunctionName" || def.type === "Variable" && def.parent.kind === "var") && (isReadonlyEslintGlobalVariable ? report(defNode, "redeclarationOfReadonlyGlobal") : report(defNode, "globalNonLexicalBinding", def.type === "FunctionName" ? "function" : `'${def.parent.kind}'`)), checkLexicalBindings && (def.type === "ClassName" || def.type === "Variable" && (def.parent.kind === "let" || def.parent.kind === "const")) && (isReadonlyEslintGlobalVariable ? report(defNode, "redeclarationOfReadonlyGlobal") : report(defNode, "globalLexicalBinding", def.type === "ClassName" ? "class" : `'${def.parent.kind}'`));
|
|
58
|
+
}), isReadonlyEslintGlobalVariable && variable.defs.length === 0 && variable.references.forEach((reference) => {
|
|
59
|
+
if (reference.isWrite() && !reference.isRead()) {
|
|
60
|
+
let assignmentParent = reference.identifier.parent;
|
|
61
|
+
for (; assignmentParent && !ASSIGNMENT_NODES.has(assignmentParent.type);) assignmentParent = assignmentParent.parent;
|
|
62
|
+
report(assignmentParent ?? reference.identifier, "assignmentToReadonlyGlobal");
|
|
63
|
+
}
|
|
64
|
+
})));
|
|
65
|
+
}), scope.implicit.variables.forEach((variable) => {
|
|
66
|
+
variable.defs.forEach((def) => {
|
|
67
|
+
report(def.node, "globalVariableLeak");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
} };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}));
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src-js/generated/plugin-eslint/rules/no-implicit-globals.cjs
|
|
76
|
+
module.exports = require_no_implicit_globals().create;
|
|
77
|
+
//#endregion
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs"), require_eslint_utils$1 = require("../common/eslint-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-implied-eval.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag use of implied eval via setTimeout and setInterval
|
|
5
|
+
* @author James Allardice
|
|
6
|
+
*/
|
|
7
|
+
var require_no_implied_eval = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t(), { getStaticValue } = require_eslint_utils$1.t();
|
|
9
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
10
|
+
module.exports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "suggestion",
|
|
13
|
+
docs: {
|
|
14
|
+
description: "Disallow the use of `eval()`-like methods",
|
|
15
|
+
recommended: !1,
|
|
16
|
+
url: "https://eslint.org/docs/latest/rules/no-implied-eval"
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
impliedEval: "Implied eval. Consider passing a function instead of a string.",
|
|
21
|
+
execScript: "Implied eval. Do not use execScript()."
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
create(context) {
|
|
25
|
+
let GLOBAL_CANDIDATES = Object.freeze([
|
|
26
|
+
"global",
|
|
27
|
+
"window",
|
|
28
|
+
"globalThis"
|
|
29
|
+
]), EVAL_LIKE_FUNC_PATTERN = /^(?:set(?:Interval|Timeout)|execScript)$/u, sourceCode = context.sourceCode;
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether a node is evaluated as a string or not.
|
|
32
|
+
* @param {ASTNode} node A node to check.
|
|
33
|
+
* @returns {boolean} True if the node is evaluated as a string.
|
|
34
|
+
*/
|
|
35
|
+
function isEvaluatedString(node) {
|
|
36
|
+
return node.type === "Literal" && typeof node.value == "string" || node.type === "TemplateLiteral" ? !0 : node.type === "BinaryExpression" && node.operator === "+" ? isEvaluatedString(node.left) || isEvaluatedString(node.right) : !1;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reports if the `CallExpression` node has evaluated argument.
|
|
40
|
+
* @param {ASTNode} node A CallExpression to check.
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
43
|
+
function reportImpliedEvalCallExpression(node) {
|
|
44
|
+
let [firstArgument] = node.arguments;
|
|
45
|
+
if (firstArgument) {
|
|
46
|
+
let staticValue = getStaticValue(firstArgument, sourceCode.getScope(node));
|
|
47
|
+
if (staticValue && typeof staticValue.value == "string" || isEvaluatedString(firstArgument)) {
|
|
48
|
+
let isExecScript = (node.callee.type === "Identifier" ? node.callee.name : astUtils.getStaticPropertyName(node.callee)) === "execScript";
|
|
49
|
+
context.report({
|
|
50
|
+
node,
|
|
51
|
+
messageId: isExecScript ? "execScript" : "impliedEval"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reports calls of `implied eval` via the global references.
|
|
58
|
+
* @param {Variable} globalVar A global variable to check.
|
|
59
|
+
* @returns {void}
|
|
60
|
+
*/
|
|
61
|
+
function reportImpliedEvalViaGlobal(globalVar) {
|
|
62
|
+
let { references, name } = globalVar;
|
|
63
|
+
references.forEach((ref) => {
|
|
64
|
+
let node = ref.identifier.parent;
|
|
65
|
+
for (; astUtils.isSpecificMemberAccess(node, null, name);) node = node.parent;
|
|
66
|
+
if (astUtils.isSpecificMemberAccess(node, null, EVAL_LIKE_FUNC_PATTERN)) {
|
|
67
|
+
let calleeNode = node.parent.type === "ChainExpression" ? node.parent : node, parent = calleeNode.parent;
|
|
68
|
+
parent.type === "CallExpression" && parent.callee === calleeNode && reportImpliedEvalCallExpression(parent);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
CallExpression(node) {
|
|
74
|
+
astUtils.isSpecificId(node.callee, EVAL_LIKE_FUNC_PATTERN) && sourceCode.isGlobalReference(node.callee) && reportImpliedEvalCallExpression(node);
|
|
75
|
+
},
|
|
76
|
+
"Program:exit"(node) {
|
|
77
|
+
let globalScope = sourceCode.getScope(node);
|
|
78
|
+
GLOBAL_CANDIDATES.map((candidate) => astUtils.getVariableByName(globalScope, candidate)).filter((globalVar) => !!globalVar && globalVar.defs.length === 0).forEach(reportImpliedEvalViaGlobal);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}));
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src-js/generated/plugin-eslint/rules/no-implied-eval.cjs
|
|
86
|
+
module.exports = require_no_implied_eval().create;
|
|
87
|
+
//#endregion
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs"), require_eslint_utils$1 = require("../common/eslint-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-import-assign.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag updates of imported bindings.
|
|
5
|
+
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
6
|
+
*/
|
|
7
|
+
var require_no_import_assign = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let { findVariable } = require_eslint_utils$1.t(), astUtils = require_ast_utils$1.t(), WellKnownMutationFunctions = {
|
|
9
|
+
Object: /^(?:assign|definePropert(?:y|ies)|freeze|setPrototypeOf)$/u,
|
|
10
|
+
Reflect: /^(?:(?:define|delete)Property|set(?:PrototypeOf)?)$/u
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Check if a given node is LHS of an assignment node.
|
|
14
|
+
* @param {ASTNode} node The node to check.
|
|
15
|
+
* @returns {boolean} `true` if the node is LHS.
|
|
16
|
+
*/
|
|
17
|
+
function isAssignmentLeft(node) {
|
|
18
|
+
let { parent } = node;
|
|
19
|
+
return parent.type === "AssignmentExpression" && parent.left === node || parent.type === "ArrayPattern" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "RestElement" || parent.type === "AssignmentPattern" && parent.left === node;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a given node is the operand of mutation unary operator.
|
|
23
|
+
* @param {ASTNode} node The node to check.
|
|
24
|
+
* @returns {boolean} `true` if the node is the operand of mutation unary operator.
|
|
25
|
+
*/
|
|
26
|
+
function isOperandOfMutationUnaryOperator(node) {
|
|
27
|
+
let argumentNode = node.parent.type === "ChainExpression" ? node.parent : node, { parent } = argumentNode;
|
|
28
|
+
return parent.type === "UpdateExpression" && parent.argument === argumentNode || parent.type === "UnaryExpression" && parent.operator === "delete" && parent.argument === argumentNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a given node is the iteration variable of `for-in`/`for-of` syntax.
|
|
32
|
+
* @param {ASTNode} node The node to check.
|
|
33
|
+
* @returns {boolean} `true` if the node is the iteration variable.
|
|
34
|
+
*/
|
|
35
|
+
function isIterationVariable(node) {
|
|
36
|
+
let { parent } = node;
|
|
37
|
+
return parent.type === "ForInStatement" && parent.left === node || parent.type === "ForOfStatement" && parent.left === node;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if a given node is at the first argument of a well-known mutation function.
|
|
41
|
+
* - `Object.assign`
|
|
42
|
+
* - `Object.defineProperty`
|
|
43
|
+
* - `Object.defineProperties`
|
|
44
|
+
* - `Object.freeze`
|
|
45
|
+
* - `Object.setPrototypeOf`
|
|
46
|
+
* - `Reflect.defineProperty`
|
|
47
|
+
* - `Reflect.deleteProperty`
|
|
48
|
+
* - `Reflect.set`
|
|
49
|
+
* - `Reflect.setPrototypeOf`
|
|
50
|
+
* @param {ASTNode} node The node to check.
|
|
51
|
+
* @param {Scope} scope A `escope.Scope` object to find variable (whichever).
|
|
52
|
+
* @returns {boolean} `true` if the node is at the first argument of a well-known mutation function.
|
|
53
|
+
*/
|
|
54
|
+
function isArgumentOfWellKnownMutationFunction(node, scope) {
|
|
55
|
+
let { parent } = node;
|
|
56
|
+
if (parent.type !== "CallExpression" || parent.arguments[0] !== node) return !1;
|
|
57
|
+
let callee = astUtils.skipChainExpression(parent.callee);
|
|
58
|
+
if (!astUtils.isSpecificMemberAccess(callee, "Object", WellKnownMutationFunctions.Object) && !astUtils.isSpecificMemberAccess(callee, "Reflect", WellKnownMutationFunctions.Reflect)) return !1;
|
|
59
|
+
let variable = findVariable(scope, callee.object);
|
|
60
|
+
return variable !== null && variable.scope.type === "global";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if the identifier node is placed at to update members.
|
|
64
|
+
* @param {ASTNode} id The Identifier node to check.
|
|
65
|
+
* @param {Scope} scope A `escope.Scope` object to find variable (whichever).
|
|
66
|
+
* @returns {boolean} `true` if the member of `id` was updated.
|
|
67
|
+
*/
|
|
68
|
+
function isMemberWrite(id, scope) {
|
|
69
|
+
let { parent } = id;
|
|
70
|
+
return parent.type === "MemberExpression" && parent.object === id && (isAssignmentLeft(parent) || isOperandOfMutationUnaryOperator(parent) || isIterationVariable(parent)) || isArgumentOfWellKnownMutationFunction(id, scope);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the mutation node.
|
|
74
|
+
* @param {ASTNode} id The Identifier node to get.
|
|
75
|
+
* @returns {ASTNode} The mutation node.
|
|
76
|
+
*/
|
|
77
|
+
function getWriteNode(id) {
|
|
78
|
+
let node = id.parent;
|
|
79
|
+
for (; node && node.type !== "AssignmentExpression" && node.type !== "UpdateExpression" && node.type !== "UnaryExpression" && node.type !== "CallExpression" && node.type !== "ForInStatement" && node.type !== "ForOfStatement";) node = node.parent;
|
|
80
|
+
return node || id;
|
|
81
|
+
}
|
|
82
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
83
|
+
module.exports = {
|
|
84
|
+
meta: {
|
|
85
|
+
type: "problem",
|
|
86
|
+
docs: {
|
|
87
|
+
description: "Disallow assigning to imported bindings",
|
|
88
|
+
recommended: !0,
|
|
89
|
+
url: "https://eslint.org/docs/latest/rules/no-import-assign"
|
|
90
|
+
},
|
|
91
|
+
schema: [],
|
|
92
|
+
messages: {
|
|
93
|
+
readonly: "'{{name}}' is read-only.",
|
|
94
|
+
readonlyMember: "The members of '{{name}}' are read-only."
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
create(context) {
|
|
98
|
+
let sourceCode = context.sourceCode;
|
|
99
|
+
return { ImportDeclaration(node) {
|
|
100
|
+
let scope = sourceCode.getScope(node);
|
|
101
|
+
for (let variable of sourceCode.getDeclaredVariables(node)) {
|
|
102
|
+
let shouldCheckMembers = variable.defs.some((d) => d.node.type === "ImportNamespaceSpecifier"), prevIdNode = null;
|
|
103
|
+
for (let reference of variable.references) {
|
|
104
|
+
let idNode = reference.identifier;
|
|
105
|
+
idNode !== prevIdNode && (prevIdNode = idNode, reference.isWrite() ? context.report({
|
|
106
|
+
node: getWriteNode(idNode),
|
|
107
|
+
messageId: "readonly",
|
|
108
|
+
data: { name: idNode.name }
|
|
109
|
+
}) : shouldCheckMembers && isMemberWrite(idNode, scope) && context.report({
|
|
110
|
+
node: getWriteNode(idNode),
|
|
111
|
+
messageId: "readonlyMember",
|
|
112
|
+
data: { name: idNode.name }
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} };
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}));
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src-js/generated/plugin-eslint/rules/no-import-assign.cjs
|
|
122
|
+
module.exports = require_no_import_assign().create;
|
|
123
|
+
//#endregion
|
|
@@ -0,0 +1,57 @@
|
|
|
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-inline-comments.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Enforces or disallows inline comments.
|
|
5
|
+
* @author Greg Cochard
|
|
6
|
+
*/
|
|
7
|
+
var require_no_inline_comments = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t();
|
|
9
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
10
|
+
module.exports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "suggestion",
|
|
13
|
+
defaultOptions: [{}],
|
|
14
|
+
docs: {
|
|
15
|
+
description: "Disallow inline comments after code",
|
|
16
|
+
recommended: !1,
|
|
17
|
+
frozen: !0,
|
|
18
|
+
url: "https://eslint.org/docs/latest/rules/no-inline-comments"
|
|
19
|
+
},
|
|
20
|
+
schema: [{
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: { ignorePattern: { type: "string" } },
|
|
23
|
+
additionalProperties: !1
|
|
24
|
+
}],
|
|
25
|
+
messages: { unexpectedInlineComment: "Unexpected comment inline with code." }
|
|
26
|
+
},
|
|
27
|
+
create(context) {
|
|
28
|
+
let sourceCode = context.sourceCode, [{ ignorePattern }] = context.options, customIgnoreRegExp = ignorePattern && new RegExp(ignorePattern, "u");
|
|
29
|
+
/**
|
|
30
|
+
* Will check that comments are not on lines starting with or ending with code
|
|
31
|
+
* @param {ASTNode} node The comment node to check
|
|
32
|
+
* @private
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
function testCodeAroundComment(node) {
|
|
36
|
+
let startLine = String(sourceCode.lines[node.loc.start.line - 1]), endLine = String(sourceCode.lines[node.loc.end.line - 1]), preamble = startLine.slice(0, node.loc.start.column).trim(), postamble = endLine.slice(node.loc.end.column).trim(), isPreambleEmpty = !preamble, isPostambleEmpty = !postamble;
|
|
37
|
+
if (!(isPreambleEmpty && isPostambleEmpty) && !(customIgnoreRegExp && customIgnoreRegExp.test(node.value))) {
|
|
38
|
+
if ((isPreambleEmpty || preamble === "{") && (isPostambleEmpty || postamble === "}")) {
|
|
39
|
+
let enclosingNode = sourceCode.getNodeByRangeIndex(node.range[0]);
|
|
40
|
+
if (enclosingNode && enclosingNode.type === "JSXEmptyExpression") return;
|
|
41
|
+
}
|
|
42
|
+
astUtils.isDirectiveComment(node) || context.report({
|
|
43
|
+
node,
|
|
44
|
+
messageId: "unexpectedInlineComment"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { Program() {
|
|
49
|
+
sourceCode.getAllComments().filter((token) => token.type !== "Shebang").forEach(testCodeAroundComment);
|
|
50
|
+
} };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}));
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src-js/generated/plugin-eslint/rules/no-inline-comments.cjs
|
|
56
|
+
module.exports = require_no_inline_comments().create;
|
|
57
|
+
//#endregion
|
|
@@ -0,0 +1,82 @@
|
|
|
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-inner-declarations.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to enforce declarations in program or function body root.
|
|
5
|
+
* @author Brandon Mills
|
|
6
|
+
*/
|
|
7
|
+
var require_no_inner_declarations = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t(), validParent = new Set([
|
|
9
|
+
"Program",
|
|
10
|
+
"StaticBlock",
|
|
11
|
+
"ExportNamedDeclaration",
|
|
12
|
+
"ExportDefaultDeclaration"
|
|
13
|
+
]), validBlockStatementParent = new Set([
|
|
14
|
+
"FunctionDeclaration",
|
|
15
|
+
"FunctionExpression",
|
|
16
|
+
"ArrowFunctionExpression"
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Finds the nearest enclosing context where this rule allows declarations and returns its description.
|
|
20
|
+
* @param {ASTNode} node Node to search from.
|
|
21
|
+
* @returns {string} Description. One of "program", "function body", "class static block body".
|
|
22
|
+
*/
|
|
23
|
+
function getAllowedBodyDescription(node) {
|
|
24
|
+
let { parent } = node;
|
|
25
|
+
for (; parent;) {
|
|
26
|
+
if (parent.type === "StaticBlock") return "class static block body";
|
|
27
|
+
if (astUtils.isFunction(parent)) return "function body";
|
|
28
|
+
({parent} = parent);
|
|
29
|
+
}
|
|
30
|
+
return "program";
|
|
31
|
+
}
|
|
32
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
33
|
+
module.exports = {
|
|
34
|
+
meta: {
|
|
35
|
+
type: "problem",
|
|
36
|
+
defaultOptions: ["functions", { blockScopedFunctions: "allow" }],
|
|
37
|
+
docs: {
|
|
38
|
+
description: "Disallow variable or `function` declarations in nested blocks",
|
|
39
|
+
recommended: !1,
|
|
40
|
+
url: "https://eslint.org/docs/latest/rules/no-inner-declarations"
|
|
41
|
+
},
|
|
42
|
+
schema: [{ enum: ["functions", "both"] }, {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: { blockScopedFunctions: { enum: ["allow", "disallow"] } },
|
|
45
|
+
additionalProperties: !1
|
|
46
|
+
}],
|
|
47
|
+
messages: { moveDeclToRoot: "Move {{type}} declaration to {{body}} root." }
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
let both = context.options[0] === "both", { blockScopedFunctions } = context.options[1], sourceCode = context.sourceCode, ecmaVersion = context.languageOptions.ecmaVersion;
|
|
51
|
+
/**
|
|
52
|
+
* Ensure that a given node is at a program or function body's root.
|
|
53
|
+
* @param {ASTNode} node Declaration node to check.
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
function check(node) {
|
|
57
|
+
let parent = node.parent;
|
|
58
|
+
parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type) || validParent.has(parent.type) || context.report({
|
|
59
|
+
node,
|
|
60
|
+
messageId: "moveDeclToRoot",
|
|
61
|
+
data: {
|
|
62
|
+
type: node.type === "FunctionDeclaration" ? "function" : "variable",
|
|
63
|
+
body: getAllowedBodyDescription(node)
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
FunctionDeclaration(node) {
|
|
69
|
+
let isInStrictCode = sourceCode.getScope(node).upper.isStrict;
|
|
70
|
+
blockScopedFunctions === "allow" && ecmaVersion >= 2015 && isInStrictCode || check(node);
|
|
71
|
+
},
|
|
72
|
+
VariableDeclaration(node) {
|
|
73
|
+
both && node.kind === "var" && check(node);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}));
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src-js/generated/plugin-eslint/rules/no-inner-declarations.cjs
|
|
81
|
+
module.exports = require_no_inner_declarations().create;
|
|
82
|
+
//#endregion
|
|
@@ -0,0 +1,130 @@
|
|
|
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-invalid-regexp.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Validate strings passed to the RegExp constructor
|
|
5
|
+
* @author Michael Ficarra
|
|
6
|
+
*/
|
|
7
|
+
var require_no_invalid_regexp = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let RegExpValidator = require_regexpp$1.t().RegExpValidator, validator = new RegExpValidator(), validFlags = "dgimsuvy";
|
|
9
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
10
|
+
module.exports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: "problem",
|
|
13
|
+
defaultOptions: [{}],
|
|
14
|
+
docs: {
|
|
15
|
+
description: "Disallow invalid regular expression strings in `RegExp` constructors",
|
|
16
|
+
recommended: !0,
|
|
17
|
+
url: "https://eslint.org/docs/latest/rules/no-invalid-regexp"
|
|
18
|
+
},
|
|
19
|
+
schema: [{
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: { allowConstructorFlags: {
|
|
22
|
+
type: "array",
|
|
23
|
+
items: { type: "string" }
|
|
24
|
+
} },
|
|
25
|
+
additionalProperties: !1
|
|
26
|
+
}],
|
|
27
|
+
messages: { regexMessage: "{{message}}." }
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
let [{ allowConstructorFlags }] = context.options, allowedFlags = [];
|
|
31
|
+
if (allowConstructorFlags) {
|
|
32
|
+
let temp = allowConstructorFlags.join("").replace(RegExp(`[${validFlags}]`, "gu"), "");
|
|
33
|
+
temp && (allowedFlags = [...new Set(temp)]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reports error with the provided message.
|
|
37
|
+
* @param {ASTNode} node The node holding the invalid RegExp
|
|
38
|
+
* @param {string} message The message to report.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
function report(node, message) {
|
|
42
|
+
context.report({
|
|
43
|
+
node,
|
|
44
|
+
messageId: "regexMessage",
|
|
45
|
+
data: { message }
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if node is a string
|
|
50
|
+
* @param {ASTNode} node node to evaluate
|
|
51
|
+
* @returns {boolean} True if its a string
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
function isString(node) {
|
|
55
|
+
return node && node.type === "Literal" && typeof node.value == "string";
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets flags of a regular expression created by the given `RegExp()` or `new RegExp()` call
|
|
59
|
+
* Examples:
|
|
60
|
+
* new RegExp(".") // => ""
|
|
61
|
+
* new RegExp(".", "gu") // => "gu"
|
|
62
|
+
* new RegExp(".", flags) // => null
|
|
63
|
+
* @param {ASTNode} node `CallExpression` or `NewExpression` node
|
|
64
|
+
* @returns {string|null} flags if they can be determined, `null` otherwise
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
function getFlags(node) {
|
|
68
|
+
return node.arguments.length < 2 ? "" : isString(node.arguments[1]) ? node.arguments[1].value : null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check syntax error in a given pattern.
|
|
72
|
+
* @param {string} pattern The RegExp pattern to validate.
|
|
73
|
+
* @param {Object} flags The RegExp flags to validate.
|
|
74
|
+
* @param {boolean} [flags.unicode] The Unicode flag.
|
|
75
|
+
* @param {boolean} [flags.unicodeSets] The UnicodeSets flag.
|
|
76
|
+
* @returns {string|null} The syntax error.
|
|
77
|
+
*/
|
|
78
|
+
function validateRegExpPattern(pattern, flags) {
|
|
79
|
+
try {
|
|
80
|
+
return validator.validatePattern(pattern, void 0, void 0, flags), null;
|
|
81
|
+
} catch (err) {
|
|
82
|
+
return err.message;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check syntax error in a given flags.
|
|
87
|
+
* @param {string|null} flags The RegExp flags to validate.
|
|
88
|
+
* @param {string|null} flagsToCheck The RegExp invalid flags.
|
|
89
|
+
* @param {string} allFlags all valid and allowed flags.
|
|
90
|
+
* @returns {string|null} The syntax error.
|
|
91
|
+
*/
|
|
92
|
+
function validateRegExpFlags(flags, flagsToCheck, allFlags) {
|
|
93
|
+
let duplicateFlags = [];
|
|
94
|
+
if (typeof flagsToCheck == "string") for (let flag of flagsToCheck) allFlags.includes(flag) && duplicateFlags.push(flag);
|
|
95
|
+
return flags && flags.includes("u") && flags.includes("v") ? "Regex 'u' and 'v' flags cannot be used together" : duplicateFlags.length > 0 ? `Duplicate flags ('${duplicateFlags.join("")}') supplied to RegExp constructor` : flagsToCheck ? `Invalid flags supplied to RegExp constructor '${flagsToCheck}'` : null;
|
|
96
|
+
}
|
|
97
|
+
return { "CallExpression, NewExpression"(node) {
|
|
98
|
+
if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp") return;
|
|
99
|
+
let flags = getFlags(node), flagsToCheck = flags, allFlags = allowedFlags.length > 0 ? validFlags.split("").concat(allowedFlags) : validFlags.split("");
|
|
100
|
+
flags && allFlags.forEach((flag) => {
|
|
101
|
+
flagsToCheck = flagsToCheck.replace(flag, "");
|
|
102
|
+
});
|
|
103
|
+
let message = validateRegExpFlags(flags, flagsToCheck, allFlags);
|
|
104
|
+
if (message) {
|
|
105
|
+
report(node, message);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!isString(node.arguments[0])) return;
|
|
109
|
+
let pattern = node.arguments[0].value;
|
|
110
|
+
message = flags === null ? validateRegExpPattern(pattern, {
|
|
111
|
+
unicode: !0,
|
|
112
|
+
unicodeSets: !1
|
|
113
|
+
}) && validateRegExpPattern(pattern, {
|
|
114
|
+
unicode: !1,
|
|
115
|
+
unicodeSets: !0
|
|
116
|
+
}) && validateRegExpPattern(pattern, {
|
|
117
|
+
unicode: !1,
|
|
118
|
+
unicodeSets: !1
|
|
119
|
+
}) : validateRegExpPattern(pattern, {
|
|
120
|
+
unicode: flags.includes("u"),
|
|
121
|
+
unicodeSets: flags.includes("v")
|
|
122
|
+
}), message && report(node, message);
|
|
123
|
+
} };
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}));
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src-js/generated/plugin-eslint/rules/no-invalid-regexp.cjs
|
|
129
|
+
module.exports = require_no_invalid_regexp().create;
|
|
130
|
+
//#endregion
|
|
@@ -0,0 +1,90 @@
|
|
|
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-invalid-this.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview A rule to disallow `this` keywords in contexts where the value of `this` is `undefined`.
|
|
5
|
+
* @author Toru Nagashima
|
|
6
|
+
*/
|
|
7
|
+
var require_no_invalid_this = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t();
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the given code path is a code path with lexical `this` binding.
|
|
11
|
+
* That is, if `this` within the code path refers to `this` of surrounding code path.
|
|
12
|
+
* @param {CodePath} codePath Code path.
|
|
13
|
+
* @param {ASTNode} node Node that started the code path.
|
|
14
|
+
* @returns {boolean} `true` if it is a code path with lexical `this` binding.
|
|
15
|
+
*/
|
|
16
|
+
function isCodePathWithLexicalThis(codePath, node) {
|
|
17
|
+
return codePath.origin === "function" && node.type === "ArrowFunctionExpression";
|
|
18
|
+
}
|
|
19
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
20
|
+
module.exports = {
|
|
21
|
+
meta: {
|
|
22
|
+
dialects: ["javascript", "typescript"],
|
|
23
|
+
language: "javascript",
|
|
24
|
+
type: "suggestion",
|
|
25
|
+
defaultOptions: [{ capIsConstructor: !0 }],
|
|
26
|
+
docs: {
|
|
27
|
+
description: "Disallow use of `this` in contexts where the value of `this` is `undefined`",
|
|
28
|
+
recommended: !1,
|
|
29
|
+
url: "https://eslint.org/docs/latest/rules/no-invalid-this"
|
|
30
|
+
},
|
|
31
|
+
schema: [{
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: { capIsConstructor: { type: "boolean" } },
|
|
34
|
+
additionalProperties: !1
|
|
35
|
+
}],
|
|
36
|
+
messages: { unexpectedThis: "Unexpected 'this'." }
|
|
37
|
+
},
|
|
38
|
+
create(context) {
|
|
39
|
+
let [{ capIsConstructor }] = context.options, stack = [], sourceCode = context.sourceCode;
|
|
40
|
+
return stack.getCurrent = function() {
|
|
41
|
+
let current = this.at(-1);
|
|
42
|
+
return current.init || (current.init = !0, current.valid = !astUtils.isDefaultThisBinding(current.node, sourceCode, { capIsConstructor })), current;
|
|
43
|
+
}, {
|
|
44
|
+
onCodePathStart(codePath, node) {
|
|
45
|
+
if (!isCodePathWithLexicalThis(codePath, node)) {
|
|
46
|
+
if (codePath.origin === "program") {
|
|
47
|
+
let scope = sourceCode.getScope(node), features = context.languageOptions.parserOptions.ecmaFeatures || {};
|
|
48
|
+
stack.push({
|
|
49
|
+
init: !0,
|
|
50
|
+
node,
|
|
51
|
+
valid: !(node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict)
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
stack.push({
|
|
56
|
+
init: !sourceCode.getScope(node).isStrict,
|
|
57
|
+
node,
|
|
58
|
+
valid: !0
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
onCodePathEnd(codePath, node) {
|
|
63
|
+
isCodePathWithLexicalThis(codePath, node) || stack.pop();
|
|
64
|
+
},
|
|
65
|
+
"AccessorProperty > *.value"(node) {
|
|
66
|
+
stack.push({
|
|
67
|
+
init: !0,
|
|
68
|
+
node,
|
|
69
|
+
valid: !0
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
"AccessorProperty:exit"() {
|
|
73
|
+
stack.pop();
|
|
74
|
+
},
|
|
75
|
+
ThisExpression(node) {
|
|
76
|
+
if (node.parent.type === "AccessorProperty" && node.parent.value === node) return;
|
|
77
|
+
let current = stack.getCurrent();
|
|
78
|
+
current && !current.valid && context.report({
|
|
79
|
+
node,
|
|
80
|
+
messageId: "unexpectedThis"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}));
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src-js/generated/plugin-eslint/rules/no-invalid-this.cjs
|
|
89
|
+
module.exports = require_no_invalid_this().create;
|
|
90
|
+
//#endregion
|