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,32 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-octal.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to flag when initializing octal literal
|
|
4
|
+
* @author Ilya Volodin
|
|
5
|
+
*/
|
|
6
|
+
var require_no_octal = /* @__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 octal literals",
|
|
13
|
+
recommended: !0,
|
|
14
|
+
url: "https://eslint.org/docs/latest/rules/no-octal"
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: { noOctal: "Octal literals should not be used." }
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
return { Literal(node) {
|
|
21
|
+
typeof node.value == "number" && /^0\d/u.test(node.raw) && context.report({
|
|
22
|
+
node,
|
|
23
|
+
messageId: "noOctal"
|
|
24
|
+
});
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}));
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src-js/generated/plugin-eslint/rules/no-octal.cjs
|
|
31
|
+
module.exports = require_no_octal().create;
|
|
32
|
+
//#endregion
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-param-reassign.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Disallow reassigning function parameters.
|
|
4
|
+
* @author Nat Burns
|
|
5
|
+
*/
|
|
6
|
+
var require_no_param_reassign = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
let stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
type: "suggestion",
|
|
12
|
+
docs: {
|
|
13
|
+
description: "Disallow reassigning function parameters",
|
|
14
|
+
recommended: !1,
|
|
15
|
+
url: "https://eslint.org/docs/latest/rules/no-param-reassign"
|
|
16
|
+
},
|
|
17
|
+
schema: [{ oneOf: [{
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: { props: { enum: [!1] } },
|
|
20
|
+
additionalProperties: !1
|
|
21
|
+
}, {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
props: { enum: [!0] },
|
|
25
|
+
ignorePropertyModificationsFor: {
|
|
26
|
+
type: "array",
|
|
27
|
+
items: { type: "string" },
|
|
28
|
+
uniqueItems: !0
|
|
29
|
+
},
|
|
30
|
+
ignorePropertyModificationsForRegex: {
|
|
31
|
+
type: "array",
|
|
32
|
+
items: { type: "string" },
|
|
33
|
+
uniqueItems: !0
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
additionalProperties: !1
|
|
37
|
+
}] }],
|
|
38
|
+
messages: {
|
|
39
|
+
assignmentToFunctionParam: "Assignment to function parameter '{{name}}'.",
|
|
40
|
+
assignmentToFunctionParamProp: "Assignment to property of function parameter '{{name}}'."
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
create(context) {
|
|
44
|
+
let props = context.options[0] && context.options[0].props, ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [], ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || [], sourceCode = context.sourceCode;
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether or not the reference modifies properties of its variable.
|
|
47
|
+
* @param {Reference} reference A reference to check.
|
|
48
|
+
* @returns {boolean} Whether or not the reference modifies properties of its variable.
|
|
49
|
+
*/
|
|
50
|
+
function isModifyingProp(reference) {
|
|
51
|
+
let node = reference.identifier, parent = node.parent;
|
|
52
|
+
for (; parent && (!stopNodePattern.test(parent.type) || parent.type === "ForInStatement" || parent.type === "ForOfStatement");) {
|
|
53
|
+
switch (parent.type) {
|
|
54
|
+
case "AssignmentExpression": return parent.left === node;
|
|
55
|
+
case "UpdateExpression": return !0;
|
|
56
|
+
case "UnaryExpression":
|
|
57
|
+
if (parent.operator === "delete") return !0;
|
|
58
|
+
break;
|
|
59
|
+
case "ForInStatement":
|
|
60
|
+
case "ForOfStatement": return parent.left === node;
|
|
61
|
+
case "CallExpression":
|
|
62
|
+
if (parent.callee !== node) return !1;
|
|
63
|
+
break;
|
|
64
|
+
case "MemberExpression":
|
|
65
|
+
if (parent.property === node) return !1;
|
|
66
|
+
break;
|
|
67
|
+
case "Property":
|
|
68
|
+
if (parent.key === node) return !1;
|
|
69
|
+
break;
|
|
70
|
+
case "ConditionalExpression":
|
|
71
|
+
if (parent.test === node) return !1;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
node = parent, parent = node.parent;
|
|
75
|
+
}
|
|
76
|
+
return !1;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Tests that an identifier name matches any of the ignored property assignments.
|
|
80
|
+
* First we test strings in ignoredPropertyAssignmentsFor.
|
|
81
|
+
* Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings.
|
|
82
|
+
* @param {string} identifierName A string that describes the name of an identifier to
|
|
83
|
+
* ignore property assignments for.
|
|
84
|
+
* @returns {boolean} Whether the string matches an ignored property assignment regular expression or not.
|
|
85
|
+
*/
|
|
86
|
+
function isIgnoredPropertyAssignment(identifierName) {
|
|
87
|
+
return ignoredPropertyAssignmentsFor.includes(identifierName) || ignoredPropertyAssignmentsForRegex.some((ignored) => new RegExp(ignored, "u").test(identifierName));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reports a reference if is non initializer and writable.
|
|
91
|
+
* @param {Reference} reference A reference to check.
|
|
92
|
+
* @param {number} index The index of the reference in the references.
|
|
93
|
+
* @param {Reference[]} references The array that the reference belongs to.
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
function checkReference(reference, index, references) {
|
|
97
|
+
let identifier = reference.identifier;
|
|
98
|
+
identifier && !reference.init && (index === 0 || references[index - 1].identifier !== identifier) && (reference.isWrite() ? context.report({
|
|
99
|
+
node: identifier,
|
|
100
|
+
messageId: "assignmentToFunctionParam",
|
|
101
|
+
data: { name: identifier.name }
|
|
102
|
+
}) : props && isModifyingProp(reference) && !isIgnoredPropertyAssignment(identifier.name) && context.report({
|
|
103
|
+
node: identifier,
|
|
104
|
+
messageId: "assignmentToFunctionParamProp",
|
|
105
|
+
data: { name: identifier.name }
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Finds and reports references that are non initializer and writable.
|
|
110
|
+
* @param {Variable} variable A variable to check.
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
function checkVariable(variable) {
|
|
114
|
+
variable.defs[0].type === "Parameter" && variable.references.forEach(checkReference);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Checks parameters of a given function node.
|
|
118
|
+
* @param {ASTNode} node A function node to check.
|
|
119
|
+
* @returns {void}
|
|
120
|
+
*/
|
|
121
|
+
function checkForFunction(node) {
|
|
122
|
+
sourceCode.getDeclaredVariables(node).forEach(checkVariable);
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
"FunctionDeclaration:exit": checkForFunction,
|
|
126
|
+
"FunctionExpression:exit": checkForFunction,
|
|
127
|
+
"ArrowFunctionExpression:exit": checkForFunction
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}));
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src-js/generated/plugin-eslint/rules/no-param-reassign.cjs
|
|
134
|
+
module.exports = require_no_param_reassign().create;
|
|
135
|
+
//#endregion
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-path-concat.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Disallow string concatenation when using __dirname and __filename
|
|
4
|
+
* @author Nicholas C. Zakas
|
|
5
|
+
* @deprecated in ESLint v7.0.0
|
|
6
|
+
*/
|
|
7
|
+
var require_no_path_concat = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
deprecated: {
|
|
12
|
+
message: "Node.js rules were moved out of ESLint core.",
|
|
13
|
+
url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
|
|
14
|
+
deprecatedSince: "7.0.0",
|
|
15
|
+
availableUntil: "11.0.0",
|
|
16
|
+
replacedBy: [{
|
|
17
|
+
message: "eslint-plugin-n now maintains deprecated Node.js-related rules.",
|
|
18
|
+
plugin: {
|
|
19
|
+
name: "eslint-plugin-n",
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n"
|
|
21
|
+
},
|
|
22
|
+
rule: {
|
|
23
|
+
name: "no-path-concat",
|
|
24
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-path-concat.md"
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
type: "suggestion",
|
|
29
|
+
docs: {
|
|
30
|
+
description: "Disallow string concatenation with `__dirname` and `__filename`",
|
|
31
|
+
recommended: !1,
|
|
32
|
+
url: "https://eslint.org/docs/latest/rules/no-path-concat"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
messages: { usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths." }
|
|
36
|
+
},
|
|
37
|
+
create(context) {
|
|
38
|
+
let MATCHER = /^__(?:dir|file)name$/u;
|
|
39
|
+
return { BinaryExpression(node) {
|
|
40
|
+
let left = node.left, right = node.right;
|
|
41
|
+
node.operator === "+" && (left.type === "Identifier" && MATCHER.test(left.name) || right.type === "Identifier" && MATCHER.test(right.name)) && context.report({
|
|
42
|
+
node,
|
|
43
|
+
messageId: "usePathFunctions"
|
|
44
|
+
});
|
|
45
|
+
} };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src-js/generated/plugin-eslint/rules/no-path-concat.cjs
|
|
51
|
+
module.exports = require_no_path_concat().create;
|
|
52
|
+
//#endregion
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-plusplus.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to flag use of unary increment and decrement operators.
|
|
4
|
+
* @author Ian Christian Myers
|
|
5
|
+
* @author Brody McKee (github.com/mrmckeb)
|
|
6
|
+
*/
|
|
7
|
+
var require_no_plusplus = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether the given node is the update node of a `ForStatement`.
|
|
10
|
+
* @param {ASTNode} node The node to check.
|
|
11
|
+
* @returns {boolean} `true` if the node is `ForStatement` update.
|
|
12
|
+
*/
|
|
13
|
+
function isForStatementUpdate(node) {
|
|
14
|
+
let parent = node.parent;
|
|
15
|
+
return parent.type === "ForStatement" && parent.update === node;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule.
|
|
19
|
+
* In particular, it returns `true` if the given node is either:
|
|
20
|
+
* - The update node of a `ForStatement`: for (;; i++) {}
|
|
21
|
+
* - An operand of a sequence expression that is the update node: for (;; foo(), i++) {}
|
|
22
|
+
* - An operand of a sequence expression that is child of another sequence expression, etc.,
|
|
23
|
+
* up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {}
|
|
24
|
+
* @param {ASTNode} node The node to check.
|
|
25
|
+
* @returns {boolean} `true` if the node is a for loop afterthought.
|
|
26
|
+
*/
|
|
27
|
+
function isForLoopAfterthought(node) {
|
|
28
|
+
let parent = node.parent;
|
|
29
|
+
return parent.type === "SequenceExpression" ? isForLoopAfterthought(parent) : isForStatementUpdate(node);
|
|
30
|
+
}
|
|
31
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
32
|
+
module.exports = {
|
|
33
|
+
meta: {
|
|
34
|
+
type: "suggestion",
|
|
35
|
+
defaultOptions: [{ allowForLoopAfterthoughts: !1 }],
|
|
36
|
+
docs: {
|
|
37
|
+
description: "Disallow the unary operators `++` and `--`",
|
|
38
|
+
recommended: !1,
|
|
39
|
+
frozen: !0,
|
|
40
|
+
url: "https://eslint.org/docs/latest/rules/no-plusplus"
|
|
41
|
+
},
|
|
42
|
+
schema: [{
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: { allowForLoopAfterthoughts: { type: "boolean" } },
|
|
45
|
+
additionalProperties: !1
|
|
46
|
+
}],
|
|
47
|
+
messages: { unexpectedUnaryOp: "Unary operator '{{operator}}' used." }
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
let [{ allowForLoopAfterthoughts }] = context.options;
|
|
51
|
+
return { UpdateExpression(node) {
|
|
52
|
+
allowForLoopAfterthoughts && isForLoopAfterthought(node) || context.report({
|
|
53
|
+
node,
|
|
54
|
+
messageId: "unexpectedUnaryOp",
|
|
55
|
+
data: { operator: node.operator }
|
|
56
|
+
});
|
|
57
|
+
} };
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}));
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src-js/generated/plugin-eslint/rules/no-plusplus.cjs
|
|
63
|
+
module.exports = require_no_plusplus().create;
|
|
64
|
+
//#endregion
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-process-env.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Disallow the use of process.env()
|
|
4
|
+
* @author Vignesh Anand
|
|
5
|
+
* @deprecated in ESLint v7.0.0
|
|
6
|
+
*/
|
|
7
|
+
var require_no_process_env = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
deprecated: {
|
|
12
|
+
message: "Node.js rules were moved out of ESLint core.",
|
|
13
|
+
url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
|
|
14
|
+
deprecatedSince: "7.0.0",
|
|
15
|
+
availableUntil: "11.0.0",
|
|
16
|
+
replacedBy: [{
|
|
17
|
+
message: "eslint-plugin-n now maintains deprecated Node.js-related rules.",
|
|
18
|
+
plugin: {
|
|
19
|
+
name: "eslint-plugin-n",
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n"
|
|
21
|
+
},
|
|
22
|
+
rule: {
|
|
23
|
+
name: "no-process-env",
|
|
24
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-process-env.md"
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
type: "suggestion",
|
|
29
|
+
docs: {
|
|
30
|
+
description: "Disallow the use of `process.env`",
|
|
31
|
+
recommended: !1,
|
|
32
|
+
url: "https://eslint.org/docs/latest/rules/no-process-env"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
messages: { unexpectedProcessEnv: "Unexpected use of process.env." }
|
|
36
|
+
},
|
|
37
|
+
create(context) {
|
|
38
|
+
return { MemberExpression(node) {
|
|
39
|
+
let objectName = node.object.name, propertyName = node.property.name;
|
|
40
|
+
objectName === "process" && !node.computed && propertyName && propertyName === "env" && context.report({
|
|
41
|
+
node,
|
|
42
|
+
messageId: "unexpectedProcessEnv"
|
|
43
|
+
});
|
|
44
|
+
} };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}));
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src-js/generated/plugin-eslint/rules/no-process-env.cjs
|
|
50
|
+
module.exports = require_no_process_env().create;
|
|
51
|
+
//#endregion
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-process-exit.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Disallow the use of process.exit()
|
|
4
|
+
* @author Nicholas C. Zakas
|
|
5
|
+
* @deprecated in ESLint v7.0.0
|
|
6
|
+
*/
|
|
7
|
+
var require_no_process_exit = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
deprecated: {
|
|
12
|
+
message: "Node.js rules were moved out of ESLint core.",
|
|
13
|
+
url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
|
|
14
|
+
deprecatedSince: "7.0.0",
|
|
15
|
+
availableUntil: "11.0.0",
|
|
16
|
+
replacedBy: [{
|
|
17
|
+
message: "eslint-plugin-n now maintains deprecated Node.js-related rules.",
|
|
18
|
+
plugin: {
|
|
19
|
+
name: "eslint-plugin-n",
|
|
20
|
+
url: "https://github.com/eslint-community/eslint-plugin-n"
|
|
21
|
+
},
|
|
22
|
+
rule: {
|
|
23
|
+
name: "no-process-exit",
|
|
24
|
+
url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-process-exit.md"
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
type: "suggestion",
|
|
29
|
+
docs: {
|
|
30
|
+
description: "Disallow the use of `process.exit()`",
|
|
31
|
+
recommended: !1,
|
|
32
|
+
url: "https://eslint.org/docs/latest/rules/no-process-exit"
|
|
33
|
+
},
|
|
34
|
+
schema: [],
|
|
35
|
+
messages: { noProcessExit: "Don't use process.exit(); throw an error instead." }
|
|
36
|
+
},
|
|
37
|
+
create(context) {
|
|
38
|
+
return { "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
|
|
39
|
+
context.report({
|
|
40
|
+
node: node.parent,
|
|
41
|
+
messageId: "noProcessExit"
|
|
42
|
+
});
|
|
43
|
+
} };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}));
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src-js/generated/plugin-eslint/rules/no-process-exit.cjs
|
|
49
|
+
module.exports = require_no_process_exit().create;
|
|
50
|
+
//#endregion
|
|
@@ -0,0 +1,131 @@
|
|
|
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-promise-executor-return.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to disallow returning values from Promise executor functions
|
|
5
|
+
* @author Milos Djermanovic
|
|
6
|
+
*/
|
|
7
|
+
var require_no_promise_executor_return = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t(), functionTypesToCheck = new Set(["ArrowFunctionExpression", "FunctionExpression"]);
|
|
9
|
+
/**
|
|
10
|
+
* Determines whether the given function node is used as a Promise executor.
|
|
11
|
+
* @param {ASTNode} node The node to check.
|
|
12
|
+
* @param {SourceCode} sourceCode Source code to which the node belongs.
|
|
13
|
+
* @returns {boolean} `true` if the node is a Promise executor.
|
|
14
|
+
*/
|
|
15
|
+
function isPromiseExecutor(node, sourceCode) {
|
|
16
|
+
let parent = node.parent;
|
|
17
|
+
return parent.type === "NewExpression" && parent.arguments[0] === node && parent.callee.type === "Identifier" && parent.callee.name === "Promise" && sourceCode.isGlobalReference(parent.callee);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks if the given node is a void expression.
|
|
21
|
+
* @param {ASTNode} node The node to check.
|
|
22
|
+
* @returns {boolean} - `true` if the node is a void expression
|
|
23
|
+
*/
|
|
24
|
+
function expressionIsVoid(node) {
|
|
25
|
+
return node.type === "UnaryExpression" && node.operator === "void";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fixes the linting error by prepending "void " to the given node
|
|
29
|
+
* @param {Object} sourceCode context given by context.sourceCode
|
|
30
|
+
* @param {ASTNode} node The node to fix.
|
|
31
|
+
* @param {Object} fixer The fixer object provided by ESLint.
|
|
32
|
+
* @returns {Array<Object>} - An array of fix objects to apply to the node.
|
|
33
|
+
*/
|
|
34
|
+
function voidPrependFixer(sourceCode, node, fixer) {
|
|
35
|
+
let requiresParens = astUtils.getPrecedence(node) < astUtils.getPrecedence({
|
|
36
|
+
type: "UnaryExpression",
|
|
37
|
+
operator: "void"
|
|
38
|
+
}) && !astUtils.isParenthesised(sourceCode, node), returnOrArrowToken = sourceCode.getTokenBefore(node, node.parent.type === "ArrowFunctionExpression" ? astUtils.isArrowToken : (token) => token.type === "Keyword" && token.value === "return"), firstToken = sourceCode.getTokenAfter(returnOrArrowToken), prependSpace = returnOrArrowToken.value === "return" && returnOrArrowToken.range[1] === firstToken.range[0];
|
|
39
|
+
return [fixer.insertTextBefore(firstToken, `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`), fixer.insertTextAfter(node, requiresParens ? ")" : "")];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fixes the linting error by `wrapping {}` around the given node's body.
|
|
43
|
+
* @param {Object} sourceCode context given by context.sourceCode
|
|
44
|
+
* @param {ASTNode} node The node to fix.
|
|
45
|
+
* @param {Object} fixer The fixer object provided by ESLint.
|
|
46
|
+
* @returns {Array<Object>} - An array of fix objects to apply to the node.
|
|
47
|
+
*/
|
|
48
|
+
function curlyWrapFixer(sourceCode, node, fixer) {
|
|
49
|
+
let arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken), firstToken = sourceCode.getTokenAfter(arrowToken), lastToken = sourceCode.getLastToken(node);
|
|
50
|
+
return [fixer.insertTextBefore(firstToken, "{"), fixer.insertTextAfter(lastToken, "}")];
|
|
51
|
+
}
|
|
52
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
53
|
+
module.exports = {
|
|
54
|
+
meta: {
|
|
55
|
+
type: "problem",
|
|
56
|
+
defaultOptions: [{ allowVoid: !1 }],
|
|
57
|
+
docs: {
|
|
58
|
+
description: "Disallow returning values from Promise executor functions",
|
|
59
|
+
recommended: !1,
|
|
60
|
+
url: "https://eslint.org/docs/latest/rules/no-promise-executor-return"
|
|
61
|
+
},
|
|
62
|
+
hasSuggestions: !0,
|
|
63
|
+
schema: [{
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: { allowVoid: { type: "boolean" } },
|
|
66
|
+
additionalProperties: !1
|
|
67
|
+
}],
|
|
68
|
+
messages: {
|
|
69
|
+
returnsValue: "Return values from promise executor functions cannot be read.",
|
|
70
|
+
prependVoid: "Prepend `void` to the expression.",
|
|
71
|
+
wrapBraces: "Wrap the expression in `{}`."
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
create(context) {
|
|
75
|
+
let funcInfo = null, sourceCode = context.sourceCode, [{ allowVoid }] = context.options;
|
|
76
|
+
return {
|
|
77
|
+
onCodePathStart(_, node) {
|
|
78
|
+
if (funcInfo = {
|
|
79
|
+
upper: funcInfo,
|
|
80
|
+
shouldCheck: functionTypesToCheck.has(node.type) && isPromiseExecutor(node, sourceCode)
|
|
81
|
+
}, funcInfo.shouldCheck && node.type === "ArrowFunctionExpression" && node.expression && !(allowVoid && expressionIsVoid(node.body))) {
|
|
82
|
+
let suggest = [];
|
|
83
|
+
allowVoid && suggest.push({
|
|
84
|
+
messageId: "prependVoid",
|
|
85
|
+
fix(fixer) {
|
|
86
|
+
return voidPrependFixer(sourceCode, node.body, fixer);
|
|
87
|
+
}
|
|
88
|
+
}), node.body.type === "FunctionExpression" && !node.body.id || suggest.push({
|
|
89
|
+
messageId: "wrapBraces",
|
|
90
|
+
fix(fixer) {
|
|
91
|
+
return curlyWrapFixer(sourceCode, node, fixer);
|
|
92
|
+
}
|
|
93
|
+
}), context.report({
|
|
94
|
+
node: node.body,
|
|
95
|
+
messageId: "returnsValue",
|
|
96
|
+
suggest
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
onCodePathEnd() {
|
|
101
|
+
funcInfo = funcInfo.upper;
|
|
102
|
+
},
|
|
103
|
+
ReturnStatement(node) {
|
|
104
|
+
if (funcInfo.shouldCheck && node.argument) {
|
|
105
|
+
if (!allowVoid) {
|
|
106
|
+
context.report({
|
|
107
|
+
node,
|
|
108
|
+
messageId: "returnsValue"
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
expressionIsVoid(node.argument) || context.report({
|
|
113
|
+
node,
|
|
114
|
+
messageId: "returnsValue",
|
|
115
|
+
suggest: [{
|
|
116
|
+
messageId: "prependVoid",
|
|
117
|
+
fix(fixer) {
|
|
118
|
+
return voidPrependFixer(sourceCode, node.argument, fixer);
|
|
119
|
+
}
|
|
120
|
+
}]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}));
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src-js/generated/plugin-eslint/rules/no-promise-executor-return.cjs
|
|
130
|
+
module.exports = require_no_promise_executor_return().create;
|
|
131
|
+
//#endregion
|
|
@@ -0,0 +1,34 @@
|
|
|
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-proto.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag usage of __proto__ property
|
|
5
|
+
* @author Ilya Volodin
|
|
6
|
+
*/
|
|
7
|
+
var require_no_proto = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let { getStaticPropertyName } = require_ast_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 the `__proto__` property",
|
|
15
|
+
recommended: !1,
|
|
16
|
+
url: "https://eslint.org/docs/latest/rules/no-proto"
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: { unexpectedProto: "The '__proto__' property is deprecated." }
|
|
20
|
+
},
|
|
21
|
+
create(context) {
|
|
22
|
+
return { MemberExpression(node) {
|
|
23
|
+
getStaticPropertyName(node) === "__proto__" && context.report({
|
|
24
|
+
node,
|
|
25
|
+
messageId: "unexpectedProto"
|
|
26
|
+
});
|
|
27
|
+
} };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}));
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src-js/generated/plugin-eslint/rules/no-proto.cjs
|
|
33
|
+
module.exports = require_no_proto().create;
|
|
34
|
+
//#endregion
|
|
@@ -0,0 +1,85 @@
|
|
|
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-prototype-builtins.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to disallow use of Object.prototype builtins on objects
|
|
5
|
+
* @author Andrew Levine
|
|
6
|
+
*/
|
|
7
|
+
var require_no_prototype_builtins = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let astUtils = require_ast_utils$1.t();
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the node or any of the objects
|
|
11
|
+
* to the left of it in the member/call chain is optional.
|
|
12
|
+
*
|
|
13
|
+
* e.g. `a?.b`, `a?.b.c`, `a?.()`, `a()?.()`
|
|
14
|
+
* @param {ASTNode} node The expression to check
|
|
15
|
+
* @returns {boolean} `true` if there is a short-circuiting optional `?.`
|
|
16
|
+
* in the same option chain to the left of this call or member expression,
|
|
17
|
+
* or the node itself is an optional call or member `?.`.
|
|
18
|
+
*/
|
|
19
|
+
function isAfterOptional(node) {
|
|
20
|
+
let leftNode;
|
|
21
|
+
if (node.type === "MemberExpression") leftNode = node.object;
|
|
22
|
+
else if (node.type === "CallExpression") leftNode = node.callee;
|
|
23
|
+
else return !1;
|
|
24
|
+
return node.optional ? !0 : isAfterOptional(leftNode);
|
|
25
|
+
}
|
|
26
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
27
|
+
module.exports = {
|
|
28
|
+
meta: {
|
|
29
|
+
type: "problem",
|
|
30
|
+
docs: {
|
|
31
|
+
description: "Disallow calling some `Object.prototype` methods directly on objects",
|
|
32
|
+
recommended: !0,
|
|
33
|
+
url: "https://eslint.org/docs/latest/rules/no-prototype-builtins"
|
|
34
|
+
},
|
|
35
|
+
hasSuggestions: !0,
|
|
36
|
+
schema: [],
|
|
37
|
+
messages: {
|
|
38
|
+
prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object.",
|
|
39
|
+
callObjectPrototype: "Call Object.prototype.{{prop}} explicitly."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
create(context) {
|
|
43
|
+
let DISALLOWED_PROPS = new Set([
|
|
44
|
+
"hasOwnProperty",
|
|
45
|
+
"isPrototypeOf",
|
|
46
|
+
"propertyIsEnumerable"
|
|
47
|
+
]);
|
|
48
|
+
/**
|
|
49
|
+
* Reports if a disallowed property is used in a CallExpression
|
|
50
|
+
* @param {ASTNode} node The CallExpression node.
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
53
|
+
function disallowBuiltIns(node) {
|
|
54
|
+
let callee = astUtils.skipChainExpression(node.callee);
|
|
55
|
+
if (callee.type !== "MemberExpression") return;
|
|
56
|
+
let propName = astUtils.getStaticPropertyName(callee);
|
|
57
|
+
propName !== null && DISALLOWED_PROPS.has(propName) && context.report({
|
|
58
|
+
messageId: "prototypeBuildIn",
|
|
59
|
+
loc: callee.property.loc,
|
|
60
|
+
data: { prop: propName },
|
|
61
|
+
node,
|
|
62
|
+
suggest: [{
|
|
63
|
+
messageId: "callObjectPrototype",
|
|
64
|
+
data: { prop: propName },
|
|
65
|
+
fix(fixer) {
|
|
66
|
+
let sourceCode = context.sourceCode;
|
|
67
|
+
if (isAfterOptional(node) || node.callee.type === "ChainExpression") return null;
|
|
68
|
+
let objectVariable = astUtils.getVariableByName(sourceCode.getScope(node), "Object");
|
|
69
|
+
if (!objectVariable || objectVariable.scope.type !== "global" || objectVariable.defs.length > 0) return null;
|
|
70
|
+
let objectText = sourceCode.getText(callee.object);
|
|
71
|
+
astUtils.getPrecedence(callee.object) <= astUtils.getPrecedence({ type: "SequenceExpression" }) && (objectText = `(${objectText})`);
|
|
72
|
+
let openParenToken = sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken), delim = node.arguments.length === 0 ? "" : ", ";
|
|
73
|
+
return [fixer.replaceText(callee, `Object.prototype.${propName}.call`), fixer.insertTextAfter(openParenToken, objectText + delim)];
|
|
74
|
+
}
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return { CallExpression: disallowBuiltIns };
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}));
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src-js/generated/plugin-eslint/rules/no-prototype-builtins.cjs
|
|
84
|
+
module.exports = require_no_prototype_builtins().create;
|
|
85
|
+
//#endregion
|