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,225 @@
|
|
|
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/object-curly-spacing.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Disallows or enforces spaces inside of object literals.
|
|
5
|
+
* @author Jamund Ferguson
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_object_curly_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: "object-curly-spacing",
|
|
27
|
+
url: "https://eslint.style/rules/object-curly-spacing"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
type: "layout",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Enforce consistent spacing inside braces",
|
|
34
|
+
recommended: !1,
|
|
35
|
+
url: "https://eslint.org/docs/latest/rules/object-curly-spacing"
|
|
36
|
+
},
|
|
37
|
+
fixable: "whitespace",
|
|
38
|
+
schema: [{ enum: ["always", "never"] }, {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
arraysInObjects: { type: "boolean" },
|
|
42
|
+
objectsInObjects: { type: "boolean" }
|
|
43
|
+
},
|
|
44
|
+
additionalProperties: !1
|
|
45
|
+
}],
|
|
46
|
+
messages: {
|
|
47
|
+
requireSpaceBefore: "A space is required before '{{token}}'.",
|
|
48
|
+
requireSpaceAfter: "A space is required after '{{token}}'.",
|
|
49
|
+
unexpectedSpaceBefore: "There should be no space before '{{token}}'.",
|
|
50
|
+
unexpectedSpaceAfter: "There should be no space after '{{token}}'."
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
create(context) {
|
|
54
|
+
let spaced = context.options[0] === "always", sourceCode = context.sourceCode;
|
|
55
|
+
/**
|
|
56
|
+
* Determines whether an option is set, relative to the spacing option.
|
|
57
|
+
* If spaced is "always", then check whether option is set to false.
|
|
58
|
+
* If spaced is "never", then check whether option is set to true.
|
|
59
|
+
* @param {Object} option The option to exclude.
|
|
60
|
+
* @returns {boolean} Whether or not the property is excluded.
|
|
61
|
+
*/
|
|
62
|
+
function isOptionSet(option) {
|
|
63
|
+
return context.options[1] ? context.options[1][option] === !spaced : !1;
|
|
64
|
+
}
|
|
65
|
+
let options = {
|
|
66
|
+
spaced,
|
|
67
|
+
arraysInObjectsException: isOptionSet("arraysInObjects"),
|
|
68
|
+
objectsInObjectsException: isOptionSet("objectsInObjects")
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Reports that there shouldn't be a space after the first token
|
|
72
|
+
* @param {ASTNode} node The node to report in the event of an error.
|
|
73
|
+
* @param {Token} token The token to use for the report.
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
function reportNoBeginningSpace(node, token) {
|
|
77
|
+
let nextToken = context.sourceCode.getTokenAfter(token, { includeComments: !0 });
|
|
78
|
+
context.report({
|
|
79
|
+
node,
|
|
80
|
+
loc: {
|
|
81
|
+
start: token.loc.end,
|
|
82
|
+
end: nextToken.loc.start
|
|
83
|
+
},
|
|
84
|
+
messageId: "unexpectedSpaceAfter",
|
|
85
|
+
data: { token: token.value },
|
|
86
|
+
fix(fixer) {
|
|
87
|
+
return fixer.removeRange([token.range[1], nextToken.range[0]]);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reports that there shouldn't be a space before the last token
|
|
93
|
+
* @param {ASTNode} node The node to report in the event of an error.
|
|
94
|
+
* @param {Token} token The token to use for the report.
|
|
95
|
+
* @returns {void}
|
|
96
|
+
*/
|
|
97
|
+
function reportNoEndingSpace(node, token) {
|
|
98
|
+
let previousToken = context.sourceCode.getTokenBefore(token, { includeComments: !0 });
|
|
99
|
+
context.report({
|
|
100
|
+
node,
|
|
101
|
+
loc: {
|
|
102
|
+
start: previousToken.loc.end,
|
|
103
|
+
end: token.loc.start
|
|
104
|
+
},
|
|
105
|
+
messageId: "unexpectedSpaceBefore",
|
|
106
|
+
data: { token: token.value },
|
|
107
|
+
fix(fixer) {
|
|
108
|
+
return fixer.removeRange([previousToken.range[1], token.range[0]]);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Reports that there should be a space after the first token
|
|
114
|
+
* @param {ASTNode} node The node to report in the event of an error.
|
|
115
|
+
* @param {Token} token The token to use for the report.
|
|
116
|
+
* @returns {void}
|
|
117
|
+
*/
|
|
118
|
+
function reportRequiredBeginningSpace(node, token) {
|
|
119
|
+
context.report({
|
|
120
|
+
node,
|
|
121
|
+
loc: token.loc,
|
|
122
|
+
messageId: "requireSpaceAfter",
|
|
123
|
+
data: { token: token.value },
|
|
124
|
+
fix(fixer) {
|
|
125
|
+
return fixer.insertTextAfter(token, " ");
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Reports that there should be a space before the last token
|
|
131
|
+
* @param {ASTNode} node The node to report in the event of an error.
|
|
132
|
+
* @param {Token} token The token to use for the report.
|
|
133
|
+
* @returns {void}
|
|
134
|
+
*/
|
|
135
|
+
function reportRequiredEndingSpace(node, token) {
|
|
136
|
+
context.report({
|
|
137
|
+
node,
|
|
138
|
+
loc: token.loc,
|
|
139
|
+
messageId: "requireSpaceBefore",
|
|
140
|
+
data: { token: token.value },
|
|
141
|
+
fix(fixer) {
|
|
142
|
+
return fixer.insertTextBefore(token, " ");
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Determines if spacing in curly braces is valid.
|
|
148
|
+
* @param {ASTNode} node The AST node to check.
|
|
149
|
+
* @param {Token} first The first token to check (should be the opening brace)
|
|
150
|
+
* @param {Token} second The second token to check (should be first after the opening brace)
|
|
151
|
+
* @param {Token} penultimate The penultimate token to check (should be last before closing brace)
|
|
152
|
+
* @param {Token} last The last token to check (should be closing brace)
|
|
153
|
+
* @returns {void}
|
|
154
|
+
*/
|
|
155
|
+
function validateBraceSpacing(node, first, second, penultimate, last) {
|
|
156
|
+
if (astUtils.isTokenOnSameLine(first, second)) {
|
|
157
|
+
let firstSpaced = sourceCode.isSpaceBetweenTokens(first, second);
|
|
158
|
+
options.spaced && !firstSpaced && reportRequiredBeginningSpace(node, first), !options.spaced && firstSpaced && second.type !== "Line" && reportNoBeginningSpace(node, first);
|
|
159
|
+
}
|
|
160
|
+
if (astUtils.isTokenOnSameLine(penultimate, last)) {
|
|
161
|
+
let penultimateType = (options.arraysInObjectsException && astUtils.isClosingBracketToken(penultimate) || options.objectsInObjectsException && astUtils.isClosingBraceToken(penultimate)) && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type, closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced, lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last);
|
|
162
|
+
closingCurlyBraceMustBeSpaced && !lastSpaced && reportRequiredEndingSpace(node, last), !closingCurlyBraceMustBeSpaced && lastSpaced && reportNoEndingSpace(node, last);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Gets '}' token of an object node.
|
|
167
|
+
*
|
|
168
|
+
* Because the last token of object patterns might be a type annotation,
|
|
169
|
+
* this traverses tokens preceded by the last property, then returns the
|
|
170
|
+
* first '}' token.
|
|
171
|
+
* @param {ASTNode} node The node to get. This node is an
|
|
172
|
+
* ObjectExpression or an ObjectPattern. And this node has one or
|
|
173
|
+
* more properties.
|
|
174
|
+
* @returns {Token} '}' token.
|
|
175
|
+
*/
|
|
176
|
+
function getClosingBraceOfObject(node) {
|
|
177
|
+
let lastProperty = node.properties.at(-1);
|
|
178
|
+
return sourceCode.getTokenAfter(lastProperty, astUtils.isClosingBraceToken);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reports a given object node if spacing in curly braces is invalid.
|
|
182
|
+
* @param {ASTNode} node An ObjectExpression or ObjectPattern node to check.
|
|
183
|
+
* @returns {void}
|
|
184
|
+
*/
|
|
185
|
+
function checkForObject(node) {
|
|
186
|
+
if (node.properties.length === 0) return;
|
|
187
|
+
let first = sourceCode.getFirstToken(node), last = getClosingBraceOfObject(node);
|
|
188
|
+
validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: !0 }), sourceCode.getTokenBefore(last, { includeComments: !0 }), last);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Reports a given import node if spacing in curly braces is invalid.
|
|
192
|
+
* @param {ASTNode} node An ImportDeclaration node to check.
|
|
193
|
+
* @returns {void}
|
|
194
|
+
*/
|
|
195
|
+
function checkForImport(node) {
|
|
196
|
+
if (node.specifiers.length === 0) return;
|
|
197
|
+
let firstSpecifier = node.specifiers[0], lastSpecifier = node.specifiers.at(-1);
|
|
198
|
+
if (lastSpecifier.type !== "ImportSpecifier") return;
|
|
199
|
+
firstSpecifier.type !== "ImportSpecifier" && (firstSpecifier = node.specifiers[1]);
|
|
200
|
+
let first = sourceCode.getTokenBefore(firstSpecifier), last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken);
|
|
201
|
+
validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: !0 }), sourceCode.getTokenBefore(last, { includeComments: !0 }), last);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Reports a given export node if spacing in curly braces is invalid.
|
|
205
|
+
* @param {ASTNode} node An ExportNamedDeclaration node to check.
|
|
206
|
+
* @returns {void}
|
|
207
|
+
*/
|
|
208
|
+
function checkForExport(node) {
|
|
209
|
+
if (node.specifiers.length === 0) return;
|
|
210
|
+
let firstSpecifier = node.specifiers[0], lastSpecifier = node.specifiers.at(-1), first = sourceCode.getTokenBefore(firstSpecifier), last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken);
|
|
211
|
+
validateBraceSpacing(node, first, sourceCode.getTokenAfter(first, { includeComments: !0 }), sourceCode.getTokenBefore(last, { includeComments: !0 }), last);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
ObjectPattern: checkForObject,
|
|
215
|
+
ObjectExpression: checkForObject,
|
|
216
|
+
ImportDeclaration: checkForImport,
|
|
217
|
+
ExportNamedDeclaration: checkForExport
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}));
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src-js/generated/plugin-eslint/rules/object-curly-spacing.cjs
|
|
224
|
+
module.exports = require_object_curly_spacing().create;
|
|
225
|
+
//#endregion
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/object-property-newline.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to enforce placing object properties on separate lines.
|
|
4
|
+
* @author Vitor Balocco
|
|
5
|
+
* @deprecated in ESLint v8.53.0
|
|
6
|
+
*/
|
|
7
|
+
var require_object_property_newline = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
deprecated: {
|
|
12
|
+
message: "Formatting rules are being moved out of ESLint core.",
|
|
13
|
+
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
14
|
+
deprecatedSince: "8.53.0",
|
|
15
|
+
availableUntil: "11.0.0",
|
|
16
|
+
replacedBy: [{
|
|
17
|
+
message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
18
|
+
url: "https://eslint.style/guide/migration",
|
|
19
|
+
plugin: {
|
|
20
|
+
name: "@stylistic/eslint-plugin",
|
|
21
|
+
url: "https://eslint.style"
|
|
22
|
+
},
|
|
23
|
+
rule: {
|
|
24
|
+
name: "object-property-newline",
|
|
25
|
+
url: "https://eslint.style/rules/object-property-newline"
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
},
|
|
29
|
+
type: "layout",
|
|
30
|
+
docs: {
|
|
31
|
+
description: "Enforce placing object properties on separate lines",
|
|
32
|
+
recommended: !1,
|
|
33
|
+
url: "https://eslint.org/docs/latest/rules/object-property-newline"
|
|
34
|
+
},
|
|
35
|
+
schema: [{
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
allowAllPropertiesOnSameLine: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
default: !1
|
|
41
|
+
},
|
|
42
|
+
allowMultiplePropertiesPerLine: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
default: !1
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
additionalProperties: !1
|
|
48
|
+
}],
|
|
49
|
+
fixable: "whitespace",
|
|
50
|
+
messages: {
|
|
51
|
+
propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.",
|
|
52
|
+
propertiesOnNewline: "Object properties must go on a new line."
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
create(context) {
|
|
56
|
+
let allowSameLine = context.options[0] && (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine), messageId = allowSameLine ? "propertiesOnNewlineAll" : "propertiesOnNewline", sourceCode = context.sourceCode;
|
|
57
|
+
return { ObjectExpression(node) {
|
|
58
|
+
if (allowSameLine && node.properties.length > 1) {
|
|
59
|
+
let firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]), lastTokenOfLastProperty = sourceCode.getLastToken(node.properties.at(-1));
|
|
60
|
+
if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) return;
|
|
61
|
+
}
|
|
62
|
+
for (let i = 1; i < node.properties.length; i++) {
|
|
63
|
+
let lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]), firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]);
|
|
64
|
+
lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line && context.report({
|
|
65
|
+
node,
|
|
66
|
+
loc: firstTokenOfCurrentProperty.loc,
|
|
67
|
+
messageId,
|
|
68
|
+
fix(fixer) {
|
|
69
|
+
let rangeAfterComma = [sourceCode.getTokenBefore(firstTokenOfCurrentProperty).range[1], firstTokenOfCurrentProperty.range[0]];
|
|
70
|
+
return sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim() ? null : fixer.replaceTextRange(rangeAfterComma, "\n");
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}));
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src-js/generated/plugin-eslint/rules/object-property-newline.cjs
|
|
80
|
+
module.exports = require_object_property_newline().create;
|
|
81
|
+
//#endregion
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
|
|
2
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/object-shorthand.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Rule to enforce concise object methods and properties.
|
|
5
|
+
* @author Jamund Ferguson
|
|
6
|
+
*/
|
|
7
|
+
var require_object_shorthand = /* @__PURE__ */ require_chunk.t(((exports, module) => {
|
|
8
|
+
let OPTIONS = {
|
|
9
|
+
always: "always",
|
|
10
|
+
never: "never",
|
|
11
|
+
methods: "methods",
|
|
12
|
+
properties: "properties",
|
|
13
|
+
consistent: "consistent",
|
|
14
|
+
consistentAsNeeded: "consistent-as-needed"
|
|
15
|
+
}, astUtils = require_ast_utils$1.t(), CTOR_PREFIX_REGEX = /[^_$0-9]/u, JSDOC_COMMENT_REGEX = /^\s*\*/u;
|
|
16
|
+
/**
|
|
17
|
+
* Determines if the first character of the name is a capital letter.
|
|
18
|
+
* @param {string} name The name of the node to evaluate.
|
|
19
|
+
* @returns {boolean} True if the first character of the property name is a capital letter, false if not.
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function isConstructor(name) {
|
|
23
|
+
let match = CTOR_PREFIX_REGEX.exec(name);
|
|
24
|
+
if (!match) return !1;
|
|
25
|
+
let firstChar = name.charAt(match.index);
|
|
26
|
+
return firstChar === firstChar.toUpperCase();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Determines if the property can have a shorthand form.
|
|
30
|
+
* @param {ASTNode} property Property AST node
|
|
31
|
+
* @returns {boolean} True if the property can have a shorthand form
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
function canHaveShorthand(property) {
|
|
35
|
+
return property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether a node is a string literal.
|
|
39
|
+
* @param {ASTNode} node Any AST node.
|
|
40
|
+
* @returns {boolean} `true` if it is a string literal.
|
|
41
|
+
*/
|
|
42
|
+
function isStringLiteral(node) {
|
|
43
|
+
return node.type === "Literal" && typeof node.value == "string";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Determines if the property is a shorthand or not.
|
|
47
|
+
* @param {ASTNode} property Property AST node
|
|
48
|
+
* @returns {boolean} True if the property is considered shorthand, false if not.
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
function isShorthand(property) {
|
|
52
|
+
return property.shorthand || property.method;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Determines if the property's key and method or value are named equally.
|
|
56
|
+
* @param {ASTNode} property Property AST node
|
|
57
|
+
* @returns {boolean} True if the key and value are named equally, false if not.
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
function isRedundant(property) {
|
|
61
|
+
let value = property.value;
|
|
62
|
+
return value.type === "FunctionExpression" ? !value.id : value.type === "Identifier" ? astUtils.getStaticPropertyName(property) === value.name : !1;
|
|
63
|
+
}
|
|
64
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
65
|
+
module.exports = {
|
|
66
|
+
meta: {
|
|
67
|
+
type: "suggestion",
|
|
68
|
+
docs: {
|
|
69
|
+
description: "Require or disallow method and property shorthand syntax for object literals",
|
|
70
|
+
recommended: !1,
|
|
71
|
+
frozen: !0,
|
|
72
|
+
url: "https://eslint.org/docs/latest/rules/object-shorthand"
|
|
73
|
+
},
|
|
74
|
+
fixable: "code",
|
|
75
|
+
schema: { anyOf: [
|
|
76
|
+
{
|
|
77
|
+
type: "array",
|
|
78
|
+
items: [{ enum: [
|
|
79
|
+
"always",
|
|
80
|
+
"methods",
|
|
81
|
+
"properties",
|
|
82
|
+
"never",
|
|
83
|
+
"consistent",
|
|
84
|
+
"consistent-as-needed"
|
|
85
|
+
] }],
|
|
86
|
+
minItems: 0,
|
|
87
|
+
maxItems: 1
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "array",
|
|
91
|
+
items: [{ enum: [
|
|
92
|
+
"always",
|
|
93
|
+
"methods",
|
|
94
|
+
"properties"
|
|
95
|
+
] }, {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: { avoidQuotes: { type: "boolean" } },
|
|
98
|
+
additionalProperties: !1
|
|
99
|
+
}],
|
|
100
|
+
minItems: 0,
|
|
101
|
+
maxItems: 2
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "array",
|
|
105
|
+
items: [{ enum: ["always", "methods"] }, {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
ignoreConstructors: { type: "boolean" },
|
|
109
|
+
methodsIgnorePattern: { type: "string" },
|
|
110
|
+
avoidQuotes: { type: "boolean" },
|
|
111
|
+
avoidExplicitReturnArrows: { type: "boolean" }
|
|
112
|
+
},
|
|
113
|
+
additionalProperties: !1
|
|
114
|
+
}],
|
|
115
|
+
minItems: 0,
|
|
116
|
+
maxItems: 2
|
|
117
|
+
}
|
|
118
|
+
] },
|
|
119
|
+
messages: {
|
|
120
|
+
expectedAllPropertiesShorthanded: "Expected shorthand for all properties.",
|
|
121
|
+
expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.",
|
|
122
|
+
expectedPropertyShorthand: "Expected property shorthand.",
|
|
123
|
+
expectedPropertyLongform: "Expected longform property syntax.",
|
|
124
|
+
expectedMethodShorthand: "Expected method shorthand.",
|
|
125
|
+
expectedMethodLongform: "Expected longform method syntax.",
|
|
126
|
+
unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties."
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
create(context) {
|
|
130
|
+
let APPLY = context.options[0] || OPTIONS.always, APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always, APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always, APPLY_NEVER = APPLY === OPTIONS.never, APPLY_CONSISTENT = APPLY === OPTIONS.consistent, APPLY_CONSISTENT_AS_NEEDED = APPLY === OPTIONS.consistentAsNeeded, PARAMS = context.options[1] || {}, IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors, METHODS_IGNORE_PATTERN = PARAMS.methodsIgnorePattern ? new RegExp(PARAMS.methodsIgnorePattern, "u") : null, AVOID_QUOTES = PARAMS.avoidQuotes, AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows, sourceCode = context.sourceCode;
|
|
131
|
+
/**
|
|
132
|
+
* Ensures that an object's properties are consistently shorthand, or not shorthand at all.
|
|
133
|
+
* @param {ASTNode} node Property AST node
|
|
134
|
+
* @param {boolean} checkRedundancy Whether to check longform redundancy
|
|
135
|
+
* @returns {void}
|
|
136
|
+
*/
|
|
137
|
+
function checkConsistency(node, checkRedundancy) {
|
|
138
|
+
let properties = node.properties.filter(canHaveShorthand);
|
|
139
|
+
if (properties.length > 0) {
|
|
140
|
+
let shorthandProperties = properties.filter(isShorthand);
|
|
141
|
+
shorthandProperties.length !== properties.length && (shorthandProperties.length > 0 ? context.report({
|
|
142
|
+
node,
|
|
143
|
+
messageId: "unexpectedMix"
|
|
144
|
+
}) : checkRedundancy && properties.every(isRedundant) && context.report({
|
|
145
|
+
node,
|
|
146
|
+
messageId: "expectedAllPropertiesShorthanded"
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Fixes a FunctionExpression node by making it into a shorthand property.
|
|
152
|
+
* @param {SourceCodeFixer} fixer The fixer object
|
|
153
|
+
* @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
|
|
154
|
+
* @returns {Object} A fix for this node
|
|
155
|
+
*/
|
|
156
|
+
function makeFunctionShorthand(fixer, node) {
|
|
157
|
+
let firstKeyToken = node.computed ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken) : sourceCode.getFirstToken(node.key), lastKeyToken = node.computed ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken) : sourceCode.getLastToken(node.key), keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]), keyPrefix = "";
|
|
158
|
+
if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) return null;
|
|
159
|
+
node.value.async && (keyPrefix += "async "), node.value.generator && (keyPrefix += "*");
|
|
160
|
+
let fixRange = [firstKeyToken.range[0], node.range[1]], methodPrefix = keyPrefix + keyText;
|
|
161
|
+
if (node.value.type === "FunctionExpression") {
|
|
162
|
+
let functionToken = sourceCode.getTokens(node.value).find((token) => token.type === "Keyword" && token.value === "function"), tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;
|
|
163
|
+
return fixer.replaceTextRange(fixRange, methodPrefix + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1]));
|
|
164
|
+
}
|
|
165
|
+
let arrowToken = sourceCode.getTokenBefore(node.value.body, astUtils.isArrowToken), fnBody = sourceCode.text.slice(arrowToken.range[1], node.value.range[1]), sliceStart = sourceCode.getFirstToken(node.value, { skip: node.value.async ? 1 : 0 }).range[0], sliceEnd = sourceCode.getTokenBefore(arrowToken).range[1], shouldAddParens = node.value.params.length === 1 && node.value.params[0].range[0] === sliceStart, oldParamText = sourceCode.text.slice(sliceStart, sliceEnd), newParamText = shouldAddParens ? `(${oldParamText})` : oldParamText;
|
|
166
|
+
return fixer.replaceTextRange(fixRange, methodPrefix + newParamText + fnBody);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Fixes a FunctionExpression node by making it into a longform property.
|
|
170
|
+
* @param {SourceCodeFixer} fixer The fixer object
|
|
171
|
+
* @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value
|
|
172
|
+
* @returns {Object} A fix for this node
|
|
173
|
+
*/
|
|
174
|
+
function makeFunctionLongform(fixer, node) {
|
|
175
|
+
let firstKeyToken = node.computed ? sourceCode.getTokens(node).find((token) => token.value === "[") : sourceCode.getFirstToken(node.key), lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find((token) => token.value === "]") : sourceCode.getLastToken(node.key), keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]), functionHeader = "function";
|
|
176
|
+
return node.value.async && (functionHeader = `async ${functionHeader}`), node.value.generator && (functionHeader = `${functionHeader}*`), fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], `${keyText}: ${functionHeader}`);
|
|
177
|
+
}
|
|
178
|
+
let lexicalScopeStack = [], arrowsWithLexicalIdentifiers = /* @__PURE__ */ new WeakSet(), argumentsIdentifiers = /* @__PURE__ */ new WeakSet();
|
|
179
|
+
/**
|
|
180
|
+
* Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
|
|
181
|
+
* Also, this marks all `arguments` identifiers so that they can be detected later.
|
|
182
|
+
* @param {ASTNode} node The node representing the function.
|
|
183
|
+
* @returns {void}
|
|
184
|
+
*/
|
|
185
|
+
function enterFunction(node) {
|
|
186
|
+
lexicalScopeStack.unshift(/* @__PURE__ */ new Set()), sourceCode.getScope(node).variables.filter((variable) => variable.name === "arguments").forEach((variable) => {
|
|
187
|
+
variable.references.map((ref) => ref.identifier).forEach((identifier) => argumentsIdentifiers.add(identifier));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Exits a function. This pops the current set of arrow functions off the lexical scope stack.
|
|
192
|
+
* @returns {void}
|
|
193
|
+
*/
|
|
194
|
+
function exitFunction() {
|
|
195
|
+
lexicalScopeStack.shift();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Marks the current function as having a lexical keyword. This implies that all arrow functions
|
|
199
|
+
* in the current lexical scope contain a reference to this lexical keyword.
|
|
200
|
+
* @returns {void}
|
|
201
|
+
*/
|
|
202
|
+
function reportLexicalIdentifier() {
|
|
203
|
+
lexicalScopeStack[0].forEach((arrowFunction) => arrowsWithLexicalIdentifiers.add(arrowFunction));
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
Program: enterFunction,
|
|
207
|
+
FunctionDeclaration: enterFunction,
|
|
208
|
+
FunctionExpression: enterFunction,
|
|
209
|
+
"Program:exit": exitFunction,
|
|
210
|
+
"FunctionDeclaration:exit": exitFunction,
|
|
211
|
+
"FunctionExpression:exit": exitFunction,
|
|
212
|
+
ArrowFunctionExpression(node) {
|
|
213
|
+
lexicalScopeStack[0].add(node);
|
|
214
|
+
},
|
|
215
|
+
"ArrowFunctionExpression:exit"(node) {
|
|
216
|
+
lexicalScopeStack[0].delete(node);
|
|
217
|
+
},
|
|
218
|
+
ThisExpression: reportLexicalIdentifier,
|
|
219
|
+
Super: reportLexicalIdentifier,
|
|
220
|
+
MetaProperty(node) {
|
|
221
|
+
node.meta.name === "new" && node.property.name === "target" && reportLexicalIdentifier();
|
|
222
|
+
},
|
|
223
|
+
Identifier(node) {
|
|
224
|
+
argumentsIdentifiers.has(node) && reportLexicalIdentifier();
|
|
225
|
+
},
|
|
226
|
+
ObjectExpression(node) {
|
|
227
|
+
APPLY_CONSISTENT ? checkConsistency(node, !1) : APPLY_CONSISTENT_AS_NEEDED && checkConsistency(node, !0);
|
|
228
|
+
},
|
|
229
|
+
"Property:exit"(node) {
|
|
230
|
+
let isConciseProperty = node.method || node.shorthand;
|
|
231
|
+
if (node.parent.type !== "ObjectPattern" && !(node.kind === "get" || node.kind === "set") && !(node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression")) {
|
|
232
|
+
if (isConciseProperty) if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) {
|
|
233
|
+
let messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform";
|
|
234
|
+
context.report({
|
|
235
|
+
node,
|
|
236
|
+
messageId,
|
|
237
|
+
fix: (fixer) => makeFunctionLongform(fixer, node)
|
|
238
|
+
});
|
|
239
|
+
} else APPLY_NEVER && context.report({
|
|
240
|
+
node,
|
|
241
|
+
messageId: "expectedPropertyLongform",
|
|
242
|
+
fix: (fixer) => fixer.insertTextAfter(node.key, `: ${node.key.name}`)
|
|
243
|
+
});
|
|
244
|
+
else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) {
|
|
245
|
+
if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) return;
|
|
246
|
+
if (METHODS_IGNORE_PATTERN) {
|
|
247
|
+
let propertyName = astUtils.getStaticPropertyName(node);
|
|
248
|
+
if (propertyName !== null && METHODS_IGNORE_PATTERN.test(propertyName)) return;
|
|
249
|
+
}
|
|
250
|
+
if (AVOID_QUOTES && isStringLiteral(node.key)) return;
|
|
251
|
+
(node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression" && node.value.body.type === "BlockStatement" && AVOID_EXPLICIT_RETURN_ARROWS && !arrowsWithLexicalIdentifiers.has(node.value)) && context.report({
|
|
252
|
+
node,
|
|
253
|
+
messageId: "expectedMethodShorthand",
|
|
254
|
+
fix: (fixer) => makeFunctionShorthand(fixer, node)
|
|
255
|
+
});
|
|
256
|
+
} else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) {
|
|
257
|
+
if (sourceCode.getCommentsInside(node).some((comment) => comment.type === "Block" && JSDOC_COMMENT_REGEX.test(comment.value) && comment.value.includes("@type"))) return;
|
|
258
|
+
context.report({
|
|
259
|
+
node,
|
|
260
|
+
messageId: "expectedPropertyShorthand",
|
|
261
|
+
fix(fixer) {
|
|
262
|
+
return sourceCode.getCommentsInside(node).length > 0 ? null : fixer.replaceText(node, node.value.name);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
} else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) {
|
|
266
|
+
if (AVOID_QUOTES || sourceCode.getCommentsInside(node).some((comment) => comment.type === "Block" && comment.value.startsWith("*") && comment.value.includes("@type"))) return;
|
|
267
|
+
context.report({
|
|
268
|
+
node,
|
|
269
|
+
messageId: "expectedPropertyShorthand",
|
|
270
|
+
fix(fixer) {
|
|
271
|
+
return sourceCode.getCommentsInside(node).length > 0 ? null : fixer.replaceText(node, node.value.name);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}));
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src-js/generated/plugin-eslint/rules/object-shorthand.cjs
|
|
283
|
+
module.exports = require_object_shorthand().create;
|
|
284
|
+
//#endregion
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/one-var-declaration-per-line.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to check multiple var declarations per line
|
|
4
|
+
* @author Alberto Rodríguez
|
|
5
|
+
* @deprecated in ESLint v8.53.0
|
|
6
|
+
*/
|
|
7
|
+
var require_one_var_declaration_per_line = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
meta: {
|
|
11
|
+
deprecated: {
|
|
12
|
+
message: "Formatting rules are being moved out of ESLint core.",
|
|
13
|
+
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
14
|
+
deprecatedSince: "8.53.0",
|
|
15
|
+
availableUntil: "11.0.0",
|
|
16
|
+
replacedBy: [{
|
|
17
|
+
message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
18
|
+
url: "https://eslint.style/guide/migration",
|
|
19
|
+
plugin: {
|
|
20
|
+
name: "@stylistic/eslint-plugin",
|
|
21
|
+
url: "https://eslint.style"
|
|
22
|
+
},
|
|
23
|
+
rule: {
|
|
24
|
+
name: "one-var-declaration-per-line",
|
|
25
|
+
url: "https://eslint.style/rules/one-var-declaration-per-line"
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
},
|
|
29
|
+
type: "suggestion",
|
|
30
|
+
docs: {
|
|
31
|
+
description: "Require or disallow newlines around variable declarations",
|
|
32
|
+
recommended: !1,
|
|
33
|
+
url: "https://eslint.org/docs/latest/rules/one-var-declaration-per-line"
|
|
34
|
+
},
|
|
35
|
+
schema: [{ enum: ["always", "initializations"] }],
|
|
36
|
+
fixable: "whitespace",
|
|
37
|
+
messages: { expectVarOnNewline: "Expected variable declaration to be on a new line." }
|
|
38
|
+
},
|
|
39
|
+
create(context) {
|
|
40
|
+
let always = context.options[0] === "always";
|
|
41
|
+
/**
|
|
42
|
+
* Determine if provided keyword is a variant of for specifiers
|
|
43
|
+
* @private
|
|
44
|
+
* @param {string} keyword keyword to test
|
|
45
|
+
* @returns {boolean} True if `keyword` is a variant of for specifier
|
|
46
|
+
*/
|
|
47
|
+
function isForTypeSpecifier(keyword) {
|
|
48
|
+
return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks newlines around variable declarations.
|
|
52
|
+
* @private
|
|
53
|
+
* @param {ASTNode} node `VariableDeclaration` node to test
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
function checkForNewLine(node) {
|
|
57
|
+
if (isForTypeSpecifier(node.parent.type)) return;
|
|
58
|
+
let declarations = node.declarations, prev;
|
|
59
|
+
declarations.forEach((current) => {
|
|
60
|
+
prev && prev.loc.end.line === current.loc.start.line && (always || prev.init || current.init) && context.report({
|
|
61
|
+
node,
|
|
62
|
+
messageId: "expectVarOnNewline",
|
|
63
|
+
loc: current.loc,
|
|
64
|
+
fix: (fixer) => fixer.insertTextBefore(current, "\n")
|
|
65
|
+
}), prev = current;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return { VariableDeclaration: checkForNewLine };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}));
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src-js/generated/plugin-eslint/rules/one-var-declaration-per-line.cjs
|
|
74
|
+
module.exports = require_one_var_declaration_per_line().create;
|
|
75
|
+
//#endregion
|