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,126 @@
|
|
|
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/id-denylist.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule that warns when identifier names that are
|
|
5
|
+
* specified in the configuration are used.
|
|
6
|
+
* @author Keith Cirkel (http://keithcirkel.co.uk)
|
|
7
|
+
*/
|
|
8
|
+
var require_id_denylist = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let astUtils = require_ast_utils$1.t();
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether the given node represents assignment target in a normal assignment or destructuring.
|
|
12
|
+
* @param {ASTNode} node The node to check.
|
|
13
|
+
* @returns {boolean} `true` if the node is assignment target.
|
|
14
|
+
*/
|
|
15
|
+
function isAssignmentTarget(node) {
|
|
16
|
+
let parent = node.parent;
|
|
17
|
+
return parent.type === "AssignmentExpression" && parent.left === node || parent.type === "ArrayPattern" || parent.type === "RestElement" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "AssignmentPattern" && parent.left === node;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether the given node represents an imported name that is renamed in the same import/export specifier.
|
|
21
|
+
*
|
|
22
|
+
* Examples:
|
|
23
|
+
* import { a as b } from 'mod'; // node `a` is renamed import
|
|
24
|
+
* export { a as b } from 'mod'; // node `a` is renamed import
|
|
25
|
+
* @param {ASTNode} node `Identifier` node to check.
|
|
26
|
+
* @returns {boolean} `true` if the node is a renamed import.
|
|
27
|
+
*/
|
|
28
|
+
function isRenamedImport(node) {
|
|
29
|
+
let parent = node.parent;
|
|
30
|
+
return parent.type === "ImportSpecifier" && parent.imported !== parent.local && parent.imported === node || parent.type === "ExportSpecifier" && parent.parent.source && parent.local !== parent.exported && parent.local === node;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether the given node is an ObjectPattern destructuring.
|
|
34
|
+
*
|
|
35
|
+
* Examples:
|
|
36
|
+
* const { a : b } = foo;
|
|
37
|
+
* @param {ASTNode} node `Identifier` node to check.
|
|
38
|
+
* @returns {boolean} `true` if the node is in an ObjectPattern destructuring.
|
|
39
|
+
*/
|
|
40
|
+
function isPropertyNameInDestructuring(node) {
|
|
41
|
+
let parent = node.parent;
|
|
42
|
+
return !parent.computed && parent.type === "Property" && parent.parent.type === "ObjectPattern" && parent.key === node;
|
|
43
|
+
}
|
|
44
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
45
|
+
module.exports = {
|
|
46
|
+
meta: {
|
|
47
|
+
type: "suggestion",
|
|
48
|
+
defaultOptions: [],
|
|
49
|
+
docs: {
|
|
50
|
+
description: "Disallow specified identifiers",
|
|
51
|
+
recommended: !1,
|
|
52
|
+
frozen: !0,
|
|
53
|
+
url: "https://eslint.org/docs/latest/rules/id-denylist"
|
|
54
|
+
},
|
|
55
|
+
schema: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: { type: "string" },
|
|
58
|
+
uniqueItems: !0
|
|
59
|
+
},
|
|
60
|
+
messages: {
|
|
61
|
+
restricted: "Identifier '{{name}}' is restricted.",
|
|
62
|
+
restrictedPrivate: "Identifier '#{{name}}' is restricted."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
create(context) {
|
|
66
|
+
let denyList = new Set(context.options), reportedNodes = /* @__PURE__ */ new Set(), sourceCode = context.sourceCode, globalScope;
|
|
67
|
+
/**
|
|
68
|
+
* Checks whether the given name is restricted.
|
|
69
|
+
* @param {string} name The name to check.
|
|
70
|
+
* @returns {boolean} `true` if the name is restricted.
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
function isRestricted(name) {
|
|
74
|
+
return denyList.has(name);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks whether the given node represents a reference to a global variable that is not declared in the source code.
|
|
78
|
+
* These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
|
|
79
|
+
* @param {ASTNode} node `Identifier` node to check.
|
|
80
|
+
* @returns {boolean} `true` if the node is a reference to a global variable.
|
|
81
|
+
*/
|
|
82
|
+
function isReferenceToGlobalVariable(node) {
|
|
83
|
+
let variable = globalScope.set.get(node.name);
|
|
84
|
+
return variable && variable.defs.length === 0 && variable.references.some((ref) => ref.identifier === node);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Determines whether the given node should be checked.
|
|
88
|
+
* @param {ASTNode} node `Identifier` node.
|
|
89
|
+
* @returns {boolean} `true` if the node should be checked.
|
|
90
|
+
*/
|
|
91
|
+
function shouldCheck(node) {
|
|
92
|
+
if (astUtils.isImportAttributeKey(node)) return !1;
|
|
93
|
+
let parent = node.parent;
|
|
94
|
+
return parent.type === "MemberExpression" && parent.property === node && !parent.computed ? isAssignmentTarget(parent) : parent.type !== "CallExpression" && parent.type !== "NewExpression" && !isRenamedImport(node) && !isPropertyNameInDestructuring(node) && !isReferenceToGlobalVariable(node);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Reports an AST node as a rule violation.
|
|
98
|
+
* @param {ASTNode} node The node to report.
|
|
99
|
+
* @returns {void}
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
function report(node) {
|
|
103
|
+
if (!reportedNodes.has(node.range.toString())) {
|
|
104
|
+
let isPrivate = node.type === "PrivateIdentifier";
|
|
105
|
+
context.report({
|
|
106
|
+
node,
|
|
107
|
+
messageId: isPrivate ? "restrictedPrivate" : "restricted",
|
|
108
|
+
data: { name: node.name }
|
|
109
|
+
}), reportedNodes.add(node.range.toString());
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
Program(node) {
|
|
114
|
+
globalScope = sourceCode.getScope(node);
|
|
115
|
+
},
|
|
116
|
+
[["Identifier", "PrivateIdentifier"]](node) {
|
|
117
|
+
isRestricted(node.name) && shouldCheck(node) && report(node);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}));
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src-js/generated/plugin-eslint/rules/id-denylist.cjs
|
|
125
|
+
module.exports = require_id_denylist().create;
|
|
126
|
+
//#endregion
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs"), require_string_utils$1 = require("../common/string-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/id-length.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule that warns when identifier names are shorter or longer
|
|
5
|
+
* than the values provided in configuration.
|
|
6
|
+
* @author Burak Yigit Kaya aka BYK
|
|
7
|
+
*/
|
|
8
|
+
var require_id_length = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let { getGraphemeCount } = require_string_utils$1.t(), { getModuleExportName, isImportAttributeKey } = require_ast_utils$1.t();
|
|
10
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
meta: {
|
|
13
|
+
type: "suggestion",
|
|
14
|
+
defaultOptions: [{
|
|
15
|
+
exceptionPatterns: [],
|
|
16
|
+
exceptions: [],
|
|
17
|
+
min: 2,
|
|
18
|
+
properties: "always"
|
|
19
|
+
}],
|
|
20
|
+
docs: {
|
|
21
|
+
description: "Enforce minimum and maximum identifier lengths",
|
|
22
|
+
recommended: !1,
|
|
23
|
+
frozen: !0,
|
|
24
|
+
url: "https://eslint.org/docs/latest/rules/id-length"
|
|
25
|
+
},
|
|
26
|
+
schema: [{
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
min: { type: "integer" },
|
|
30
|
+
max: { type: "integer" },
|
|
31
|
+
exceptions: {
|
|
32
|
+
type: "array",
|
|
33
|
+
uniqueItems: !0,
|
|
34
|
+
items: { type: "string" }
|
|
35
|
+
},
|
|
36
|
+
exceptionPatterns: {
|
|
37
|
+
type: "array",
|
|
38
|
+
uniqueItems: !0,
|
|
39
|
+
items: { type: "string" }
|
|
40
|
+
},
|
|
41
|
+
properties: { enum: ["always", "never"] }
|
|
42
|
+
},
|
|
43
|
+
additionalProperties: !1
|
|
44
|
+
}],
|
|
45
|
+
messages: {
|
|
46
|
+
tooShort: "Identifier name '{{name}}' is too short (< {{min}}).",
|
|
47
|
+
tooShortPrivate: "Identifier name '#{{name}}' is too short (< {{min}}).",
|
|
48
|
+
tooLong: "Identifier name '{{name}}' is too long (> {{max}}).",
|
|
49
|
+
tooLongPrivate: "Identifier name #'{{name}}' is too long (> {{max}})."
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
create(context) {
|
|
53
|
+
let [options] = context.options, { max: maxLength = Infinity, min: minLength } = options, properties = options.properties !== "never", exceptions = new Set(options.exceptions), exceptionPatterns = options.exceptionPatterns.map((pattern) => new RegExp(pattern, "u")), reportedNodes = /* @__PURE__ */ new Set();
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a string matches the provided exception patterns
|
|
56
|
+
* @param {string} name The string to check.
|
|
57
|
+
* @returns {boolean} if the string is a match
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
function matchesExceptionPattern(name) {
|
|
61
|
+
return exceptionPatterns.some((pattern) => pattern.test(name));
|
|
62
|
+
}
|
|
63
|
+
let SUPPORTED_EXPRESSIONS = {
|
|
64
|
+
MemberExpression: properties && function(parent) {
|
|
65
|
+
return !parent.computed && (parent.parent.left === parent && parent.parent.type === "AssignmentExpression" || parent.parent.type === "Property" && parent.parent.value === parent && parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent);
|
|
66
|
+
},
|
|
67
|
+
AssignmentPattern(parent, node) {
|
|
68
|
+
return parent.left === node;
|
|
69
|
+
},
|
|
70
|
+
VariableDeclarator(parent, node) {
|
|
71
|
+
return parent.id === node;
|
|
72
|
+
},
|
|
73
|
+
Property(parent, node) {
|
|
74
|
+
if (parent.parent.type === "ObjectPattern") {
|
|
75
|
+
let isKeyAndValueSame = parent.value.name === parent.key.name;
|
|
76
|
+
return !isKeyAndValueSame && parent.value === node || isKeyAndValueSame && parent.key === node && properties;
|
|
77
|
+
}
|
|
78
|
+
return properties && !isImportAttributeKey(node) && !parent.computed && parent.key.name === node.name;
|
|
79
|
+
},
|
|
80
|
+
ImportSpecifier(parent, node) {
|
|
81
|
+
return parent.local === node && getModuleExportName(parent.imported) !== getModuleExportName(parent.local);
|
|
82
|
+
},
|
|
83
|
+
ImportDefaultSpecifier: !0,
|
|
84
|
+
ImportNamespaceSpecifier: !0,
|
|
85
|
+
RestElement: !0,
|
|
86
|
+
FunctionExpression: !0,
|
|
87
|
+
ArrowFunctionExpression: !0,
|
|
88
|
+
ClassDeclaration: !0,
|
|
89
|
+
FunctionDeclaration: !0,
|
|
90
|
+
MethodDefinition: !0,
|
|
91
|
+
PropertyDefinition: !0,
|
|
92
|
+
CatchClause: !0,
|
|
93
|
+
ArrayPattern: !0
|
|
94
|
+
};
|
|
95
|
+
return { [["Identifier", "PrivateIdentifier"]](node) {
|
|
96
|
+
let name = node.name, parent = node.parent, nameLength = getGraphemeCount(name), isShort = nameLength < minLength;
|
|
97
|
+
if (!(isShort || nameLength > maxLength) || exceptions.has(name) || matchesExceptionPattern(name)) return;
|
|
98
|
+
let isValidExpression = SUPPORTED_EXPRESSIONS[parent.type];
|
|
99
|
+
if (isValidExpression && !reportedNodes.has(node.range.toString()) && (isValidExpression === !0 || isValidExpression(parent, node))) {
|
|
100
|
+
reportedNodes.add(node.range.toString());
|
|
101
|
+
let messageId = isShort ? "tooShort" : "tooLong";
|
|
102
|
+
node.type === "PrivateIdentifier" && (messageId += "Private"), context.report({
|
|
103
|
+
node,
|
|
104
|
+
messageId,
|
|
105
|
+
data: {
|
|
106
|
+
name,
|
|
107
|
+
min: minLength,
|
|
108
|
+
max: maxLength
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
} };
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src-js/generated/plugin-eslint/rules/id-length.cjs
|
|
118
|
+
module.exports = require_id_length().create;
|
|
119
|
+
//#endregion
|
|
@@ -0,0 +1,139 @@
|
|
|
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/id-match.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to flag non-matching identifiers
|
|
5
|
+
* @author Matthieu Larcher
|
|
6
|
+
*/
|
|
7
|
+
var require_id_match = /* @__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
|
+
classFields: !1,
|
|
15
|
+
ignoreDestructuring: !1,
|
|
16
|
+
onlyDeclarations: !1,
|
|
17
|
+
properties: !1
|
|
18
|
+
}],
|
|
19
|
+
docs: {
|
|
20
|
+
description: "Require identifiers to match a specified regular expression",
|
|
21
|
+
recommended: !1,
|
|
22
|
+
frozen: !0,
|
|
23
|
+
url: "https://eslint.org/docs/latest/rules/id-match"
|
|
24
|
+
},
|
|
25
|
+
schema: [{ type: "string" }, {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
properties: { type: "boolean" },
|
|
29
|
+
classFields: { type: "boolean" },
|
|
30
|
+
onlyDeclarations: { type: "boolean" },
|
|
31
|
+
ignoreDestructuring: { type: "boolean" }
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: !1
|
|
34
|
+
}],
|
|
35
|
+
messages: {
|
|
36
|
+
notMatch: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.",
|
|
37
|
+
notMatchPrivate: "Identifier '#{{name}}' does not match the pattern '{{pattern}}'."
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
create(context) {
|
|
41
|
+
let [pattern, { classFields: checkClassFields, ignoreDestructuring, onlyDeclarations, properties: checkProperties }] = context.options, regexp = new RegExp(pattern, "u"), sourceCode = context.sourceCode, globalScope, reportedNodes = /* @__PURE__ */ new Set(), ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]), DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]), IMPORT_TYPES = new Set([
|
|
42
|
+
"ImportSpecifier",
|
|
43
|
+
"ImportNamespaceSpecifier",
|
|
44
|
+
"ImportDefaultSpecifier"
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the given node represents a reference to a global variable that is not declared in the source code.
|
|
48
|
+
* These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
|
|
49
|
+
* @param {ASTNode} node `Identifier` node to check.
|
|
50
|
+
* @returns {boolean} `true` if the node is a reference to a global variable.
|
|
51
|
+
*/
|
|
52
|
+
function isReferenceToGlobalVariable(node) {
|
|
53
|
+
let variable = globalScope.set.get(node.name);
|
|
54
|
+
return variable && variable.defs.length === 0 && variable.references.some((ref) => ref.identifier === node);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a string matches the provided pattern
|
|
58
|
+
* @param {string} name The string to check.
|
|
59
|
+
* @returns {boolean} if the string is a match
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
function isInvalid(name) {
|
|
63
|
+
return !regexp.test(name);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a parent of a node is an ObjectPattern.
|
|
67
|
+
* @param {ASTNode} node The node to check.
|
|
68
|
+
* @returns {boolean} if the node is inside an ObjectPattern
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
function isInsideObjectPattern(node) {
|
|
72
|
+
let { parent } = node;
|
|
73
|
+
for (; parent;) {
|
|
74
|
+
if (parent.type === "ObjectPattern") return !0;
|
|
75
|
+
parent = parent.parent;
|
|
76
|
+
}
|
|
77
|
+
return !1;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Verifies if we should report an error or not based on the effective
|
|
81
|
+
* parent node and the identifier name.
|
|
82
|
+
* @param {ASTNode} effectiveParent The effective parent node of the node to be reported
|
|
83
|
+
* @param {string} name The identifier name of the identifier node
|
|
84
|
+
* @returns {boolean} whether an error should be reported or not
|
|
85
|
+
*/
|
|
86
|
+
function shouldReport(effectiveParent, name) {
|
|
87
|
+
return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reports an AST node as a rule violation.
|
|
91
|
+
* @param {ASTNode} node The node to report.
|
|
92
|
+
* @returns {void}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
function report(node) {
|
|
96
|
+
if (!reportedNodes.has(node.range.toString())) {
|
|
97
|
+
let messageId = node.type === "PrivateIdentifier" ? "notMatchPrivate" : "notMatch";
|
|
98
|
+
context.report({
|
|
99
|
+
node,
|
|
100
|
+
messageId,
|
|
101
|
+
data: {
|
|
102
|
+
name: node.name,
|
|
103
|
+
pattern
|
|
104
|
+
}
|
|
105
|
+
}), reportedNodes.add(node.range.toString());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
Program(node) {
|
|
110
|
+
globalScope = sourceCode.getScope(node);
|
|
111
|
+
},
|
|
112
|
+
Identifier(node) {
|
|
113
|
+
let name = node.name, parent = node.parent, effectiveParent = parent.type === "MemberExpression" ? parent.parent : parent;
|
|
114
|
+
if (!(isReferenceToGlobalVariable(node) || astUtils.isImportAttributeKey(node))) if (parent.type === "MemberExpression") {
|
|
115
|
+
if (!checkProperties) return;
|
|
116
|
+
parent.object.type === "Identifier" && parent.object.name === name || effectiveParent.type === "AssignmentExpression" && effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name ? isInvalid(name) && report(node) : effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression" && isInvalid(name) && report(node);
|
|
117
|
+
} else if (parent.type === "Property" && parent.parent.type === "ObjectExpression" && parent.key === node && !parent.computed) checkProperties && isInvalid(name) && report(node);
|
|
118
|
+
else if (parent.type === "Property" || parent.type === "AssignmentPattern") {
|
|
119
|
+
if (parent.parent && parent.parent.type === "ObjectPattern") {
|
|
120
|
+
!ignoreDestructuring && parent.shorthand && parent.value.left && isInvalid(name) && report(node);
|
|
121
|
+
let assignmentKeyEqualsValue = parent.key.name === parent.value.name;
|
|
122
|
+
if (!assignmentKeyEqualsValue && parent.key === node) return;
|
|
123
|
+
parent.value.name && isInvalid(name) && !(assignmentKeyEqualsValue && ignoreDestructuring) && report(node);
|
|
124
|
+
}
|
|
125
|
+
if (!checkProperties && !parent.computed || ignoreDestructuring && isInsideObjectPattern(node)) return;
|
|
126
|
+
parent.right !== node && shouldReport(effectiveParent, name) && report(node);
|
|
127
|
+
} else IMPORT_TYPES.has(parent.type) ? parent.local && parent.local.name === node.name && isInvalid(name) && report(node) : parent.type === "PropertyDefinition" ? checkClassFields && isInvalid(name) && report(node) : shouldReport(effectiveParent, name) && report(node);
|
|
128
|
+
},
|
|
129
|
+
PrivateIdentifier(node) {
|
|
130
|
+
node.parent.type === "PropertyDefinition" && !checkClassFields || isInvalid(node.name) && report(node);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}));
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src-js/generated/plugin-eslint/rules/id-match.cjs
|
|
138
|
+
module.exports = require_id_match().create;
|
|
139
|
+
//#endregion
|
|
@@ -0,0 +1,76 @@
|
|
|
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/implicit-arrow-linebreak.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview enforce the location of arrow function bodies
|
|
5
|
+
* @author Sharmila Jesupaul
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_implicit_arrow_linebreak = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let { isCommentToken, isNotOpeningParenToken } = require_ast_utils$1.t();
|
|
10
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
meta: {
|
|
13
|
+
deprecated: {
|
|
14
|
+
message: "Formatting rules are being moved out of ESLint core.",
|
|
15
|
+
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
16
|
+
deprecatedSince: "8.53.0",
|
|
17
|
+
availableUntil: "11.0.0",
|
|
18
|
+
replacedBy: [{
|
|
19
|
+
message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
20
|
+
url: "https://eslint.style/guide/migration",
|
|
21
|
+
plugin: {
|
|
22
|
+
name: "@stylistic/eslint-plugin",
|
|
23
|
+
url: "https://eslint.style"
|
|
24
|
+
},
|
|
25
|
+
rule: {
|
|
26
|
+
name: "implicit-arrow-linebreak",
|
|
27
|
+
url: "https://eslint.style/rules/implicit-arrow-linebreak"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
type: "layout",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Enforce the location of arrow function bodies",
|
|
34
|
+
recommended: !1,
|
|
35
|
+
url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak"
|
|
36
|
+
},
|
|
37
|
+
fixable: "whitespace",
|
|
38
|
+
schema: [{ enum: ["beside", "below"] }],
|
|
39
|
+
messages: {
|
|
40
|
+
expected: "Expected a linebreak before this expression.",
|
|
41
|
+
unexpected: "Expected no linebreak before this expression."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
create(context) {
|
|
45
|
+
let sourceCode = context.sourceCode, option = context.options[0] || "beside";
|
|
46
|
+
/**
|
|
47
|
+
* Validates the location of an arrow function body
|
|
48
|
+
* @param {ASTNode} node The arrow function body
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
function validateExpression(node) {
|
|
52
|
+
if (node.body.type === "BlockStatement") return;
|
|
53
|
+
let arrowToken = sourceCode.getTokenBefore(node.body, isNotOpeningParenToken), firstTokenOfBody = sourceCode.getTokenAfter(arrowToken);
|
|
54
|
+
arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below" ? context.report({
|
|
55
|
+
node: firstTokenOfBody,
|
|
56
|
+
messageId: "expected",
|
|
57
|
+
fix: (fixer) => fixer.insertTextBefore(firstTokenOfBody, "\n")
|
|
58
|
+
}) : arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside" && context.report({
|
|
59
|
+
node: firstTokenOfBody,
|
|
60
|
+
messageId: "unexpected",
|
|
61
|
+
fix(fixer) {
|
|
62
|
+
return sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, {
|
|
63
|
+
includeComments: !0,
|
|
64
|
+
filter: isCommentToken
|
|
65
|
+
}) ? null : fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " ");
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return { ArrowFunctionExpression: (node) => validateExpression(node) };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}));
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src-js/generated/plugin-eslint/rules/implicit-arrow-linebreak.cjs
|
|
75
|
+
module.exports = require_implicit_arrow_linebreak().create;
|
|
76
|
+
//#endregion
|