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,274 @@
|
|
|
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/comma-dangle.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to forbid or enforce dangling commas.
|
|
5
|
+
* @author Ian Christian Myers
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_comma_dangle = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let astUtils = require_ast_utils$1.t(), DEFAULT_OPTIONS = Object.freeze({
|
|
10
|
+
arrays: "never",
|
|
11
|
+
objects: "never",
|
|
12
|
+
imports: "never",
|
|
13
|
+
exports: "never",
|
|
14
|
+
functions: "never"
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether or not a trailing comma is allowed in a given node.
|
|
18
|
+
* If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas.
|
|
19
|
+
* @param {ASTNode} lastItem The node of the last element in the given node.
|
|
20
|
+
* @returns {boolean} `true` if a trailing comma is allowed.
|
|
21
|
+
*/
|
|
22
|
+
function isTrailingCommaAllowed(lastItem) {
|
|
23
|
+
return !(lastItem.type === "RestElement" || lastItem.type === "RestProperty" || lastItem.type === "ExperimentalRestProperty");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Normalize option value.
|
|
27
|
+
* @param {string|Object|undefined} optionValue The 1st option value to normalize.
|
|
28
|
+
* @param {number} ecmaVersion The normalized ECMAScript version.
|
|
29
|
+
* @returns {Object} The normalized option value.
|
|
30
|
+
*/
|
|
31
|
+
function normalizeOptions(optionValue, ecmaVersion) {
|
|
32
|
+
return typeof optionValue == "string" ? {
|
|
33
|
+
arrays: optionValue,
|
|
34
|
+
objects: optionValue,
|
|
35
|
+
imports: optionValue,
|
|
36
|
+
exports: optionValue,
|
|
37
|
+
functions: ecmaVersion < 2017 ? "ignore" : optionValue
|
|
38
|
+
} : typeof optionValue == "object" && optionValue ? {
|
|
39
|
+
arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays,
|
|
40
|
+
objects: optionValue.objects || DEFAULT_OPTIONS.objects,
|
|
41
|
+
imports: optionValue.imports || DEFAULT_OPTIONS.imports,
|
|
42
|
+
exports: optionValue.exports || DEFAULT_OPTIONS.exports,
|
|
43
|
+
functions: optionValue.functions || DEFAULT_OPTIONS.functions
|
|
44
|
+
} : DEFAULT_OPTIONS;
|
|
45
|
+
}
|
|
46
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
47
|
+
module.exports = {
|
|
48
|
+
meta: {
|
|
49
|
+
deprecated: {
|
|
50
|
+
message: "Formatting rules are being moved out of ESLint core.",
|
|
51
|
+
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
52
|
+
deprecatedSince: "8.53.0",
|
|
53
|
+
availableUntil: "11.0.0",
|
|
54
|
+
replacedBy: [{
|
|
55
|
+
message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
56
|
+
url: "https://eslint.style/guide/migration",
|
|
57
|
+
plugin: {
|
|
58
|
+
name: "@stylistic/eslint-plugin",
|
|
59
|
+
url: "https://eslint.style"
|
|
60
|
+
},
|
|
61
|
+
rule: {
|
|
62
|
+
name: "comma-dangle",
|
|
63
|
+
url: "https://eslint.style/rules/comma-dangle"
|
|
64
|
+
}
|
|
65
|
+
}]
|
|
66
|
+
},
|
|
67
|
+
type: "layout",
|
|
68
|
+
docs: {
|
|
69
|
+
description: "Require or disallow trailing commas",
|
|
70
|
+
recommended: !1,
|
|
71
|
+
url: "https://eslint.org/docs/latest/rules/comma-dangle"
|
|
72
|
+
},
|
|
73
|
+
fixable: "code",
|
|
74
|
+
schema: {
|
|
75
|
+
definitions: {
|
|
76
|
+
value: { enum: [
|
|
77
|
+
"always-multiline",
|
|
78
|
+
"always",
|
|
79
|
+
"never",
|
|
80
|
+
"only-multiline"
|
|
81
|
+
] },
|
|
82
|
+
valueWithIgnore: { enum: [
|
|
83
|
+
"always-multiline",
|
|
84
|
+
"always",
|
|
85
|
+
"ignore",
|
|
86
|
+
"never",
|
|
87
|
+
"only-multiline"
|
|
88
|
+
] }
|
|
89
|
+
},
|
|
90
|
+
type: "array",
|
|
91
|
+
items: [{ oneOf: [{ $ref: "#/definitions/value" }, {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
arrays: { $ref: "#/definitions/valueWithIgnore" },
|
|
95
|
+
objects: { $ref: "#/definitions/valueWithIgnore" },
|
|
96
|
+
imports: { $ref: "#/definitions/valueWithIgnore" },
|
|
97
|
+
exports: { $ref: "#/definitions/valueWithIgnore" },
|
|
98
|
+
functions: { $ref: "#/definitions/valueWithIgnore" }
|
|
99
|
+
},
|
|
100
|
+
additionalProperties: !1
|
|
101
|
+
}] }],
|
|
102
|
+
additionalItems: !1
|
|
103
|
+
},
|
|
104
|
+
messages: {
|
|
105
|
+
unexpected: "Unexpected trailing comma.",
|
|
106
|
+
missing: "Missing trailing comma."
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
create(context) {
|
|
110
|
+
let options = normalizeOptions(context.options[0], context.languageOptions.ecmaVersion), sourceCode = context.sourceCode;
|
|
111
|
+
/**
|
|
112
|
+
* Gets the last item of the given node.
|
|
113
|
+
* @param {ASTNode} node The node to get.
|
|
114
|
+
* @returns {ASTNode|null} The last node or null.
|
|
115
|
+
*/
|
|
116
|
+
function getLastItem(node) {
|
|
117
|
+
/**
|
|
118
|
+
* Returns the last element of an array
|
|
119
|
+
* @param {any[]} array The input array
|
|
120
|
+
* @returns {any} The last element
|
|
121
|
+
*/
|
|
122
|
+
function last(array) {
|
|
123
|
+
return array.at(-1);
|
|
124
|
+
}
|
|
125
|
+
switch (node.type) {
|
|
126
|
+
case "ObjectExpression":
|
|
127
|
+
case "ObjectPattern": return last(node.properties);
|
|
128
|
+
case "ArrayExpression":
|
|
129
|
+
case "ArrayPattern": return last(node.elements);
|
|
130
|
+
case "ImportDeclaration":
|
|
131
|
+
case "ExportNamedDeclaration": return last(node.specifiers);
|
|
132
|
+
case "FunctionDeclaration":
|
|
133
|
+
case "FunctionExpression":
|
|
134
|
+
case "ArrowFunctionExpression": return last(node.params);
|
|
135
|
+
case "CallExpression":
|
|
136
|
+
case "NewExpression": return last(node.arguments);
|
|
137
|
+
default: return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets the trailing comma token of the given node.
|
|
142
|
+
* If the trailing comma does not exist, this returns the token which is
|
|
143
|
+
* the insertion point of the trailing comma token.
|
|
144
|
+
* @param {ASTNode} node The node to get.
|
|
145
|
+
* @param {ASTNode} lastItem The last item of the node.
|
|
146
|
+
* @returns {Token} The trailing comma token or the insertion point.
|
|
147
|
+
*/
|
|
148
|
+
function getTrailingToken(node, lastItem) {
|
|
149
|
+
switch (node.type) {
|
|
150
|
+
case "ObjectExpression":
|
|
151
|
+
case "ArrayExpression":
|
|
152
|
+
case "CallExpression":
|
|
153
|
+
case "NewExpression": return sourceCode.getLastToken(node, 1);
|
|
154
|
+
default: {
|
|
155
|
+
let nextToken = sourceCode.getTokenAfter(lastItem);
|
|
156
|
+
return astUtils.isCommaToken(nextToken) ? nextToken : sourceCode.getLastToken(lastItem);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Checks whether or not a given node is multiline.
|
|
162
|
+
* This rule handles a given node as multiline when the closing parenthesis
|
|
163
|
+
* and the last element are not on the same line.
|
|
164
|
+
* @param {ASTNode} node A node to check.
|
|
165
|
+
* @returns {boolean} `true` if the node is multiline.
|
|
166
|
+
*/
|
|
167
|
+
function isMultiline(node) {
|
|
168
|
+
let lastItem = getLastItem(node);
|
|
169
|
+
if (!lastItem) return !1;
|
|
170
|
+
let penultimateToken = getTrailingToken(node, lastItem);
|
|
171
|
+
return sourceCode.getTokenAfter(penultimateToken).loc.end.line !== penultimateToken.loc.end.line;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Reports a trailing comma if it exists.
|
|
175
|
+
* @param {ASTNode} node A node to check. Its type is one of
|
|
176
|
+
* ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
|
|
177
|
+
* ImportDeclaration, and ExportNamedDeclaration.
|
|
178
|
+
* @returns {void}
|
|
179
|
+
*/
|
|
180
|
+
function forbidTrailingComma(node) {
|
|
181
|
+
let lastItem = getLastItem(node);
|
|
182
|
+
if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") return;
|
|
183
|
+
let trailingToken = getTrailingToken(node, lastItem);
|
|
184
|
+
astUtils.isCommaToken(trailingToken) && context.report({
|
|
185
|
+
node: lastItem,
|
|
186
|
+
loc: trailingToken.loc,
|
|
187
|
+
messageId: "unexpected",
|
|
188
|
+
*fix(fixer) {
|
|
189
|
+
yield fixer.remove(trailingToken), yield fixer.insertTextBefore(sourceCode.getTokenBefore(trailingToken), ""), yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), "");
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Reports the last element of a given node if it does not have a trailing
|
|
195
|
+
* comma.
|
|
196
|
+
*
|
|
197
|
+
* If a given node is `ArrayPattern` which has `RestElement`, the trailing
|
|
198
|
+
* comma is disallowed, so report if it exists.
|
|
199
|
+
* @param {ASTNode} node A node to check. Its type is one of
|
|
200
|
+
* ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
|
|
201
|
+
* ImportDeclaration, and ExportNamedDeclaration.
|
|
202
|
+
* @returns {void}
|
|
203
|
+
*/
|
|
204
|
+
function forceTrailingComma(node) {
|
|
205
|
+
let lastItem = getLastItem(node);
|
|
206
|
+
if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") return;
|
|
207
|
+
if (!isTrailingCommaAllowed(lastItem)) {
|
|
208
|
+
forbidTrailingComma(node);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
let trailingToken = getTrailingToken(node, lastItem);
|
|
212
|
+
trailingToken.value !== "," && context.report({
|
|
213
|
+
node: lastItem,
|
|
214
|
+
loc: {
|
|
215
|
+
start: trailingToken.loc.end,
|
|
216
|
+
end: astUtils.getNextLocation(sourceCode, trailingToken.loc.end)
|
|
217
|
+
},
|
|
218
|
+
messageId: "missing",
|
|
219
|
+
*fix(fixer) {
|
|
220
|
+
yield fixer.insertTextAfter(trailingToken, ","), yield fixer.insertTextBefore(trailingToken, ""), yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), "");
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* If a given node is multiline, reports the last element of a given node
|
|
226
|
+
* when it does not have a trailing comma.
|
|
227
|
+
* Otherwise, reports a trailing comma if it exists.
|
|
228
|
+
* @param {ASTNode} node A node to check. Its type is one of
|
|
229
|
+
* ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
|
|
230
|
+
* ImportDeclaration, and ExportNamedDeclaration.
|
|
231
|
+
* @returns {void}
|
|
232
|
+
*/
|
|
233
|
+
function forceTrailingCommaIfMultiline(node) {
|
|
234
|
+
isMultiline(node) ? forceTrailingComma(node) : forbidTrailingComma(node);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Only if a given node is not multiline, reports the last element of a given node
|
|
238
|
+
* when it does not have a trailing comma.
|
|
239
|
+
* Otherwise, reports a trailing comma if it exists.
|
|
240
|
+
* @param {ASTNode} node A node to check. Its type is one of
|
|
241
|
+
* ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
|
|
242
|
+
* ImportDeclaration, and ExportNamedDeclaration.
|
|
243
|
+
* @returns {void}
|
|
244
|
+
*/
|
|
245
|
+
function allowTrailingCommaIfMultiline(node) {
|
|
246
|
+
isMultiline(node) || forbidTrailingComma(node);
|
|
247
|
+
}
|
|
248
|
+
let predicate = {
|
|
249
|
+
always: forceTrailingComma,
|
|
250
|
+
"always-multiline": forceTrailingCommaIfMultiline,
|
|
251
|
+
"only-multiline": allowTrailingCommaIfMultiline,
|
|
252
|
+
never: forbidTrailingComma,
|
|
253
|
+
ignore() {}
|
|
254
|
+
};
|
|
255
|
+
return {
|
|
256
|
+
ObjectExpression: predicate[options.objects],
|
|
257
|
+
ObjectPattern: predicate[options.objects],
|
|
258
|
+
ArrayExpression: predicate[options.arrays],
|
|
259
|
+
ArrayPattern: predicate[options.arrays],
|
|
260
|
+
ImportDeclaration: predicate[options.imports],
|
|
261
|
+
ExportNamedDeclaration: predicate[options.exports],
|
|
262
|
+
FunctionDeclaration: predicate[options.functions],
|
|
263
|
+
FunctionExpression: predicate[options.functions],
|
|
264
|
+
ArrowFunctionExpression: predicate[options.functions],
|
|
265
|
+
CallExpression: predicate[options.functions],
|
|
266
|
+
NewExpression: predicate[options.functions]
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}));
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src-js/generated/plugin-eslint/rules/comma-dangle.cjs
|
|
273
|
+
module.exports = require_comma_dangle().create;
|
|
274
|
+
//#endregion
|
|
@@ -0,0 +1,111 @@
|
|
|
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/comma-spacing.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Comma spacing - validates spacing before and after comma
|
|
5
|
+
* @author Vignesh Anand aka vegetableman.
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_comma_spacing = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let astUtils = 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: "comma-spacing",
|
|
27
|
+
url: "https://eslint.style/rules/comma-spacing"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
type: "layout",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Enforce consistent spacing before and after commas",
|
|
34
|
+
recommended: !1,
|
|
35
|
+
url: "https://eslint.org/docs/latest/rules/comma-spacing"
|
|
36
|
+
},
|
|
37
|
+
fixable: "whitespace",
|
|
38
|
+
schema: [{
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
before: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
default: !1
|
|
44
|
+
},
|
|
45
|
+
after: {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
default: !0
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
additionalProperties: !1
|
|
51
|
+
}],
|
|
52
|
+
messages: {
|
|
53
|
+
missing: "A space is required {{loc}} ','.",
|
|
54
|
+
unexpected: "There should be no space {{loc}} ','."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
create(context) {
|
|
58
|
+
let sourceCode = context.sourceCode, tokensAndComments = sourceCode.tokensAndComments, options = {
|
|
59
|
+
before: context.options[0] ? context.options[0].before : !1,
|
|
60
|
+
after: context.options[0] ? context.options[0].after : !0
|
|
61
|
+
}, commaTokensToIgnore = [];
|
|
62
|
+
/**
|
|
63
|
+
* Reports a spacing error with an appropriate message.
|
|
64
|
+
* @param {ASTNode} node The binary expression node to report.
|
|
65
|
+
* @param {string} loc Is the error "before" or "after" the comma?
|
|
66
|
+
* @param {ASTNode} otherNode The node at the left or right of `node`
|
|
67
|
+
* @returns {void}
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
function report(node, loc, otherNode) {
|
|
71
|
+
context.report({
|
|
72
|
+
node,
|
|
73
|
+
fix(fixer) {
|
|
74
|
+
if (options[loc]) return loc === "before" ? fixer.insertTextBefore(node, " ") : fixer.insertTextAfter(node, " ");
|
|
75
|
+
let start, end;
|
|
76
|
+
return loc === "before" ? (start = otherNode.range[1], end = node.range[0]) : (start = node.range[1], end = otherNode.range[0]), fixer.replaceTextRange([start, end], "");
|
|
77
|
+
},
|
|
78
|
+
messageId: options[loc] ? "missing" : "unexpected",
|
|
79
|
+
data: { loc }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
|
|
84
|
+
* @param {ASTNode} node An ArrayExpression or ArrayPattern node.
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
function addNullElementsToIgnoreList(node) {
|
|
88
|
+
let previousToken = sourceCode.getFirstToken(node);
|
|
89
|
+
node.elements.forEach((element) => {
|
|
90
|
+
let token;
|
|
91
|
+
element === null ? (token = sourceCode.getTokenAfter(previousToken), astUtils.isCommaToken(token) && commaTokensToIgnore.push(token)) : token = sourceCode.getTokenAfter(element), previousToken = token;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
"Program:exit"() {
|
|
96
|
+
tokensAndComments.forEach((token, i) => {
|
|
97
|
+
if (!astUtils.isCommaToken(token)) return;
|
|
98
|
+
let previousToken = tokensAndComments[i - 1], nextToken = tokensAndComments[i + 1];
|
|
99
|
+
previousToken && !astUtils.isCommaToken(previousToken) && !commaTokensToIgnore.includes(token) && astUtils.isTokenOnSameLine(previousToken, token) && options.before !== sourceCode.isSpaceBetweenTokens(previousToken, token) && report(token, "before", previousToken), nextToken && !astUtils.isCommaToken(nextToken) && !astUtils.isClosingParenToken(nextToken) && !astUtils.isClosingBracketToken(nextToken) && !astUtils.isClosingBraceToken(nextToken) && !(!options.after && nextToken.type === "Line") && astUtils.isTokenOnSameLine(token, nextToken) && options.after !== sourceCode.isSpaceBetweenTokens(token, nextToken) && report(token, "after", nextToken);
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
ArrayExpression: addNullElementsToIgnoreList,
|
|
103
|
+
ArrayPattern: addNullElementsToIgnoreList
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}));
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src-js/generated/plugin-eslint/rules/comma-spacing.cjs
|
|
110
|
+
module.exports = require_comma_spacing().create;
|
|
111
|
+
//#endregion
|
|
@@ -0,0 +1,180 @@
|
|
|
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/comma-style.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Comma style - enforces comma styles of two types: last and first
|
|
5
|
+
* @author Vignesh Anand aka vegetableman
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_comma_style = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let astUtils = 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: "comma-style",
|
|
27
|
+
url: "https://eslint.style/rules/comma-style"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
type: "layout",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Enforce consistent comma style",
|
|
34
|
+
recommended: !1,
|
|
35
|
+
url: "https://eslint.org/docs/latest/rules/comma-style"
|
|
36
|
+
},
|
|
37
|
+
fixable: "code",
|
|
38
|
+
schema: [{ enum: ["first", "last"] }, {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: { exceptions: {
|
|
41
|
+
type: "object",
|
|
42
|
+
additionalProperties: { type: "boolean" }
|
|
43
|
+
} },
|
|
44
|
+
additionalProperties: !1
|
|
45
|
+
}],
|
|
46
|
+
messages: {
|
|
47
|
+
unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.",
|
|
48
|
+
expectedCommaFirst: "',' should be placed first.",
|
|
49
|
+
expectedCommaLast: "',' should be placed last."
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
create(context) {
|
|
53
|
+
let style = context.options[0] || "last", sourceCode = context.sourceCode, exceptions = {
|
|
54
|
+
ArrayPattern: !0,
|
|
55
|
+
ArrowFunctionExpression: !0,
|
|
56
|
+
CallExpression: !0,
|
|
57
|
+
FunctionDeclaration: !0,
|
|
58
|
+
FunctionExpression: !0,
|
|
59
|
+
ImportDeclaration: !0,
|
|
60
|
+
ObjectPattern: !0,
|
|
61
|
+
NewExpression: !0
|
|
62
|
+
};
|
|
63
|
+
if (context.options.length === 2 && Object.hasOwn(context.options[1], "exceptions")) {
|
|
64
|
+
let keys = Object.keys(context.options[1].exceptions);
|
|
65
|
+
for (let i = 0; i < keys.length; i++) exceptions[keys[i]] = context.options[1].exceptions[keys[i]];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Modified text based on the style
|
|
69
|
+
* @param {string} styleType Style type
|
|
70
|
+
* @param {string} text Source code text
|
|
71
|
+
* @returns {string} modified text
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
function getReplacedText(styleType, text) {
|
|
75
|
+
switch (styleType) {
|
|
76
|
+
case "between": return `,${text.replace(astUtils.LINEBREAK_MATCHER, "")}`;
|
|
77
|
+
case "first": return `${text},`;
|
|
78
|
+
case "last": return `,${text}`;
|
|
79
|
+
default: return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Determines the fixer function for a given style.
|
|
84
|
+
* @param {string} styleType comma style
|
|
85
|
+
* @param {ASTNode} previousItemToken The token to check.
|
|
86
|
+
* @param {ASTNode} commaToken The token to check.
|
|
87
|
+
* @param {ASTNode} currentItemToken The token to check.
|
|
88
|
+
* @returns {Function} Fixer function
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
|
|
92
|
+
let text = sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]), range = [previousItemToken.range[1], currentItemToken.range[0]];
|
|
93
|
+
return function(fixer) {
|
|
94
|
+
return fixer.replaceTextRange(range, getReplacedText(styleType, text));
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Validates the spacing around single items in lists.
|
|
99
|
+
* @param {Token} previousItemToken The last token from the previous item.
|
|
100
|
+
* @param {Token} commaToken The token representing the comma.
|
|
101
|
+
* @param {Token} currentItemToken The first token of the current item.
|
|
102
|
+
* @param {Token} reportItem The item to use when reporting an error.
|
|
103
|
+
* @returns {void}
|
|
104
|
+
* @private
|
|
105
|
+
*/
|
|
106
|
+
function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
|
|
107
|
+
if (!(astUtils.isTokenOnSameLine(commaToken, currentItemToken) && astUtils.isTokenOnSameLine(previousItemToken, commaToken))) if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
|
|
108
|
+
let comment = sourceCode.getCommentsAfter(commaToken)[0], styleType = comment && comment.type === "Block" && astUtils.isTokenOnSameLine(commaToken, comment) ? style : "between";
|
|
109
|
+
context.report({
|
|
110
|
+
node: reportItem,
|
|
111
|
+
loc: commaToken.loc,
|
|
112
|
+
messageId: "unexpectedLineBeforeAndAfterComma",
|
|
113
|
+
fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken)
|
|
114
|
+
});
|
|
115
|
+
} else style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken) ? context.report({
|
|
116
|
+
node: reportItem,
|
|
117
|
+
loc: commaToken.loc,
|
|
118
|
+
messageId: "expectedCommaFirst",
|
|
119
|
+
fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
|
|
120
|
+
}) : style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken) && context.report({
|
|
121
|
+
node: reportItem,
|
|
122
|
+
loc: commaToken.loc,
|
|
123
|
+
messageId: "expectedCommaLast",
|
|
124
|
+
fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Checks the comma placement with regards to a declaration/property/element
|
|
129
|
+
* @param {ASTNode} node The binary expression node to check
|
|
130
|
+
* @param {string} property The property of the node containing child nodes.
|
|
131
|
+
* @private
|
|
132
|
+
* @returns {void}
|
|
133
|
+
*/
|
|
134
|
+
function validateComma(node, property) {
|
|
135
|
+
let items = node[property], arrayLiteral = node.type === "ArrayExpression" || node.type === "ArrayPattern";
|
|
136
|
+
if (items.length > 1 || arrayLiteral) {
|
|
137
|
+
let previousItemToken = sourceCode.getFirstToken(node);
|
|
138
|
+
if (items.forEach((item) => {
|
|
139
|
+
let commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken, currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken), reportItem = item || currentItemToken;
|
|
140
|
+
if (astUtils.isCommaToken(commaToken) && validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem), item) {
|
|
141
|
+
let tokenAfterItem = sourceCode.getTokenAfter(item, astUtils.isNotClosingParenToken);
|
|
142
|
+
previousItemToken = tokenAfterItem ? sourceCode.getTokenBefore(tokenAfterItem) : sourceCode.ast.tokens.at(-1);
|
|
143
|
+
} else previousItemToken = currentItemToken;
|
|
144
|
+
}), arrayLiteral) {
|
|
145
|
+
let lastToken = sourceCode.getLastToken(node), nextToLastToken = sourceCode.getTokenBefore(lastToken);
|
|
146
|
+
astUtils.isCommaToken(nextToLastToken) && validateCommaItemSpacing(sourceCode.getTokenBefore(nextToLastToken), nextToLastToken, lastToken, lastToken);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
let nodes = {};
|
|
151
|
+
return exceptions.VariableDeclaration || (nodes.VariableDeclaration = function(node) {
|
|
152
|
+
validateComma(node, "declarations");
|
|
153
|
+
}), exceptions.ObjectExpression || (nodes.ObjectExpression = function(node) {
|
|
154
|
+
validateComma(node, "properties");
|
|
155
|
+
}), exceptions.ObjectPattern || (nodes.ObjectPattern = function(node) {
|
|
156
|
+
validateComma(node, "properties");
|
|
157
|
+
}), exceptions.ArrayExpression || (nodes.ArrayExpression = function(node) {
|
|
158
|
+
validateComma(node, "elements");
|
|
159
|
+
}), exceptions.ArrayPattern || (nodes.ArrayPattern = function(node) {
|
|
160
|
+
validateComma(node, "elements");
|
|
161
|
+
}), exceptions.FunctionDeclaration || (nodes.FunctionDeclaration = function(node) {
|
|
162
|
+
validateComma(node, "params");
|
|
163
|
+
}), exceptions.FunctionExpression || (nodes.FunctionExpression = function(node) {
|
|
164
|
+
validateComma(node, "params");
|
|
165
|
+
}), exceptions.ArrowFunctionExpression || (nodes.ArrowFunctionExpression = function(node) {
|
|
166
|
+
validateComma(node, "params");
|
|
167
|
+
}), exceptions.CallExpression || (nodes.CallExpression = function(node) {
|
|
168
|
+
validateComma(node, "arguments");
|
|
169
|
+
}), exceptions.ImportDeclaration || (nodes.ImportDeclaration = function(node) {
|
|
170
|
+
validateComma(node, "specifiers");
|
|
171
|
+
}), exceptions.NewExpression || (nodes.NewExpression = function(node) {
|
|
172
|
+
validateComma(node, "arguments");
|
|
173
|
+
}), nodes;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}));
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src-js/generated/plugin-eslint/rules/comma-style.cjs
|
|
179
|
+
module.exports = require_comma_style().create;
|
|
180
|
+
//#endregion
|
|
@@ -0,0 +1,100 @@
|
|
|
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/complexity.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity.
|
|
5
|
+
* Counts the number of if, conditional, for, while, try, switch/case,
|
|
6
|
+
* @author Patrick Brosset
|
|
7
|
+
*/
|
|
8
|
+
var require_complexity = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
9
|
+
let astUtils = require_ast_utils$1.t(), { upperCaseFirst } = require_string_utils$1.t();
|
|
10
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
11
|
+
module.exports = {
|
|
12
|
+
meta: {
|
|
13
|
+
type: "suggestion",
|
|
14
|
+
defaultOptions: [20],
|
|
15
|
+
docs: {
|
|
16
|
+
description: "Enforce a maximum cyclomatic complexity allowed in a program",
|
|
17
|
+
recommended: !1,
|
|
18
|
+
url: "https://eslint.org/docs/latest/rules/complexity"
|
|
19
|
+
},
|
|
20
|
+
schema: [{ oneOf: [{
|
|
21
|
+
type: "integer",
|
|
22
|
+
minimum: 0
|
|
23
|
+
}, {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
maximum: {
|
|
27
|
+
type: "integer",
|
|
28
|
+
minimum: 0
|
|
29
|
+
},
|
|
30
|
+
max: {
|
|
31
|
+
type: "integer",
|
|
32
|
+
minimum: 0
|
|
33
|
+
},
|
|
34
|
+
variant: { enum: ["classic", "modified"] }
|
|
35
|
+
},
|
|
36
|
+
additionalProperties: !1
|
|
37
|
+
}] }],
|
|
38
|
+
messages: { complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}." }
|
|
39
|
+
},
|
|
40
|
+
create(context) {
|
|
41
|
+
let sourceCode = context.sourceCode, option = context.options[0], threshold = 20, VARIANT = "classic";
|
|
42
|
+
typeof option == "object" ? ((Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) && (threshold = option.maximum || option.max), Object.hasOwn(option, "variant") && (VARIANT = option.variant)) : typeof option == "number" && (threshold = option);
|
|
43
|
+
let IS_MODIFIED_COMPLEXITY = VARIANT === "modified", complexities = [];
|
|
44
|
+
/**
|
|
45
|
+
* Increase the complexity of the code path in context
|
|
46
|
+
* @returns {void}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
function increaseComplexity() {
|
|
50
|
+
complexities[complexities.length - 1]++;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
onCodePathStart() {
|
|
54
|
+
complexities.push(1);
|
|
55
|
+
},
|
|
56
|
+
CatchClause: increaseComplexity,
|
|
57
|
+
ConditionalExpression: increaseComplexity,
|
|
58
|
+
LogicalExpression: increaseComplexity,
|
|
59
|
+
ForStatement: increaseComplexity,
|
|
60
|
+
ForInStatement: increaseComplexity,
|
|
61
|
+
ForOfStatement: increaseComplexity,
|
|
62
|
+
IfStatement: increaseComplexity,
|
|
63
|
+
WhileStatement: increaseComplexity,
|
|
64
|
+
DoWhileStatement: increaseComplexity,
|
|
65
|
+
AssignmentPattern: increaseComplexity,
|
|
66
|
+
"SwitchCase[test]": () => IS_MODIFIED_COMPLEXITY || increaseComplexity(),
|
|
67
|
+
SwitchStatement: () => IS_MODIFIED_COMPLEXITY && increaseComplexity(),
|
|
68
|
+
AssignmentExpression(node) {
|
|
69
|
+
astUtils.isLogicalAssignmentOperator(node.operator) && increaseComplexity();
|
|
70
|
+
},
|
|
71
|
+
MemberExpression(node) {
|
|
72
|
+
node.optional === !0 && increaseComplexity();
|
|
73
|
+
},
|
|
74
|
+
CallExpression(node) {
|
|
75
|
+
node.optional === !0 && increaseComplexity();
|
|
76
|
+
},
|
|
77
|
+
onCodePathEnd(codePath, node) {
|
|
78
|
+
let complexity = complexities.pop();
|
|
79
|
+
if (!(codePath.origin !== "function" && codePath.origin !== "class-field-initializer" && codePath.origin !== "class-static-block") && complexity > threshold) {
|
|
80
|
+
let name, loc = node.loc;
|
|
81
|
+
codePath.origin === "class-field-initializer" ? name = "class field initializer" : codePath.origin === "class-static-block" ? (name = "class static block", loc = sourceCode.getFirstToken(node).loc) : (name = astUtils.getFunctionNameWithKind(node), loc = astUtils.getFunctionHeadLoc(node, sourceCode)), context.report({
|
|
82
|
+
node,
|
|
83
|
+
loc,
|
|
84
|
+
messageId: "complex",
|
|
85
|
+
data: {
|
|
86
|
+
name: upperCaseFirst(name),
|
|
87
|
+
complexity,
|
|
88
|
+
max: threshold
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}));
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src-js/generated/plugin-eslint/rules/complexity.cjs
|
|
99
|
+
module.exports = require_complexity().create;
|
|
100
|
+
//#endregion
|