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,103 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/func-style.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to enforce a particular function style
|
|
4
|
+
* @author Nicholas C. Zakas
|
|
5
|
+
*/
|
|
6
|
+
var require_func_style = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
7
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
meta: {
|
|
10
|
+
dialects: ["javascript", "typescript"],
|
|
11
|
+
language: "javascript",
|
|
12
|
+
type: "suggestion",
|
|
13
|
+
defaultOptions: ["expression", {
|
|
14
|
+
allowArrowFunctions: !1,
|
|
15
|
+
allowTypeAnnotation: !1,
|
|
16
|
+
overrides: {}
|
|
17
|
+
}],
|
|
18
|
+
docs: {
|
|
19
|
+
description: "Enforce the consistent use of either `function` declarations or expressions assigned to variables",
|
|
20
|
+
recommended: !1,
|
|
21
|
+
frozen: !0,
|
|
22
|
+
url: "https://eslint.org/docs/latest/rules/func-style"
|
|
23
|
+
},
|
|
24
|
+
schema: [{ enum: ["declaration", "expression"] }, {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
allowArrowFunctions: { type: "boolean" },
|
|
28
|
+
allowTypeAnnotation: { type: "boolean" },
|
|
29
|
+
overrides: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: { namedExports: { enum: [
|
|
32
|
+
"declaration",
|
|
33
|
+
"expression",
|
|
34
|
+
"ignore"
|
|
35
|
+
] } },
|
|
36
|
+
additionalProperties: !1
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
additionalProperties: !1
|
|
40
|
+
}],
|
|
41
|
+
messages: {
|
|
42
|
+
expression: "Expected a function expression.",
|
|
43
|
+
declaration: "Expected a function declaration."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
create(context) {
|
|
47
|
+
let [style, { allowArrowFunctions, allowTypeAnnotation, overrides }] = context.options, enforceDeclarations = style === "declaration", { namedExports: exportFunctionStyle } = overrides, stack = [];
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a function declaration is part of an overloaded function
|
|
50
|
+
* @param {ASTNode} node The function declaration node to check
|
|
51
|
+
* @returns {boolean} True if the function is overloaded
|
|
52
|
+
*/
|
|
53
|
+
function isOverloadedFunction(node) {
|
|
54
|
+
let functionName = node.id.name;
|
|
55
|
+
return node.parent.type === "ExportNamedDeclaration" ? node.parent.parent.body.some((member) => member.type === "ExportNamedDeclaration" && member.declaration?.type === "TSDeclareFunction" && member.declaration.id.name === functionName) : node.parent.type === "SwitchCase" ? node.parent.parent.cases.some((switchCase) => switchCase.consequent.some((member) => member.type === "TSDeclareFunction" && member.id.name === functionName)) : Array.isArray(node.parent.body) && node.parent.body.some((member) => member.type === "TSDeclareFunction" && member.id.name === functionName);
|
|
56
|
+
}
|
|
57
|
+
let nodesToCheck = {
|
|
58
|
+
FunctionDeclaration(node) {
|
|
59
|
+
stack.push(!1), !enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration" && (exportFunctionStyle === void 0 || node.parent.type !== "ExportNamedDeclaration") && !isOverloadedFunction(node) && context.report({
|
|
60
|
+
node,
|
|
61
|
+
messageId: "expression"
|
|
62
|
+
}), node.parent.type === "ExportNamedDeclaration" && exportFunctionStyle === "expression" && !isOverloadedFunction(node) && context.report({
|
|
63
|
+
node,
|
|
64
|
+
messageId: "expression"
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
"FunctionDeclaration:exit"() {
|
|
68
|
+
stack.pop();
|
|
69
|
+
},
|
|
70
|
+
FunctionExpression(node) {
|
|
71
|
+
stack.push(!1), enforceDeclarations && node.parent.type === "VariableDeclarator" && (exportFunctionStyle === void 0 || node.parent.parent.parent.type !== "ExportNamedDeclaration") && !(allowTypeAnnotation && node.parent.id.typeAnnotation) && context.report({
|
|
72
|
+
node: node.parent,
|
|
73
|
+
messageId: "declaration"
|
|
74
|
+
}), node.parent.type === "VariableDeclarator" && node.parent.parent.parent.type === "ExportNamedDeclaration" && exportFunctionStyle === "declaration" && !(allowTypeAnnotation && node.parent.id.typeAnnotation) && context.report({
|
|
75
|
+
node: node.parent,
|
|
76
|
+
messageId: "declaration"
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
"FunctionExpression:exit"() {
|
|
80
|
+
stack.pop();
|
|
81
|
+
},
|
|
82
|
+
"ThisExpression, Super"() {
|
|
83
|
+
stack.length > 0 && (stack[stack.length - 1] = !0);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return allowArrowFunctions || (nodesToCheck.ArrowFunctionExpression = function() {
|
|
87
|
+
stack.push(!1);
|
|
88
|
+
}, nodesToCheck["ArrowFunctionExpression:exit"] = function(node) {
|
|
89
|
+
!stack.pop() && node.parent.type === "VariableDeclarator" && (enforceDeclarations && (exportFunctionStyle === void 0 || node.parent.parent.parent.type !== "ExportNamedDeclaration") && !(allowTypeAnnotation && node.parent.id.typeAnnotation) && context.report({
|
|
90
|
+
node: node.parent,
|
|
91
|
+
messageId: "declaration"
|
|
92
|
+
}), node.parent.parent.parent.type === "ExportNamedDeclaration" && exportFunctionStyle === "declaration" && !(allowTypeAnnotation && node.parent.id.typeAnnotation) && context.report({
|
|
93
|
+
node: node.parent,
|
|
94
|
+
messageId: "declaration"
|
|
95
|
+
}));
|
|
96
|
+
}), nodesToCheck;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}));
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src-js/generated/plugin-eslint/rules/func-style.cjs
|
|
102
|
+
module.exports = require_func_style().create;
|
|
103
|
+
//#endregion
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/function-call-argument-newline.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to enforce line breaks between arguments of a function call
|
|
4
|
+
* @author Alexey Gonchar <https://github.com/finico>
|
|
5
|
+
* @deprecated in ESLint v8.53.0
|
|
6
|
+
*/
|
|
7
|
+
var require_function_call_argument_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: "function-call-argument-newline",
|
|
25
|
+
url: "https://eslint.style/rules/function-call-argument-newline"
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
},
|
|
29
|
+
type: "layout",
|
|
30
|
+
docs: {
|
|
31
|
+
description: "Enforce line breaks between arguments of a function call",
|
|
32
|
+
recommended: !1,
|
|
33
|
+
url: "https://eslint.org/docs/latest/rules/function-call-argument-newline"
|
|
34
|
+
},
|
|
35
|
+
fixable: "whitespace",
|
|
36
|
+
schema: [{ enum: [
|
|
37
|
+
"always",
|
|
38
|
+
"never",
|
|
39
|
+
"consistent"
|
|
40
|
+
] }],
|
|
41
|
+
messages: {
|
|
42
|
+
unexpectedLineBreak: "There should be no line break here.",
|
|
43
|
+
missingLineBreak: "There should be a line break after this argument."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
create(context) {
|
|
47
|
+
let sourceCode = context.sourceCode, checkers = {
|
|
48
|
+
unexpected: {
|
|
49
|
+
messageId: "unexpectedLineBreak",
|
|
50
|
+
check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line,
|
|
51
|
+
createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ")
|
|
52
|
+
},
|
|
53
|
+
missing: {
|
|
54
|
+
messageId: "missingLineBreak",
|
|
55
|
+
check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line,
|
|
56
|
+
createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n")
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Check all arguments for line breaks in the CallExpression
|
|
61
|
+
* @param {CallExpression} node node to evaluate
|
|
62
|
+
* @param {{ messageId: string, check: Function }} checker selected checker
|
|
63
|
+
* @returns {void}
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
function checkArguments(node, checker) {
|
|
67
|
+
for (let i = 1; i < node.arguments.length; i++) {
|
|
68
|
+
let prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]), currentArgToken = sourceCode.getFirstToken(node.arguments[i]);
|
|
69
|
+
if (checker.check(prevArgToken, currentArgToken)) {
|
|
70
|
+
let tokenBefore = sourceCode.getTokenBefore(currentArgToken, { includeComments: !0 }), hasLineCommentBefore = tokenBefore.type === "Line";
|
|
71
|
+
context.report({
|
|
72
|
+
node,
|
|
73
|
+
loc: {
|
|
74
|
+
start: tokenBefore.loc.end,
|
|
75
|
+
end: currentArgToken.loc.start
|
|
76
|
+
},
|
|
77
|
+
messageId: checker.messageId,
|
|
78
|
+
fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check if open space is present in a function name
|
|
85
|
+
* @param {CallExpression} node node to evaluate
|
|
86
|
+
* @returns {void}
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
function check(node) {
|
|
90
|
+
if (node.arguments.length < 2) return;
|
|
91
|
+
let option = context.options[0] || "always";
|
|
92
|
+
if (option === "never") checkArguments(node, checkers.unexpected);
|
|
93
|
+
else if (option === "always") checkArguments(node, checkers.missing);
|
|
94
|
+
else if (option === "consistent") {
|
|
95
|
+
let firstArgToken = sourceCode.getLastToken(node.arguments[0]), secondArgToken = sourceCode.getFirstToken(node.arguments[1]);
|
|
96
|
+
firstArgToken.loc.end.line === secondArgToken.loc.start.line ? checkArguments(node, checkers.unexpected) : checkArguments(node, checkers.missing);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
CallExpression: check,
|
|
101
|
+
NewExpression: check
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}));
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src-js/generated/plugin-eslint/rules/function-call-argument-newline.cjs
|
|
108
|
+
module.exports = require_function_call_argument_newline().create;
|
|
109
|
+
//#endregion
|
|
@@ -0,0 +1,173 @@
|
|
|
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/function-paren-newline.js
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview enforce consistent line breaks inside function parentheses
|
|
5
|
+
* @author Teddy Katz
|
|
6
|
+
* @deprecated in ESLint v8.53.0
|
|
7
|
+
*/
|
|
8
|
+
var require_function_paren_newline = /* @__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: "function-paren-newline",
|
|
27
|
+
url: "https://eslint.style/rules/function-paren-newline"
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
type: "layout",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Enforce consistent line breaks inside function parentheses",
|
|
34
|
+
recommended: !1,
|
|
35
|
+
url: "https://eslint.org/docs/latest/rules/function-paren-newline"
|
|
36
|
+
},
|
|
37
|
+
fixable: "whitespace",
|
|
38
|
+
schema: [{ oneOf: [{ enum: [
|
|
39
|
+
"always",
|
|
40
|
+
"never",
|
|
41
|
+
"consistent",
|
|
42
|
+
"multiline",
|
|
43
|
+
"multiline-arguments"
|
|
44
|
+
] }, {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: { minItems: {
|
|
47
|
+
type: "integer",
|
|
48
|
+
minimum: 0
|
|
49
|
+
} },
|
|
50
|
+
additionalProperties: !1
|
|
51
|
+
}] }],
|
|
52
|
+
messages: {
|
|
53
|
+
expectedBefore: "Expected newline before ')'.",
|
|
54
|
+
expectedAfter: "Expected newline after '('.",
|
|
55
|
+
expectedBetween: "Expected newline between arguments/params.",
|
|
56
|
+
unexpectedBefore: "Unexpected newline before ')'.",
|
|
57
|
+
unexpectedAfter: "Unexpected newline after '('."
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
create(context) {
|
|
61
|
+
let sourceCode = context.sourceCode, rawOption = context.options[0] || "multiline", multilineOption = rawOption === "multiline", multilineArgumentsOption = rawOption === "multiline-arguments", consistentOption = rawOption === "consistent", minItems;
|
|
62
|
+
minItems = typeof rawOption == "object" ? rawOption.minItems : rawOption === "always" ? 0 : rawOption === "never" ? Infinity : null;
|
|
63
|
+
/**
|
|
64
|
+
* Determines whether there should be newlines inside function parens
|
|
65
|
+
* @param {ASTNode[]} elements The arguments or parameters in the list
|
|
66
|
+
* @param {boolean} hasLeftNewline `true` if the left paren has a newline in the current code.
|
|
67
|
+
* @returns {boolean} `true` if there should be newlines inside the function parens
|
|
68
|
+
*/
|
|
69
|
+
function shouldHaveNewlines(elements, hasLeftNewline) {
|
|
70
|
+
return multilineArgumentsOption && elements.length === 1 ? hasLeftNewline : multilineOption || multilineArgumentsOption ? elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line) : consistentOption ? hasLeftNewline : elements.length >= minItems;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validates parens
|
|
74
|
+
* @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
|
|
75
|
+
* @param {ASTNode[]} elements The arguments or parameters in the list
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
function validateParens(parens, elements) {
|
|
79
|
+
let leftParen = parens.leftParen, rightParen = parens.rightParen, tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen), tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen), hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen), hasRightNewline = !astUtils.isTokenOnSameLine(tokenBeforeRightParen, rightParen), needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
|
|
80
|
+
hasLeftNewline && !needsNewlines ? context.report({
|
|
81
|
+
node: leftParen,
|
|
82
|
+
messageId: "unexpectedAfter",
|
|
83
|
+
fix(fixer) {
|
|
84
|
+
return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim() ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]);
|
|
85
|
+
}
|
|
86
|
+
}) : !hasLeftNewline && needsNewlines && context.report({
|
|
87
|
+
node: leftParen,
|
|
88
|
+
messageId: "expectedAfter",
|
|
89
|
+
fix: (fixer) => fixer.insertTextAfter(leftParen, "\n")
|
|
90
|
+
}), hasRightNewline && !needsNewlines ? context.report({
|
|
91
|
+
node: rightParen,
|
|
92
|
+
messageId: "unexpectedBefore",
|
|
93
|
+
fix(fixer) {
|
|
94
|
+
return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim() ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]);
|
|
95
|
+
}
|
|
96
|
+
}) : !hasRightNewline && needsNewlines && context.report({
|
|
97
|
+
node: rightParen,
|
|
98
|
+
messageId: "expectedBefore",
|
|
99
|
+
fix: (fixer) => fixer.insertTextBefore(rightParen, "\n")
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validates a list of arguments or parameters
|
|
104
|
+
* @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
|
|
105
|
+
* @param {ASTNode[]} elements The arguments or parameters in the list
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
function validateArguments(parens, elements) {
|
|
109
|
+
let leftParen = parens.leftParen, tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen), needsNewlines = shouldHaveNewlines(elements, !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen));
|
|
110
|
+
for (let i = 0; i <= elements.length - 2; i++) {
|
|
111
|
+
let currentElement = elements[i], nextElement = elements[i + 1];
|
|
112
|
+
currentElement.loc.end.line === nextElement.loc.start.line && needsNewlines && context.report({
|
|
113
|
+
node: currentElement,
|
|
114
|
+
messageId: "expectedBetween",
|
|
115
|
+
fix: (fixer) => fixer.insertTextBefore(nextElement, "\n")
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Gets the left paren and right paren tokens of a node.
|
|
121
|
+
* @param {ASTNode} node The node with parens
|
|
122
|
+
* @throws {TypeError} Unexpected node type.
|
|
123
|
+
* @returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token.
|
|
124
|
+
* Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an ArrowFunctionExpression
|
|
125
|
+
* with a single parameter)
|
|
126
|
+
*/
|
|
127
|
+
function getParenTokens(node) {
|
|
128
|
+
switch (node.type) {
|
|
129
|
+
case "NewExpression": if (!node.arguments.length && !(astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) && astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && node.callee.range[1] < node.range[1])) return null;
|
|
130
|
+
case "CallExpression": return {
|
|
131
|
+
leftParen: sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken),
|
|
132
|
+
rightParen: sourceCode.getLastToken(node)
|
|
133
|
+
};
|
|
134
|
+
case "FunctionDeclaration":
|
|
135
|
+
case "FunctionExpression": {
|
|
136
|
+
let leftParen = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
|
|
137
|
+
return {
|
|
138
|
+
leftParen,
|
|
139
|
+
rightParen: node.params.length ? sourceCode.getTokenAfter(node.params.at(-1), astUtils.isClosingParenToken) : sourceCode.getTokenAfter(leftParen)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
case "ArrowFunctionExpression": {
|
|
143
|
+
let firstToken = sourceCode.getFirstToken(node, { skip: node.async ? 1 : 0 });
|
|
144
|
+
return astUtils.isOpeningParenToken(firstToken) ? {
|
|
145
|
+
leftParen: firstToken,
|
|
146
|
+
rightParen: node.params.length ? sourceCode.getTokenAfter(node.params.at(-1), astUtils.isClosingParenToken) : sourceCode.getTokenAfter(firstToken)
|
|
147
|
+
} : null;
|
|
148
|
+
}
|
|
149
|
+
case "ImportExpression": return {
|
|
150
|
+
leftParen: sourceCode.getFirstToken(node, 1),
|
|
151
|
+
rightParen: sourceCode.getLastToken(node)
|
|
152
|
+
};
|
|
153
|
+
default: throw TypeError(`unexpected node with type ${node.type}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { [[
|
|
157
|
+
"ArrowFunctionExpression",
|
|
158
|
+
"CallExpression",
|
|
159
|
+
"FunctionDeclaration",
|
|
160
|
+
"FunctionExpression",
|
|
161
|
+
"ImportExpression",
|
|
162
|
+
"NewExpression"
|
|
163
|
+
]](node) {
|
|
164
|
+
let parens = getParenTokens(node), params;
|
|
165
|
+
params = node.type === "ImportExpression" ? [node.source] : astUtils.isFunction(node) ? node.params : node.arguments, parens && (validateParens(parens, params), multilineArgumentsOption && validateArguments(parens, params));
|
|
166
|
+
} };
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}));
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src-js/generated/plugin-eslint/rules/function-paren-newline.cjs
|
|
172
|
+
module.exports = require_function_paren_newline().create;
|
|
173
|
+
//#endregion
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/generator-star-spacing.js
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Rule to check the spacing around the * in generator functions.
|
|
4
|
+
* @author Jamund Ferguson
|
|
5
|
+
* @deprecated in ESLint v8.53.0
|
|
6
|
+
*/
|
|
7
|
+
var require_generator_star_spacing = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
|
|
8
|
+
let OVERRIDE_SCHEMA = { oneOf: [{ enum: [
|
|
9
|
+
"before",
|
|
10
|
+
"after",
|
|
11
|
+
"both",
|
|
12
|
+
"neither"
|
|
13
|
+
] }, {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
before: { type: "boolean" },
|
|
17
|
+
after: { type: "boolean" }
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: !1
|
|
20
|
+
}] };
|
|
21
|
+
/** @type {import('../types').Rule.RuleModule} */
|
|
22
|
+
module.exports = {
|
|
23
|
+
meta: {
|
|
24
|
+
deprecated: {
|
|
25
|
+
message: "Formatting rules are being moved out of ESLint core.",
|
|
26
|
+
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
|
27
|
+
deprecatedSince: "8.53.0",
|
|
28
|
+
availableUntil: "11.0.0",
|
|
29
|
+
replacedBy: [{
|
|
30
|
+
message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
|
|
31
|
+
url: "https://eslint.style/guide/migration",
|
|
32
|
+
plugin: {
|
|
33
|
+
name: "@stylistic/eslint-plugin",
|
|
34
|
+
url: "https://eslint.style"
|
|
35
|
+
},
|
|
36
|
+
rule: {
|
|
37
|
+
name: "generator-star-spacing",
|
|
38
|
+
url: "https://eslint.style/rules/generator-star-spacing"
|
|
39
|
+
}
|
|
40
|
+
}]
|
|
41
|
+
},
|
|
42
|
+
type: "layout",
|
|
43
|
+
docs: {
|
|
44
|
+
description: "Enforce consistent spacing around `*` operators in generator functions",
|
|
45
|
+
recommended: !1,
|
|
46
|
+
url: "https://eslint.org/docs/latest/rules/generator-star-spacing"
|
|
47
|
+
},
|
|
48
|
+
fixable: "whitespace",
|
|
49
|
+
schema: [{ oneOf: [{ enum: [
|
|
50
|
+
"before",
|
|
51
|
+
"after",
|
|
52
|
+
"both",
|
|
53
|
+
"neither"
|
|
54
|
+
] }, {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
before: { type: "boolean" },
|
|
58
|
+
after: { type: "boolean" },
|
|
59
|
+
named: OVERRIDE_SCHEMA,
|
|
60
|
+
anonymous: OVERRIDE_SCHEMA,
|
|
61
|
+
method: OVERRIDE_SCHEMA
|
|
62
|
+
},
|
|
63
|
+
additionalProperties: !1
|
|
64
|
+
}] }],
|
|
65
|
+
messages: {
|
|
66
|
+
missingBefore: "Missing space before *.",
|
|
67
|
+
missingAfter: "Missing space after *.",
|
|
68
|
+
unexpectedBefore: "Unexpected space before *.",
|
|
69
|
+
unexpectedAfter: "Unexpected space after *."
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
create(context) {
|
|
73
|
+
let optionDefinitions = {
|
|
74
|
+
before: {
|
|
75
|
+
before: !0,
|
|
76
|
+
after: !1
|
|
77
|
+
},
|
|
78
|
+
after: {
|
|
79
|
+
before: !1,
|
|
80
|
+
after: !0
|
|
81
|
+
},
|
|
82
|
+
both: {
|
|
83
|
+
before: !0,
|
|
84
|
+
after: !0
|
|
85
|
+
},
|
|
86
|
+
neither: {
|
|
87
|
+
before: !1,
|
|
88
|
+
after: !1
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns resolved option definitions based on an option and defaults
|
|
93
|
+
* @param {any} option The option object or string value
|
|
94
|
+
* @param {Object} defaults The defaults to use if options are not present
|
|
95
|
+
* @returns {Object} the resolved object definition
|
|
96
|
+
*/
|
|
97
|
+
function optionToDefinition(option, defaults) {
|
|
98
|
+
return option ? typeof option == "string" ? optionDefinitions[option] : Object.assign({}, defaults, option) : defaults;
|
|
99
|
+
}
|
|
100
|
+
let modes = (function(option) {
|
|
101
|
+
let defaults = optionToDefinition(option, optionDefinitions.before);
|
|
102
|
+
return {
|
|
103
|
+
named: optionToDefinition(option.named, defaults),
|
|
104
|
+
anonymous: optionToDefinition(option.anonymous, defaults),
|
|
105
|
+
method: optionToDefinition(option.method, defaults)
|
|
106
|
+
};
|
|
107
|
+
})(context.options[0] || {}), sourceCode = context.sourceCode;
|
|
108
|
+
/**
|
|
109
|
+
* Checks if the given token is a star token or not.
|
|
110
|
+
* @param {Token} token The token to check.
|
|
111
|
+
* @returns {boolean} `true` if the token is a star token.
|
|
112
|
+
*/
|
|
113
|
+
function isStarToken(token) {
|
|
114
|
+
return token.value === "*" && token.type === "Punctuator";
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets the generator star token of the given function node.
|
|
118
|
+
* @param {ASTNode} node The function node to get.
|
|
119
|
+
* @returns {Token} Found star token.
|
|
120
|
+
*/
|
|
121
|
+
function getStarToken(node) {
|
|
122
|
+
return sourceCode.getFirstToken(node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node, isStarToken);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* capitalize a given string.
|
|
126
|
+
* @param {string} str the given string.
|
|
127
|
+
* @returns {string} the capitalized string.
|
|
128
|
+
*/
|
|
129
|
+
function capitalize(str) {
|
|
130
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Checks the spacing between two tokens before or after the star token.
|
|
134
|
+
* @param {string} kind Either "named", "anonymous", or "method"
|
|
135
|
+
* @param {string} side Either "before" or "after".
|
|
136
|
+
* @param {Token} leftToken `function` keyword token if side is "before", or
|
|
137
|
+
* star token if side is "after".
|
|
138
|
+
* @param {Token} rightToken Star token if side is "before", or identifier
|
|
139
|
+
* token if side is "after".
|
|
140
|
+
* @returns {void}
|
|
141
|
+
*/
|
|
142
|
+
function checkSpacing(kind, side, leftToken, rightToken) {
|
|
143
|
+
if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) {
|
|
144
|
+
let after = leftToken.value === "*", spaceRequired = modes[kind][side], node = after ? leftToken : rightToken, messageId = `${spaceRequired ? "missing" : "unexpected"}${capitalize(side)}`;
|
|
145
|
+
context.report({
|
|
146
|
+
node,
|
|
147
|
+
messageId,
|
|
148
|
+
fix(fixer) {
|
|
149
|
+
return spaceRequired ? after ? fixer.insertTextAfter(node, " ") : fixer.insertTextBefore(node, " ") : fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Enforces the spacing around the star if node is a generator function.
|
|
156
|
+
* @param {ASTNode} node A function expression or declaration node.
|
|
157
|
+
* @returns {void}
|
|
158
|
+
*/
|
|
159
|
+
function checkFunction(node) {
|
|
160
|
+
if (!node.generator) return;
|
|
161
|
+
let starToken = getStarToken(node), prevToken = sourceCode.getTokenBefore(starToken), nextToken = sourceCode.getTokenAfter(starToken), kind = "named";
|
|
162
|
+
node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method ? kind = "method" : node.id || (kind = "anonymous"), kind === "method" && starToken === sourceCode.getFirstToken(node.parent) || checkSpacing(kind, "before", prevToken, starToken), checkSpacing(kind, "after", starToken, nextToken);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
FunctionDeclaration: checkFunction,
|
|
166
|
+
FunctionExpression: checkFunction
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}));
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src-js/generated/plugin-eslint/rules/generator-star-spacing.cjs
|
|
173
|
+
module.exports = require_generator_star_spacing().create;
|
|
174
|
+
//#endregion
|