@so1ve/eslint-config 4.1.8 → 4.2.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/dist/configs/astro.d.mts +8 -0
- package/dist/configs/astro.mjs +49 -0
- package/dist/configs/command.d.mts +6 -0
- package/dist/configs/command.mjs +10 -0
- package/dist/configs/comments.d.mts +6 -0
- package/dist/configs/comments.mjs +19 -0
- package/dist/configs/de-morgan.d.mts +6 -0
- package/dist/configs/de-morgan.mjs +10 -0
- package/dist/configs/formatting.d.mts +6 -0
- package/dist/configs/formatting.mjs +294 -0
- package/dist/configs/html.d.mts +6 -0
- package/dist/configs/html.mjs +37 -0
- package/dist/configs/ignores.d.mts +6 -0
- package/dist/configs/ignores.mjs +14 -0
- package/dist/configs/imports.d.mts +6 -0
- package/dist/configs/imports.mjs +75 -0
- package/dist/configs/index.d.mts +24 -0
- package/dist/configs/index.mjs +26 -0
- package/dist/configs/javascript.d.mts +8 -0
- package/dist/configs/javascript.mjs +326 -0
- package/dist/configs/jsonc.d.mts +6 -0
- package/dist/configs/jsonc.mjs +30 -0
- package/dist/configs/mdx.d.mts +9 -0
- package/dist/configs/mdx.mjs +43 -0
- package/dist/configs/node.d.mts +6 -0
- package/dist/configs/node.mjs +21 -0
- package/dist/configs/only-error.d.mts +6 -0
- package/dist/configs/only-error.mjs +10 -0
- package/dist/configs/perfectionist.d.mts +6 -0
- package/dist/configs/perfectionist.mjs +34 -0
- package/dist/configs/pnpm.d.mts +6 -0
- package/dist/configs/pnpm.mjs +106 -0
- package/dist/configs/promise.d.mts +6 -0
- package/dist/configs/promise.mjs +13 -0
- package/dist/configs/solid.d.mts +9 -0
- package/dist/configs/solid.mjs +24 -0
- package/dist/configs/sort-imports.d.mts +6 -0
- package/dist/configs/sort-imports.mjs +11 -0
- package/dist/configs/test.d.mts +8 -0
- package/dist/configs/test.mjs +46 -0
- package/dist/configs/toml.d.mts +8 -0
- package/dist/configs/toml.mjs +24 -0
- package/dist/configs/typescript.d.mts +10 -0
- package/dist/configs/typescript.mjs +232 -0
- package/dist/configs/unicorn.d.mts +6 -0
- package/dist/configs/unicorn.mjs +61 -0
- package/dist/configs/vue.d.mts +9 -0
- package/dist/configs/vue.mjs +194 -0
- package/dist/configs/yaml.d.mts +8 -0
- package/dist/configs/yaml.mjs +25 -0
- package/dist/factory.d.mts +21 -0
- package/dist/factory.mjs +114 -0
- package/dist/globs.d.mts +31 -0
- package/dist/globs.mjs +80 -0
- package/dist/index.d.mts +30 -16646
- package/dist/index.mjs +28 -2298
- package/dist/plugins.mjs +15 -0
- package/dist/typegen.d.mts +16308 -0
- package/dist/types.d.mts +175 -0
- package/dist/utils.d.mts +30 -0
- package/dist/utils.mjs +32 -0
- package/package.json +4 -6
package/dist/index.mjs
CHANGED
|
@@ -1,2300 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
1
|
+
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML } from "./globs.mjs";
|
|
2
|
+
import { interopDefault, renameRules } from "./utils.mjs";
|
|
3
|
+
import { astro } from "./configs/astro.mjs";
|
|
4
|
+
import { command } from "./configs/command.mjs";
|
|
5
|
+
import { comments } from "./configs/comments.mjs";
|
|
6
|
+
import { deMorgan } from "./configs/de-morgan.mjs";
|
|
7
|
+
import { formatting } from "./configs/formatting.mjs";
|
|
8
|
+
import { html } from "./configs/html.mjs";
|
|
9
|
+
import { ignores } from "./configs/ignores.mjs";
|
|
10
|
+
import { imports } from "./configs/imports.mjs";
|
|
11
|
+
import { javascript } from "./configs/javascript.mjs";
|
|
12
|
+
import { jsonc } from "./configs/jsonc.mjs";
|
|
13
|
+
import { mdx } from "./configs/mdx.mjs";
|
|
14
|
+
import { node } from "./configs/node.mjs";
|
|
15
|
+
import { onlyError } from "./configs/only-error.mjs";
|
|
16
|
+
import { perfectionist } from "./configs/perfectionist.mjs";
|
|
17
|
+
import { pnpm } from "./configs/pnpm.mjs";
|
|
18
|
+
import { promise } from "./configs/promise.mjs";
|
|
19
|
+
import { solid } from "./configs/solid.mjs";
|
|
20
|
+
import { sortImports } from "./configs/sort-imports.mjs";
|
|
21
|
+
import { test } from "./configs/test.mjs";
|
|
22
|
+
import { toml } from "./configs/toml.mjs";
|
|
23
|
+
import { typescript } from "./configs/typescript.mjs";
|
|
24
|
+
import { unicorn } from "./configs/unicorn.mjs";
|
|
25
|
+
import { vue } from "./configs/vue.mjs";
|
|
26
|
+
import { yaml } from "./configs/yaml.mjs";
|
|
27
|
+
import "./configs/index.mjs";
|
|
28
|
+
import { defaultPluginRenaming, getOverrides, so1ve } from "./factory.mjs";
|
|
22
29
|
|
|
23
|
-
//#region src/globs.ts
|
|
24
|
-
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
25
|
-
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
26
|
-
const GLOB_JS = "**/*.?([cm])js";
|
|
27
|
-
const GLOB_JSX = "**/*.?([cm])jsx";
|
|
28
|
-
const GLOB_TS = "**/*.?([cm])ts";
|
|
29
|
-
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
30
|
-
const GLOB_DTS = "**/*.d.?([cm])tsx";
|
|
31
|
-
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
32
|
-
const GLOB_CSS = "**/*.css";
|
|
33
|
-
const GLOB_LESS = "**/*.less";
|
|
34
|
-
const GLOB_SCSS = "**/*.scss";
|
|
35
|
-
const GLOB_JSON = "**/*.json";
|
|
36
|
-
const GLOB_JSON5 = "**/*.json5";
|
|
37
|
-
const GLOB_JSONC = "**/*.jsonc";
|
|
38
|
-
const GLOB_ESLINTRC = "**/.eslintrc";
|
|
39
|
-
const GLOB_MARKDOWN = "**/*.md?(x)";
|
|
40
|
-
const GLOB_ASTRO = "**/*.astro";
|
|
41
|
-
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
42
|
-
const GLOB_VUE = "**/*.vue";
|
|
43
|
-
const GLOB_YAML = "**/*.y?(a)ml";
|
|
44
|
-
const GLOB_TOML = "**/*.toml";
|
|
45
|
-
const GLOB_HTML = "**/*.htm?(l)";
|
|
46
|
-
const GLOB_PACKAGEJSON = "**/package.json";
|
|
47
|
-
const GLOB_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
48
|
-
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/**`;
|
|
49
|
-
const GLOB_TESTS = [
|
|
50
|
-
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
51
|
-
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
52
|
-
`**/*.test.${GLOB_SRC_EXT}`,
|
|
53
|
-
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
54
|
-
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
55
|
-
];
|
|
56
|
-
const GLOB_ALL_SRC = [
|
|
57
|
-
GLOB_SRC,
|
|
58
|
-
GLOB_STYLE,
|
|
59
|
-
GLOB_JSON,
|
|
60
|
-
GLOB_JSON5,
|
|
61
|
-
GLOB_ESLINTRC,
|
|
62
|
-
GLOB_MARKDOWN,
|
|
63
|
-
GLOB_VUE,
|
|
64
|
-
GLOB_YAML,
|
|
65
|
-
GLOB_HTML
|
|
66
|
-
];
|
|
67
|
-
const GLOB_EXCLUDE = [
|
|
68
|
-
"**/node_modules",
|
|
69
|
-
"**/dist",
|
|
70
|
-
"**/out",
|
|
71
|
-
"**/output",
|
|
72
|
-
"**/package-lock.json",
|
|
73
|
-
"**/yarn.lock",
|
|
74
|
-
"**/pnpm-lock.yaml",
|
|
75
|
-
"**/bun.lockb",
|
|
76
|
-
"**/coverage",
|
|
77
|
-
"**/temp",
|
|
78
|
-
"**/.vitepress/cache",
|
|
79
|
-
"**/.nuxt",
|
|
80
|
-
"**/.nitro",
|
|
81
|
-
"**/.vercel",
|
|
82
|
-
"**/.netlify",
|
|
83
|
-
"**/.output",
|
|
84
|
-
"**/.vercel",
|
|
85
|
-
"**/.changeset",
|
|
86
|
-
"**/.idea",
|
|
87
|
-
"**/.vite-inspect",
|
|
88
|
-
"**/.yarn",
|
|
89
|
-
"**/CHANGELOG*.md",
|
|
90
|
-
"**/*.min.*",
|
|
91
|
-
"**/LICENSE*",
|
|
92
|
-
"**/__snapshots__",
|
|
93
|
-
"**/auto-import?(s).d.ts",
|
|
94
|
-
"**/components.d.ts",
|
|
95
|
-
"**/*.vue.js",
|
|
96
|
-
"**/*.vue.jsx",
|
|
97
|
-
"**/*.vue.ts",
|
|
98
|
-
"**/*.vue.tsx"
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/utils.ts
|
|
103
|
-
/**
|
|
104
|
-
* Rename plugin prefixes in a rule object. Accepts a map of prefixes to rename.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* import { renameRules } from "@antfu/eslint-config";
|
|
110
|
-
*
|
|
111
|
-
* export default [
|
|
112
|
-
* {
|
|
113
|
-
* rules: renameRules(
|
|
114
|
-
* {
|
|
115
|
-
* "@typescript-eslint/indent": "error",
|
|
116
|
-
* },
|
|
117
|
-
* { "@typescript-eslint": "ts" },
|
|
118
|
-
* ),
|
|
119
|
-
* },
|
|
120
|
-
* ];
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
const renameRules = (rules$1, map) => Object.fromEntries(Object.entries(rules$1).map(([key, value]) => {
|
|
124
|
-
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
125
|
-
return [key, value];
|
|
126
|
-
}));
|
|
127
|
-
async function interopDefault(m) {
|
|
128
|
-
const resolved = await m;
|
|
129
|
-
return resolved.default ?? resolved;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/configs/astro.ts
|
|
134
|
-
async function astro({ overrides = {} } = {}) {
|
|
135
|
-
const [pluginAstro, parserAstro, parserTs] = await Promise.all([
|
|
136
|
-
interopDefault(import("eslint-plugin-astro")),
|
|
137
|
-
interopDefault(import("astro-eslint-parser")),
|
|
138
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
139
|
-
]);
|
|
140
|
-
return [{
|
|
141
|
-
name: "antfu/astro/setup",
|
|
142
|
-
plugins: { astro: pluginAstro }
|
|
143
|
-
}, {
|
|
144
|
-
files: [GLOB_ASTRO],
|
|
145
|
-
languageOptions: {
|
|
146
|
-
globals: pluginAstro.environments.astro.globals,
|
|
147
|
-
parser: parserAstro,
|
|
148
|
-
parserOptions: {
|
|
149
|
-
extraFileExtensions: [".astro"],
|
|
150
|
-
parser: parserTs
|
|
151
|
-
},
|
|
152
|
-
sourceType: "module"
|
|
153
|
-
},
|
|
154
|
-
name: "antfu/astro/rules",
|
|
155
|
-
processor: "astro/client-side-ts",
|
|
156
|
-
rules: {
|
|
157
|
-
"antfu/no-top-level-await": "off",
|
|
158
|
-
"astro/missing-client-only-directive-value": "error",
|
|
159
|
-
"astro/no-conflict-set-directives": "error",
|
|
160
|
-
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
161
|
-
"astro/no-deprecated-astro-fetchcontent": "error",
|
|
162
|
-
"astro/no-deprecated-astro-resolve": "error",
|
|
163
|
-
"astro/no-deprecated-getentrybyslug": "error",
|
|
164
|
-
"astro/no-set-html-directive": "off",
|
|
165
|
-
"astro/no-unused-define-vars-in-style": "error",
|
|
166
|
-
"astro/semi": "off",
|
|
167
|
-
"astro/valid-compile": "error",
|
|
168
|
-
...overrides
|
|
169
|
-
}
|
|
170
|
-
}];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/configs/command.ts
|
|
175
|
-
const command = async () => [{
|
|
176
|
-
...createCommand(),
|
|
177
|
-
name: "so1ve/command"
|
|
178
|
-
}];
|
|
179
|
-
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/package.json.js
|
|
182
|
-
const name = "eslint-plugin-de-morgan";
|
|
183
|
-
const version = "2.0.0";
|
|
184
|
-
const repository = "azat-io/eslint-plugin-de-morgan";
|
|
185
|
-
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/create-test-with-parameters.js
|
|
188
|
-
function createTestWithParameters(...parameters) {
|
|
189
|
-
return (...predicates) => predicates.every((predicate) => predicate(...parameters));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-logical-expression.js
|
|
194
|
-
function isLogicalExpression(node$1) {
|
|
195
|
-
return node$1.type === "LogicalExpression";
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/find-outermost-parenthesized-node.js
|
|
200
|
-
function findOutermostParenthesizedNode(node$1, sourceCode) {
|
|
201
|
-
let current = node$1;
|
|
202
|
-
let [start, end] = current.range;
|
|
203
|
-
if (isInParentheses(start, end, sourceCode)) return current;
|
|
204
|
-
while (current.parent && isLogicalExpression(current)) {
|
|
205
|
-
current = current.parent;
|
|
206
|
-
[start, end] = current.range;
|
|
207
|
-
if (isInParentheses(start, end, sourceCode)) return current;
|
|
208
|
-
}
|
|
209
|
-
return current;
|
|
210
|
-
}
|
|
211
|
-
function isInParentheses(start, end, sourceCode) {
|
|
212
|
-
return sourceCode[start - 1] === "(" && sourceCode[end] === ")";
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-unary-expression.js
|
|
217
|
-
function isUnaryExpression(node$1) {
|
|
218
|
-
return node$1.type === "UnaryExpression";
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-operator.js
|
|
223
|
-
function hasOperator(operator) {
|
|
224
|
-
return (node$1) => node$1.operator === operator;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-negation-operator.js
|
|
229
|
-
function hasNegationOperator(node$1) {
|
|
230
|
-
return createTestWithParameters(node$1)(isUnaryExpression, hasOperator("!"));
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-negation-inside-parens.js
|
|
235
|
-
function hasNegationInsideParens(node$1, context) {
|
|
236
|
-
let outermostNode = findOutermostParenthesizedNode(node$1, context.sourceCode.getText(node$1));
|
|
237
|
-
if (!isUnaryExpression(outermostNode)) return false;
|
|
238
|
-
return hasNegationInside(outermostNode.argument);
|
|
239
|
-
}
|
|
240
|
-
function hasNegationInside(node$1) {
|
|
241
|
-
if (isUnaryExpression(node$1) && node$1.operator === "!" && isUnaryExpression(node$1.argument) && node$1.argument.operator === "!") return hasNegationInside(node$1.argument.argument);
|
|
242
|
-
if (hasNegationOperator(node$1)) return true;
|
|
243
|
-
if (isLogicalExpression(node$1)) return hasNegationInside(node$1.left) || hasNegationInside(node$1.right);
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-binary-expression.js
|
|
249
|
-
function isBinaryExpression(node$1) {
|
|
250
|
-
return node$1.type === "BinaryExpression";
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/has-boolean-context.js
|
|
255
|
-
function hasBooleanContext(node$1, _context) {
|
|
256
|
-
return node$1.parent ? isControlFlowBooleanContext(node$1.parent) || isBooleanOperation(node$1.parent) || isBooleanFunction(node$1.parent) : false;
|
|
257
|
-
}
|
|
258
|
-
function isControlFlowBooleanContext(parent) {
|
|
259
|
-
return booleanControlFlowNodes.has(parent.type);
|
|
260
|
-
}
|
|
261
|
-
let booleanControlFlowNodes = /* @__PURE__ */ new Set([
|
|
262
|
-
"ConditionalExpression",
|
|
263
|
-
"LogicalExpression",
|
|
264
|
-
"DoWhileStatement",
|
|
265
|
-
"UnaryExpression",
|
|
266
|
-
"WhileStatement",
|
|
267
|
-
"ForStatement",
|
|
268
|
-
"IfStatement"
|
|
269
|
-
]);
|
|
270
|
-
function isBooleanOperation(parent) {
|
|
271
|
-
return isBinaryExpression(parent) && booleanOperators.has(parent.operator);
|
|
272
|
-
}
|
|
273
|
-
let booleanOperators = /* @__PURE__ */ new Set([
|
|
274
|
-
"instanceof",
|
|
275
|
-
"===",
|
|
276
|
-
"!==",
|
|
277
|
-
"==",
|
|
278
|
-
"!=",
|
|
279
|
-
"<=",
|
|
280
|
-
">=",
|
|
281
|
-
"in",
|
|
282
|
-
"<",
|
|
283
|
-
">"
|
|
284
|
-
]);
|
|
285
|
-
function isBooleanFunction(parent) {
|
|
286
|
-
return parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "Boolean";
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
//#endregion
|
|
290
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/apply-to-property.js
|
|
291
|
-
function applyToProperty(property, predicate) {
|
|
292
|
-
return (object) => predicate(object[property]);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-conjunction.js
|
|
297
|
-
function isConjunction(node$1) {
|
|
298
|
-
return createTestWithParameters(node$1)(isLogicalExpression, hasOperator("&&"));
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/sanitize-code.js
|
|
303
|
-
function sanitizeCode(code) {
|
|
304
|
-
let stringLiterals = [];
|
|
305
|
-
let normalized = code.replaceAll(/(?<quote>["'`])(?:\\.|(?!\k<quote>)[^\\])*\k<quote>/gu, (match) => {
|
|
306
|
-
let placeholder = `__STRING_LITERAL_${stringLiterals.length}__`;
|
|
307
|
-
stringLiterals.push(match);
|
|
308
|
-
return placeholder;
|
|
309
|
-
}).replaceAll(/\/\/.*$/gmu, "").replaceAll(/\/\*[\s\S]*?\*\//gu, "").replaceAll(/\s+/gu, " ").replaceAll(/\(\s+/gu, "(").replaceAll(/\s+\)/gu, ")").trim();
|
|
310
|
-
for (let [index$1, string_] of stringLiterals.entries()) normalized = normalized.replace(`__STRING_LITERAL_${index$1}__`, string_);
|
|
311
|
-
return normalized;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
//#endregion
|
|
315
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-pure-group.js
|
|
316
|
-
function isPureGroup(node$1, context) {
|
|
317
|
-
let outermostNode = findOutermostParenthesizedNode(node$1, context.sourceCode.getText());
|
|
318
|
-
return !hasMixedOperators(getCodeInsideParentheses(context.sourceCode.getText(outermostNode)));
|
|
319
|
-
}
|
|
320
|
-
function hasMixedOperators(code) {
|
|
321
|
-
let depth = 0;
|
|
322
|
-
let operatorFound = null;
|
|
323
|
-
for (let i = 0; i < code.length; i++) {
|
|
324
|
-
let char = code[i];
|
|
325
|
-
if (char === "(") {
|
|
326
|
-
depth++;
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
if (char === ")") {
|
|
330
|
-
depth--;
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (depth !== 0) continue;
|
|
334
|
-
let twoChars = code.slice(i, i + 2);
|
|
335
|
-
if (twoChars === "&&" || twoChars === "||") {
|
|
336
|
-
if (operatorFound === null) operatorFound = twoChars;
|
|
337
|
-
else if (operatorFound !== twoChars) return true;
|
|
338
|
-
i++;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
function getCodeInsideParentheses(code) {
|
|
344
|
-
if (code.startsWith("!(")) return code.slice(2, -1);
|
|
345
|
-
if (code.startsWith("(")) return code.slice(1, -1);
|
|
346
|
-
return code;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-negated.js
|
|
351
|
-
function isNegated(node$1) {
|
|
352
|
-
return hasNegationOperator(node$1) && !hasNegationOperator(node$1.argument) && (!node$1.parent || !hasNegationOperator(node$1.parent));
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
//#endregion
|
|
356
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/parenthesize.js
|
|
357
|
-
function parenthesize(text, condition = true) {
|
|
358
|
-
return condition ? `(${text})` : text;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-boolean.js
|
|
363
|
-
function isBoolean(node$1) {
|
|
364
|
-
return node$1.type === "Literal" && typeof node$1.value === "boolean";
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/toggle-negation.js
|
|
369
|
-
function toggleNegation(node$1, context) {
|
|
370
|
-
let toggleStrategies = [
|
|
371
|
-
{
|
|
372
|
-
transformer: toggleBinaryExpression,
|
|
373
|
-
predicate: isBinaryExpression
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
transformer: toggleBooleanLiteral,
|
|
377
|
-
predicate: isBoolean
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
transformer: toggleLogicalExpression,
|
|
381
|
-
predicate: isLogicalExpression
|
|
382
|
-
}
|
|
383
|
-
];
|
|
384
|
-
for (let { transformer, predicate } of toggleStrategies) if (predicate(node$1)) return transformer(node$1, context);
|
|
385
|
-
return toggleUnaryExpression(node$1, context);
|
|
386
|
-
}
|
|
387
|
-
function toggleBinaryExpression(node$1, context) {
|
|
388
|
-
let left = context.sourceCode.getText(node$1.left).trim();
|
|
389
|
-
let right = context.sourceCode.getText(node$1.right).trim();
|
|
390
|
-
if ([
|
|
391
|
-
"<<",
|
|
392
|
-
">>",
|
|
393
|
-
">>>",
|
|
394
|
-
"+",
|
|
395
|
-
"-",
|
|
396
|
-
"*",
|
|
397
|
-
"/",
|
|
398
|
-
"%",
|
|
399
|
-
"**",
|
|
400
|
-
"|",
|
|
401
|
-
"^",
|
|
402
|
-
"&",
|
|
403
|
-
"in",
|
|
404
|
-
"instanceof"
|
|
405
|
-
].includes(node$1.operator)) return `!(${left} ${node$1.operator} ${right})`;
|
|
406
|
-
return `${left} ${{
|
|
407
|
-
"===": "!==",
|
|
408
|
-
"!==": "===",
|
|
409
|
-
"==": "!=",
|
|
410
|
-
"!=": "==",
|
|
411
|
-
"<": ">=",
|
|
412
|
-
">": "<=",
|
|
413
|
-
"<=": ">",
|
|
414
|
-
">=": "<"
|
|
415
|
-
}[node$1.operator]} ${right}`;
|
|
416
|
-
}
|
|
417
|
-
function toggleLogicalExpression(node$1, context) {
|
|
418
|
-
return toggleCode(parenthesize(context.sourceCode.getText(node$1).trim()));
|
|
419
|
-
}
|
|
420
|
-
function toggleUnaryExpression(node$1, context) {
|
|
421
|
-
return toggleCode(context.sourceCode.getText(node$1).trim());
|
|
422
|
-
}
|
|
423
|
-
function toggleCode(code) {
|
|
424
|
-
return code.startsWith("!") ? code.replace(/^!/u, "") : `!${code}`;
|
|
425
|
-
}
|
|
426
|
-
function toggleBooleanLiteral(node$1) {
|
|
427
|
-
return node$1.value ? "false" : "true";
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/is-disjunction.js
|
|
432
|
-
function isDisjunction(node$1) {
|
|
433
|
-
return createTestWithParameters(node$1)(isLogicalExpression, hasOperator("||"));
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/transform.js
|
|
438
|
-
const MAX_DEPTH = 10;
|
|
439
|
-
const OPERATOR_MAPPING = {
|
|
440
|
-
"&&": "||",
|
|
441
|
-
"||": "&&"
|
|
442
|
-
};
|
|
443
|
-
function transform({ shouldWrapInParens, expressionType, context, node: node$1 }) {
|
|
444
|
-
let argument = node$1.argument;
|
|
445
|
-
let sourceOperator = expressionType === "conjunction" ? "&&" : "||";
|
|
446
|
-
if (argument.operator !== sourceOperator) return null;
|
|
447
|
-
let originalText = context.sourceCode.getText(argument);
|
|
448
|
-
let transformUtilityOptions = {
|
|
449
|
-
expression: argument,
|
|
450
|
-
expressionType,
|
|
451
|
-
sourceOperator,
|
|
452
|
-
targetOperator: OPERATOR_MAPPING[sourceOperator],
|
|
453
|
-
context
|
|
454
|
-
};
|
|
455
|
-
return parenthesize(hasSpecialFormatting(originalText) ? transformWithFormatting(transformUtilityOptions) : transformSimple(transformUtilityOptions), shouldWrapInParens);
|
|
456
|
-
}
|
|
457
|
-
function transformWithFormatting({ sourceOperator, targetOperator, expression, context }) {
|
|
458
|
-
let { sourceCode } = context;
|
|
459
|
-
let leftText = toggleNegation(expression.left, context);
|
|
460
|
-
let rightText = toggleNegation(expression.right, context);
|
|
461
|
-
if (!expression.left.range || !expression.right.range) return `${leftText} ${targetOperator} ${rightText}`;
|
|
462
|
-
let [, leftEnd] = expression.left.range;
|
|
463
|
-
let [rightStart] = expression.right.range;
|
|
464
|
-
let textBetween = sourceCode.text.slice(leftEnd, rightStart);
|
|
465
|
-
if (/\(\s*$/u.test(textBetween)) textBetween = textBetween.replace(/\(\s*$/u, "");
|
|
466
|
-
return `${leftText}${textBetween.replaceAll(new RegExp(sourceOperator.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`), "gu"), targetOperator)}${rightText}`;
|
|
467
|
-
}
|
|
468
|
-
function flattenOperands({ expressionType, expression, context }) {
|
|
469
|
-
let result = [];
|
|
470
|
-
let stack = [{
|
|
471
|
-
expr: expression,
|
|
472
|
-
depth: 0
|
|
473
|
-
}];
|
|
474
|
-
while (stack.length > 0) {
|
|
475
|
-
let { depth, expr } = stack.pop();
|
|
476
|
-
if (depth > MAX_DEPTH || !matchesExpressionType(expr, expressionType)) {
|
|
477
|
-
result.push(toggleNegation(expr, context));
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
let logicalExpr = expr;
|
|
481
|
-
stack.push({
|
|
482
|
-
expr: logicalExpr.right,
|
|
483
|
-
depth: depth + 1
|
|
484
|
-
}, {
|
|
485
|
-
expr: logicalExpr.left,
|
|
486
|
-
depth: depth + 1
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
return result;
|
|
490
|
-
}
|
|
491
|
-
function transformSimple({ expressionType, targetOperator, expression, context }) {
|
|
492
|
-
return flattenOperands({
|
|
493
|
-
expressionType,
|
|
494
|
-
expression,
|
|
495
|
-
context
|
|
496
|
-
}).join(` ${targetOperator} `);
|
|
497
|
-
}
|
|
498
|
-
function matchesExpressionType(expression, type) {
|
|
499
|
-
return type === "conjunction" ? isConjunction(expression) : isDisjunction(expression);
|
|
500
|
-
}
|
|
501
|
-
function hasSpecialFormatting(text) {
|
|
502
|
-
return text.includes("//") || text.includes("/*") || text.includes("\n") || /\s{2,}/u.test(text);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
//#endregion
|
|
506
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/not.js
|
|
507
|
-
function not(predicate) {
|
|
508
|
-
return (...arguments_) => !predicate(...arguments_);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/utils/or.js
|
|
513
|
-
function or(...predicates) {
|
|
514
|
-
return (...arguments_) => predicates.some((predicate) => predicate(...arguments_));
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
//#endregion
|
|
518
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/rules/no-negated-conjunction.js
|
|
519
|
-
const noNegatedConjunction = {
|
|
520
|
-
create: (context) => ({ UnaryExpression: (node$1) => {
|
|
521
|
-
if (createTestWithParameters(node$1, context)(isNegated, applyToProperty("argument", isConjunction), isPureGroup, or(hasBooleanContext, not(hasNegationInsideParens)))) {
|
|
522
|
-
let fixedExpression = transform({
|
|
523
|
-
expressionType: "conjunction",
|
|
524
|
-
shouldWrapInParens: isConjunction(node$1.parent),
|
|
525
|
-
context,
|
|
526
|
-
node: node$1
|
|
527
|
-
});
|
|
528
|
-
if (fixedExpression) {
|
|
529
|
-
let originalExpression = context.sourceCode.getText(node$1);
|
|
530
|
-
context.report({
|
|
531
|
-
data: {
|
|
532
|
-
original: sanitizeCode(originalExpression),
|
|
533
|
-
fixed: sanitizeCode(fixedExpression)
|
|
534
|
-
},
|
|
535
|
-
fix: (fixer) => fixer.replaceText(node$1, fixedExpression),
|
|
536
|
-
messageId: "convertNegatedConjunction",
|
|
537
|
-
node: node$1
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
} }),
|
|
542
|
-
meta: {
|
|
543
|
-
docs: {
|
|
544
|
-
description: "Transforms the negation of a conjunction !(A && B) into the equivalent !A || !B according to De Morgan’s law",
|
|
545
|
-
url: `https://github.com/${repository}/blob/main/docs/no-negated-conjunction.md`,
|
|
546
|
-
category: "Best Practices",
|
|
547
|
-
recommended: true
|
|
548
|
-
},
|
|
549
|
-
messages: { convertNegatedConjunction: "Replace negated conjunction `{{ original }}` with `{{ fixed }}`" },
|
|
550
|
-
type: "suggestion",
|
|
551
|
-
fixable: "code",
|
|
552
|
-
schema: []
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/rules/no-negated-disjunction.js
|
|
558
|
-
const noNegatedDisjunction = {
|
|
559
|
-
create: (context) => ({ UnaryExpression: (node$1) => {
|
|
560
|
-
if (createTestWithParameters(node$1, context)(isNegated, applyToProperty("argument", isDisjunction), isPureGroup, or(hasBooleanContext, not(hasNegationInsideParens)))) {
|
|
561
|
-
let fixedExpression = transform({
|
|
562
|
-
expressionType: "disjunction",
|
|
563
|
-
shouldWrapInParens: false,
|
|
564
|
-
context,
|
|
565
|
-
node: node$1
|
|
566
|
-
});
|
|
567
|
-
if (fixedExpression) {
|
|
568
|
-
let originalExpression = context.sourceCode.getText(node$1);
|
|
569
|
-
context.report({
|
|
570
|
-
data: {
|
|
571
|
-
original: sanitizeCode(originalExpression),
|
|
572
|
-
fixed: sanitizeCode(fixedExpression)
|
|
573
|
-
},
|
|
574
|
-
fix: (fixer) => fixer.replaceText(node$1, fixedExpression),
|
|
575
|
-
messageId: "convertNegatedDisjunction",
|
|
576
|
-
node: node$1
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
} }),
|
|
581
|
-
meta: {
|
|
582
|
-
docs: {
|
|
583
|
-
description: "Transforms the negation of a disjunction !(A || B) into the equivalent !A && !B according to De Morgan’s law",
|
|
584
|
-
url: `https://github.com/${repository}/blob/main/docs/no-negated-disjunction.md`,
|
|
585
|
-
category: "Best Practices",
|
|
586
|
-
recommended: true
|
|
587
|
-
},
|
|
588
|
-
messages: { convertNegatedDisjunction: "Replace negated disjunction `{{ original }}` with `{{ fixed }}`" },
|
|
589
|
-
type: "suggestion",
|
|
590
|
-
fixable: "code",
|
|
591
|
-
schema: []
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
//#endregion
|
|
596
|
-
//#region ../../node_modules/.pnpm/eslint-plugin-de-morgan@2.0.0_eslint@9.39.2_jiti@2.6.1_/node_modules/eslint-plugin-de-morgan/dist/index.js
|
|
597
|
-
let pluginName = "de-morgan";
|
|
598
|
-
let rules = {
|
|
599
|
-
"no-negated-conjunction": noNegatedConjunction,
|
|
600
|
-
"no-negated-disjunction": noNegatedDisjunction
|
|
601
|
-
};
|
|
602
|
-
function getRules() {
|
|
603
|
-
return Object.fromEntries(Object.keys(rules).map((ruleName) => [`${pluginName}/${ruleName}`, "error"]));
|
|
604
|
-
}
|
|
605
|
-
function createConfig() {
|
|
606
|
-
return {
|
|
607
|
-
plugins: { [pluginName]: { rules } },
|
|
608
|
-
rules: getRules()
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
function createLegacyConfig() {
|
|
612
|
-
return {
|
|
613
|
-
plugins: [pluginName],
|
|
614
|
-
rules: getRules()
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
let configs = {
|
|
618
|
-
"recommended-legacy": createLegacyConfig(),
|
|
619
|
-
recommended: createConfig()
|
|
620
|
-
};
|
|
621
|
-
const index = {
|
|
622
|
-
meta: {
|
|
623
|
-
version,
|
|
624
|
-
name
|
|
625
|
-
},
|
|
626
|
-
configs,
|
|
627
|
-
rules
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region src/configs/comments.ts
|
|
632
|
-
const comments = () => [{
|
|
633
|
-
name: "so1ve/comments/setup",
|
|
634
|
-
plugins: { "eslint-comments": pluginComments }
|
|
635
|
-
}, {
|
|
636
|
-
name: "so1ve/comments/rules",
|
|
637
|
-
rules: {
|
|
638
|
-
"eslint-comments/disable-enable-pair": "off",
|
|
639
|
-
"eslint-comments/no-aggregating-enable": "error",
|
|
640
|
-
"eslint-comments/no-duplicate-disable": "error",
|
|
641
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
642
|
-
"eslint-comments/no-unused-enable": "error"
|
|
643
|
-
}
|
|
644
|
-
}];
|
|
645
|
-
|
|
646
|
-
//#endregion
|
|
647
|
-
//#region src/configs/de-morgan.ts
|
|
648
|
-
const deMorgan = () => [{
|
|
649
|
-
...index.configs.recommended,
|
|
650
|
-
name: "so1ve/de-morgan"
|
|
651
|
-
}];
|
|
652
|
-
|
|
653
|
-
//#endregion
|
|
654
|
-
//#region src/configs/formatting.ts
|
|
655
|
-
async function formatting(options) {
|
|
656
|
-
return [
|
|
657
|
-
{
|
|
658
|
-
name: "so1ve/formatting/setup",
|
|
659
|
-
plugins: { style: await interopDefault(import("@stylistic/eslint-plugin")) }
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
name: "so1ve/formatting/rules",
|
|
663
|
-
rules: {
|
|
664
|
-
"curly": ["error", "all"],
|
|
665
|
-
"so1ve/function-style": "error",
|
|
666
|
-
"so1ve/import-export-newline": "error",
|
|
667
|
-
"so1ve/no-import-promises-as": "error",
|
|
668
|
-
"so1ve/no-negated-comparison": "error",
|
|
669
|
-
"so1ve/no-useless-template-string": "error",
|
|
670
|
-
"style/lines-between-class-members": [
|
|
671
|
-
"error",
|
|
672
|
-
"always",
|
|
673
|
-
{ exceptAfterSingleLine: true }
|
|
674
|
-
],
|
|
675
|
-
"style/no-extra-parens": ["error", "functions"],
|
|
676
|
-
"style/padding-line-between-statements": ["error", {
|
|
677
|
-
blankLine: "always",
|
|
678
|
-
prev: "*",
|
|
679
|
-
next: "return"
|
|
680
|
-
}],
|
|
681
|
-
"style/quote-props": ["error", "consistent-as-needed"],
|
|
682
|
-
"style/spaced-comment": [
|
|
683
|
-
"error",
|
|
684
|
-
"always",
|
|
685
|
-
{
|
|
686
|
-
line: {
|
|
687
|
-
markers: ["/"],
|
|
688
|
-
exceptions: ["/", "#"]
|
|
689
|
-
},
|
|
690
|
-
block: {
|
|
691
|
-
markers: ["!"],
|
|
692
|
-
exceptions: ["*"],
|
|
693
|
-
balanced: true
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
]
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
(options?.jsonc ?? true) && [{
|
|
700
|
-
name: "so1ve/formatting/rules/sort-package-json",
|
|
701
|
-
files: [GLOB_PACKAGEJSON],
|
|
702
|
-
rules: { "jsonc/sort-keys": [
|
|
703
|
-
"error",
|
|
704
|
-
{
|
|
705
|
-
pathPattern: "^$",
|
|
706
|
-
order: [
|
|
707
|
-
"name",
|
|
708
|
-
"displayName",
|
|
709
|
-
"private",
|
|
710
|
-
"preview",
|
|
711
|
-
"version",
|
|
712
|
-
"packageManager",
|
|
713
|
-
"publisher",
|
|
714
|
-
"author",
|
|
715
|
-
"contributors",
|
|
716
|
-
"type",
|
|
717
|
-
"description",
|
|
718
|
-
"keywords",
|
|
719
|
-
"homepage",
|
|
720
|
-
"repository",
|
|
721
|
-
"bugs",
|
|
722
|
-
"funding",
|
|
723
|
-
"categories",
|
|
724
|
-
"license",
|
|
725
|
-
"sideEffects",
|
|
726
|
-
"exports",
|
|
727
|
-
"bin",
|
|
728
|
-
"main",
|
|
729
|
-
"module",
|
|
730
|
-
"browser",
|
|
731
|
-
"unpkg",
|
|
732
|
-
"jsdelivr",
|
|
733
|
-
"types",
|
|
734
|
-
"typesVersions",
|
|
735
|
-
"icon",
|
|
736
|
-
"files",
|
|
737
|
-
"engines",
|
|
738
|
-
"extensionKind",
|
|
739
|
-
"activationEvents",
|
|
740
|
-
"contributes",
|
|
741
|
-
"eslintConfig",
|
|
742
|
-
"publishConfig",
|
|
743
|
-
"scripts",
|
|
744
|
-
"husky",
|
|
745
|
-
"simple-git-hooks",
|
|
746
|
-
"lint-staged",
|
|
747
|
-
"dependencies",
|
|
748
|
-
"devDependencies",
|
|
749
|
-
"optionalDependencies",
|
|
750
|
-
"peerDependencies",
|
|
751
|
-
"peerDependenciesMeta",
|
|
752
|
-
"pnpm",
|
|
753
|
-
"overrides",
|
|
754
|
-
"resolutions"
|
|
755
|
-
]
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
pathPattern: "^scripts$",
|
|
759
|
-
order: { type: "asc" }
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
pathPattern: "^exports.*$",
|
|
763
|
-
order: [
|
|
764
|
-
"types",
|
|
765
|
-
"require",
|
|
766
|
-
"import",
|
|
767
|
-
"default"
|
|
768
|
-
]
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
|
|
772
|
-
order: { type: "asc" }
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
|
|
776
|
-
order: { type: "asc" }
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
pathPattern: "^workspaces\\.catalog$",
|
|
780
|
-
order: { type: "asc" }
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
pathPattern: "^workspaces\\.catalogs\\.[^.]+$",
|
|
784
|
-
order: { type: "asc" }
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
|
|
788
|
-
order: [
|
|
789
|
-
"pre-commit",
|
|
790
|
-
"prepare-commit-msg",
|
|
791
|
-
"commit-msg",
|
|
792
|
-
"post-commit",
|
|
793
|
-
"pre-rebase",
|
|
794
|
-
"post-rewrite",
|
|
795
|
-
"post-checkout",
|
|
796
|
-
"post-merge",
|
|
797
|
-
"pre-push",
|
|
798
|
-
"pre-auto-gc"
|
|
799
|
-
]
|
|
800
|
-
}
|
|
801
|
-
] }
|
|
802
|
-
}, {
|
|
803
|
-
name: "so1ve/formatting/rules/sort-tsconfig",
|
|
804
|
-
files: GLOB_TSCONFIG,
|
|
805
|
-
rules: {
|
|
806
|
-
"jsonc/sort-array-values": [
|
|
807
|
-
"error",
|
|
808
|
-
{
|
|
809
|
-
pathPattern: "^compilerOptions\\.types$",
|
|
810
|
-
order: { type: "asc" }
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
pathPattern: "^include$",
|
|
814
|
-
order: { type: "asc" }
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
pathPattern: "^exclude$",
|
|
818
|
-
order: { type: "asc" }
|
|
819
|
-
}
|
|
820
|
-
],
|
|
821
|
-
"jsonc/sort-keys": [
|
|
822
|
-
"error",
|
|
823
|
-
{
|
|
824
|
-
pathPattern: "^$",
|
|
825
|
-
order: [
|
|
826
|
-
"extends",
|
|
827
|
-
"compilerOptions",
|
|
828
|
-
"references",
|
|
829
|
-
"files",
|
|
830
|
-
"include",
|
|
831
|
-
"exclude"
|
|
832
|
-
]
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
pathPattern: "^compilerOptions$",
|
|
836
|
-
order: [
|
|
837
|
-
"incremental",
|
|
838
|
-
"composite",
|
|
839
|
-
"tsBuildInfoFile",
|
|
840
|
-
"disableSourceOfProjectReferenceRedirect",
|
|
841
|
-
"disableSolutionSearching",
|
|
842
|
-
"disableReferencedProjectLoad",
|
|
843
|
-
"target",
|
|
844
|
-
"jsx",
|
|
845
|
-
"jsxFactory",
|
|
846
|
-
"jsxFragmentFactory",
|
|
847
|
-
"jsxImportSource",
|
|
848
|
-
"lib",
|
|
849
|
-
"moduleDetection",
|
|
850
|
-
"noLib",
|
|
851
|
-
"reactNamespace",
|
|
852
|
-
"useDefineForClassFields",
|
|
853
|
-
"emitDecoratorMetadata",
|
|
854
|
-
"experimentalDecorators",
|
|
855
|
-
"baseUrl",
|
|
856
|
-
"rootDir",
|
|
857
|
-
"rootDirs",
|
|
858
|
-
"customConditions",
|
|
859
|
-
"module",
|
|
860
|
-
"moduleResolution",
|
|
861
|
-
"moduleSuffixes",
|
|
862
|
-
"noResolve",
|
|
863
|
-
"resolveJsonModule",
|
|
864
|
-
"resolvePackageJsonExports",
|
|
865
|
-
"resolvePackageJsonImports",
|
|
866
|
-
"typeRoots",
|
|
867
|
-
"types",
|
|
868
|
-
"allowArbitraryExtensions",
|
|
869
|
-
"allowImportingTsExtensions",
|
|
870
|
-
"allowUmdGlobalAccess",
|
|
871
|
-
"allowJs",
|
|
872
|
-
"checkJs",
|
|
873
|
-
"maxNodeModuleJsDepth",
|
|
874
|
-
"strict",
|
|
875
|
-
"strictBindCallApply",
|
|
876
|
-
"strictFunctionTypes",
|
|
877
|
-
"strictNullChecks",
|
|
878
|
-
"strictPropertyInitialization",
|
|
879
|
-
"allowUnreachableCode",
|
|
880
|
-
"allowUnusedLabels",
|
|
881
|
-
"alwaysStrict",
|
|
882
|
-
"erasableSyntaxOnly",
|
|
883
|
-
"exactOptionalPropertyTypes",
|
|
884
|
-
"noFallthroughCasesInSwitch",
|
|
885
|
-
"noImplicitAny",
|
|
886
|
-
"noImplicitOverride",
|
|
887
|
-
"noImplicitReturns",
|
|
888
|
-
"noImplicitThis",
|
|
889
|
-
"noPropertyAccessFromIndexSignature",
|
|
890
|
-
"noUncheckedIndexedAccess",
|
|
891
|
-
"noUnusedLocals",
|
|
892
|
-
"noUnusedParameters",
|
|
893
|
-
"useUnknownInCatchVariables",
|
|
894
|
-
"declaration",
|
|
895
|
-
"declarationDir",
|
|
896
|
-
"declarationMap",
|
|
897
|
-
"downlevelIteration",
|
|
898
|
-
"emitBOM",
|
|
899
|
-
"emitDeclarationOnly",
|
|
900
|
-
"importHelpers",
|
|
901
|
-
"importsNotUsedAsValues",
|
|
902
|
-
"inlineSourceMap",
|
|
903
|
-
"inlineSources",
|
|
904
|
-
"mapRoot",
|
|
905
|
-
"newLine",
|
|
906
|
-
"noEmit",
|
|
907
|
-
"noEmitHelpers",
|
|
908
|
-
"noEmitOnError",
|
|
909
|
-
"outDir",
|
|
910
|
-
"outFile",
|
|
911
|
-
"preserveConstEnums",
|
|
912
|
-
"preserveValueImports",
|
|
913
|
-
"removeComments",
|
|
914
|
-
"sourceMap",
|
|
915
|
-
"sourceRoot",
|
|
916
|
-
"stripInternal",
|
|
917
|
-
"allowSyntheticDefaultImports",
|
|
918
|
-
"esModuleInterop",
|
|
919
|
-
"forceConsistentCasingInFileNames",
|
|
920
|
-
"isolatedModules",
|
|
921
|
-
"preserveSymlinks",
|
|
922
|
-
"verbatimModuleSyntax",
|
|
923
|
-
"skipDefaultLibCheck",
|
|
924
|
-
"skipLibCheck",
|
|
925
|
-
"paths"
|
|
926
|
-
]
|
|
927
|
-
},
|
|
928
|
-
{
|
|
929
|
-
pathPattern: "^compilerOptions\\.paths$",
|
|
930
|
-
order: { type: "asc" }
|
|
931
|
-
}
|
|
932
|
-
]
|
|
933
|
-
}
|
|
934
|
-
}],
|
|
935
|
-
(options?.test ?? true) && {
|
|
936
|
-
name: "so1ve/formatting/rules/test",
|
|
937
|
-
files: GLOB_TESTS,
|
|
938
|
-
rules: { "jest-formatting/padding-around-all": "error" }
|
|
939
|
-
}
|
|
940
|
-
].flat().filter(Boolean);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
//#endregion
|
|
944
|
-
//#region src/configs/html.ts
|
|
945
|
-
async function html() {
|
|
946
|
-
const [parserHtml, pluginHtml, pluginHtmlJsSupport] = await Promise.all([
|
|
947
|
-
interopDefault(import("@html-eslint/parser")),
|
|
948
|
-
interopDefault(import("@html-eslint/eslint-plugin")),
|
|
949
|
-
interopDefault(import("eslint-plugin-html"))
|
|
950
|
-
]);
|
|
951
|
-
return [{
|
|
952
|
-
name: "so1ve/html/setup",
|
|
953
|
-
plugins: {
|
|
954
|
-
"html": pluginHtml,
|
|
955
|
-
"html-js-support": pluginHtmlJsSupport
|
|
956
|
-
}
|
|
957
|
-
}, {
|
|
958
|
-
name: "so1ve/html/rules",
|
|
959
|
-
languageOptions: { parser: parserHtml },
|
|
960
|
-
settings: { "html/report-bad-indent": "off" },
|
|
961
|
-
files: [GLOB_HTML],
|
|
962
|
-
rules: {
|
|
963
|
-
...renameRules(pluginHtml.configs.recommended.rules, { "@html-eslint": "html" }),
|
|
964
|
-
"html/attrs-newline": "off",
|
|
965
|
-
"html/indent": "off",
|
|
966
|
-
"html/no-extra-spacing-attrs": "off",
|
|
967
|
-
"html/no-trailing-spaces": "off",
|
|
968
|
-
"html/quotes": "off",
|
|
969
|
-
"html/require-closing-tags": "off",
|
|
970
|
-
"so1ve/html-spaced-comment": "error",
|
|
971
|
-
"style/spaced-comment": "off"
|
|
972
|
-
}
|
|
973
|
-
}];
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
//#endregion
|
|
977
|
-
//#region src/configs/ignores.ts
|
|
978
|
-
function ignores(userIgnores = []) {
|
|
979
|
-
let ignores$1 = [...GLOB_EXCLUDE];
|
|
980
|
-
ignores$1 = typeof userIgnores === "function" ? userIgnores(ignores$1) : [...ignores$1, ...userIgnores];
|
|
981
|
-
return [{
|
|
982
|
-
name: "so1ve/ignores",
|
|
983
|
-
ignores: ignores$1
|
|
984
|
-
}];
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
//#endregion
|
|
988
|
-
//#region src/configs/imports.ts
|
|
989
|
-
const imports = (options = {}) => [
|
|
990
|
-
{
|
|
991
|
-
name: "so1ve/imports/setup",
|
|
992
|
-
plugins: {
|
|
993
|
-
"import": pluginImport,
|
|
994
|
-
"import-lite": pluginImportLite
|
|
995
|
-
}
|
|
996
|
-
},
|
|
997
|
-
{
|
|
998
|
-
name: "so1ve/imports/rules",
|
|
999
|
-
languageOptions: { parserOptions: {
|
|
1000
|
-
ecmaVersion: "latest",
|
|
1001
|
-
sourceType: "module"
|
|
1002
|
-
} },
|
|
1003
|
-
settings: {
|
|
1004
|
-
"import/parsers": {
|
|
1005
|
-
"espree": [
|
|
1006
|
-
".js",
|
|
1007
|
-
".cjs",
|
|
1008
|
-
".mjs",
|
|
1009
|
-
".jsx"
|
|
1010
|
-
],
|
|
1011
|
-
"@typescript-eslint/parser": [
|
|
1012
|
-
".ts",
|
|
1013
|
-
".mts",
|
|
1014
|
-
".cts",
|
|
1015
|
-
".tsx",
|
|
1016
|
-
".d.ts"
|
|
1017
|
-
]
|
|
1018
|
-
},
|
|
1019
|
-
"import/resolver": { ...options.typescript ? {
|
|
1020
|
-
node: { extensions: [
|
|
1021
|
-
".js",
|
|
1022
|
-
".jsx",
|
|
1023
|
-
".mjs",
|
|
1024
|
-
".ts",
|
|
1025
|
-
".tsx",
|
|
1026
|
-
".d.ts"
|
|
1027
|
-
] },
|
|
1028
|
-
typescript: { extensions: [
|
|
1029
|
-
".js",
|
|
1030
|
-
".jsx",
|
|
1031
|
-
".mjs",
|
|
1032
|
-
".ts",
|
|
1033
|
-
".tsx",
|
|
1034
|
-
".d.ts"
|
|
1035
|
-
] }
|
|
1036
|
-
} : { node: { extensions: [".js", ".mjs"] } } }
|
|
1037
|
-
},
|
|
1038
|
-
rules: {
|
|
1039
|
-
"import-lite/no-duplicates": "error",
|
|
1040
|
-
"import-lite/no-named-default": "error",
|
|
1041
|
-
"import/default": "error",
|
|
1042
|
-
"import/export": "error",
|
|
1043
|
-
"import/first": "error",
|
|
1044
|
-
"import/named": "error",
|
|
1045
|
-
"import/namespace": "off",
|
|
1046
|
-
"import/no-named-as-default": "error",
|
|
1047
|
-
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
|
|
1048
|
-
"import/no-webpack-loader-syntax": "error"
|
|
1049
|
-
}
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
name: "so1ve/imports/rules/dts",
|
|
1053
|
-
files: [GLOB_DTS],
|
|
1054
|
-
rules: { "import/no-duplicates": "off" }
|
|
1055
|
-
}
|
|
1056
|
-
];
|
|
1057
|
-
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region src/configs/javascript.ts
|
|
1060
|
-
async function javascript({ overrides } = {}) {
|
|
1061
|
-
const regexpRecommended = pluginRegexp.configs["flat/recommended"];
|
|
1062
|
-
return [
|
|
1063
|
-
{
|
|
1064
|
-
name: "so1ve/javascript/setup",
|
|
1065
|
-
plugins: {
|
|
1066
|
-
"array-func": pluginArrayFunc,
|
|
1067
|
-
"no-await-in-promise": pluginNoAwaitInPromise,
|
|
1068
|
-
"so1ve": pluginSo1ve,
|
|
1069
|
-
"unused-imports": pluginUnusedImports
|
|
1070
|
-
}
|
|
1071
|
-
},
|
|
1072
|
-
{
|
|
1073
|
-
name: "so1ve/javascript/rules",
|
|
1074
|
-
languageOptions: {
|
|
1075
|
-
ecmaVersion: "latest",
|
|
1076
|
-
globals: {
|
|
1077
|
-
...globals.browser,
|
|
1078
|
-
...globals.es2021,
|
|
1079
|
-
...globals.node,
|
|
1080
|
-
document: "readonly",
|
|
1081
|
-
navigator: "readonly",
|
|
1082
|
-
window: "readonly"
|
|
1083
|
-
},
|
|
1084
|
-
parserOptions: {
|
|
1085
|
-
ecmaFeatures: { jsx: true },
|
|
1086
|
-
ecmaVersion: "latest",
|
|
1087
|
-
sourceType: "module"
|
|
1088
|
-
},
|
|
1089
|
-
sourceType: "module"
|
|
1090
|
-
},
|
|
1091
|
-
linterOptions: { reportUnusedDisableDirectives: true },
|
|
1092
|
-
rules: {
|
|
1093
|
-
"accessor-pairs": ["error", {
|
|
1094
|
-
setWithoutGet: true,
|
|
1095
|
-
enforceForClassMembers: true
|
|
1096
|
-
}],
|
|
1097
|
-
"array-bracket-newline": "off",
|
|
1098
|
-
"array-callback-return": "error",
|
|
1099
|
-
"array-element-newline": "off",
|
|
1100
|
-
"array-func/avoid-reverse": "error",
|
|
1101
|
-
"array-func/from-map": "off",
|
|
1102
|
-
"array-func/no-unnecessary-this-arg": "off",
|
|
1103
|
-
"array-func/prefer-array-from": "off",
|
|
1104
|
-
"array-func/prefer-flat-map": "error",
|
|
1105
|
-
"array-func/prefer-flat": "off",
|
|
1106
|
-
"arrow-body-style": "off",
|
|
1107
|
-
"arrow-parens": "off",
|
|
1108
|
-
"block-scoped-var": "error",
|
|
1109
|
-
"complexity": ["off", 11],
|
|
1110
|
-
"consistent-return": "off",
|
|
1111
|
-
"constructor-super": "error",
|
|
1112
|
-
"default-case-last": "error",
|
|
1113
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
1114
|
-
"eqeqeq": ["error", "smart"],
|
|
1115
|
-
"function-call-argument-newline": "off",
|
|
1116
|
-
"function-paren-newline": "off",
|
|
1117
|
-
"generator-star": "off",
|
|
1118
|
-
"implicit-arrow-linebreak": "off",
|
|
1119
|
-
"indent-legacy": "off",
|
|
1120
|
-
"indent": "off",
|
|
1121
|
-
"jsx-quotes": "off",
|
|
1122
|
-
"linebreak-style": "off",
|
|
1123
|
-
"new-cap": ["error", {
|
|
1124
|
-
newIsCap: true,
|
|
1125
|
-
capIsNew: false,
|
|
1126
|
-
properties: true
|
|
1127
|
-
}],
|
|
1128
|
-
"newline-per-chained-call": "off",
|
|
1129
|
-
"no-alert": "error",
|
|
1130
|
-
"no-array-constructor": "error",
|
|
1131
|
-
"no-arrow-condition": "off",
|
|
1132
|
-
"no-async-promise-executor": "error",
|
|
1133
|
-
"no-await-in-promise/no-await-in-promise": "error",
|
|
1134
|
-
"no-caller": "error",
|
|
1135
|
-
"no-case-declarations": "error",
|
|
1136
|
-
"no-class-assign": "error",
|
|
1137
|
-
"no-comma-dangle": "off",
|
|
1138
|
-
"no-compare-neg-zero": "error",
|
|
1139
|
-
"no-cond-assign": ["error", "always"],
|
|
1140
|
-
"no-confusing-arrow": "off",
|
|
1141
|
-
"no-console": ["error", { allow: [
|
|
1142
|
-
"error",
|
|
1143
|
-
"warn",
|
|
1144
|
-
"table",
|
|
1145
|
-
"time"
|
|
1146
|
-
] }],
|
|
1147
|
-
"no-const-assign": "error",
|
|
1148
|
-
"no-constant-condition": "error",
|
|
1149
|
-
"no-control-regex": "error",
|
|
1150
|
-
"no-debugger": "error",
|
|
1151
|
-
"no-delete-var": "error",
|
|
1152
|
-
"no-dupe-args": "error",
|
|
1153
|
-
"no-dupe-class-members": "error",
|
|
1154
|
-
"no-dupe-keys": "error",
|
|
1155
|
-
"no-duplicate-case": "error",
|
|
1156
|
-
"no-empty-character-class": "error",
|
|
1157
|
-
"no-empty-pattern": "error",
|
|
1158
|
-
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
1159
|
-
"no-eval": "error",
|
|
1160
|
-
"no-ex-assign": "error",
|
|
1161
|
-
"no-extend-native": "error",
|
|
1162
|
-
"no-extra-bind": "error",
|
|
1163
|
-
"no-extra-boolean-cast": "error",
|
|
1164
|
-
"no-extra-semi": "off",
|
|
1165
|
-
"no-fallthrough": "error",
|
|
1166
|
-
"no-func-assign": "error",
|
|
1167
|
-
"no-global-assign": "error",
|
|
1168
|
-
"no-implied-eval": "error",
|
|
1169
|
-
"no-import-assign": "error",
|
|
1170
|
-
"no-invalid-regexp": "error",
|
|
1171
|
-
"no-invalid-this": "error",
|
|
1172
|
-
"no-irregular-whitespace": "error",
|
|
1173
|
-
"no-iterator": "error",
|
|
1174
|
-
"no-labels": ["error", {
|
|
1175
|
-
allowLoop: true,
|
|
1176
|
-
allowSwitch: false
|
|
1177
|
-
}],
|
|
1178
|
-
"no-lone-blocks": "error",
|
|
1179
|
-
"no-loss-of-precision": "error",
|
|
1180
|
-
"no-misleading-character-class": "error",
|
|
1181
|
-
"no-multi-str": "error",
|
|
1182
|
-
"no-new-func": "error",
|
|
1183
|
-
"no-new-native-nonconstructor": "error",
|
|
1184
|
-
"no-new-wrappers": "error",
|
|
1185
|
-
"no-obj-calls": "error",
|
|
1186
|
-
"no-object-constructor": "error",
|
|
1187
|
-
"no-octal-escape": "error",
|
|
1188
|
-
"no-octal": "error",
|
|
1189
|
-
"no-param-reassign": "off",
|
|
1190
|
-
"no-proto": "error",
|
|
1191
|
-
"no-prototype-builtins": "error",
|
|
1192
|
-
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
1193
|
-
"no-regex-spaces": "error",
|
|
1194
|
-
"no-reserved-keys": "off",
|
|
1195
|
-
"no-restricted-globals": [
|
|
1196
|
-
"error",
|
|
1197
|
-
{
|
|
1198
|
-
name: "global",
|
|
1199
|
-
message: "Use `globalThis` instead."
|
|
1200
|
-
},
|
|
1201
|
-
{
|
|
1202
|
-
name: "self",
|
|
1203
|
-
message: "Use `globalThis` instead."
|
|
1204
|
-
},
|
|
1205
|
-
{
|
|
1206
|
-
name: "isNaN",
|
|
1207
|
-
message: "Use `Number.isNaN` instead"
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
name: "isFinite",
|
|
1211
|
-
message: "Use `Number.isFinite` instead"
|
|
1212
|
-
},
|
|
1213
|
-
{
|
|
1214
|
-
name: "parseFloat",
|
|
1215
|
-
message: "Use `Number.parseFloat` instead"
|
|
1216
|
-
},
|
|
1217
|
-
{
|
|
1218
|
-
name: "parseInt",
|
|
1219
|
-
message: "Use `Number.parseInt` instead"
|
|
1220
|
-
}
|
|
1221
|
-
],
|
|
1222
|
-
"no-restricted-properties": [
|
|
1223
|
-
"error",
|
|
1224
|
-
{
|
|
1225
|
-
object: "globalThis",
|
|
1226
|
-
property: "isNaN",
|
|
1227
|
-
message: "Use `Number.isNaN` instead"
|
|
1228
|
-
},
|
|
1229
|
-
{
|
|
1230
|
-
object: "globalThis",
|
|
1231
|
-
property: "isFinite",
|
|
1232
|
-
message: "Use `Number.isFinite` instead"
|
|
1233
|
-
},
|
|
1234
|
-
{
|
|
1235
|
-
object: "globalThis",
|
|
1236
|
-
property: "parseFloat",
|
|
1237
|
-
message: "Use `Number.parseFloat` instead"
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
object: "globalThis",
|
|
1241
|
-
property: "parseInt",
|
|
1242
|
-
message: "Use `Number.parseInt` instead"
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
object: "window",
|
|
1246
|
-
property: "isNaN",
|
|
1247
|
-
message: "Use `Number.isNaN` instead"
|
|
1248
|
-
},
|
|
1249
|
-
{
|
|
1250
|
-
object: "window",
|
|
1251
|
-
property: "isFinite",
|
|
1252
|
-
message: "Use `Number.isFinite` instead"
|
|
1253
|
-
},
|
|
1254
|
-
{
|
|
1255
|
-
object: "window",
|
|
1256
|
-
property: "parseFloat",
|
|
1257
|
-
message: "Use `Number.parseFloat` instead"
|
|
1258
|
-
},
|
|
1259
|
-
{
|
|
1260
|
-
object: "window",
|
|
1261
|
-
property: "parseInt",
|
|
1262
|
-
message: "Use `Number.parseInt` instead"
|
|
1263
|
-
}
|
|
1264
|
-
],
|
|
1265
|
-
"no-restricted-syntax": [
|
|
1266
|
-
"error",
|
|
1267
|
-
"DebuggerStatement",
|
|
1268
|
-
"LabeledStatement",
|
|
1269
|
-
"WithStatement"
|
|
1270
|
-
],
|
|
1271
|
-
"no-return-await": "off",
|
|
1272
|
-
"no-self-assign": ["error", { props: true }],
|
|
1273
|
-
"no-self-compare": "error",
|
|
1274
|
-
"no-sequences": "error",
|
|
1275
|
-
"no-shadow-restricted-names": "error",
|
|
1276
|
-
"no-space-before-semi": "off",
|
|
1277
|
-
"no-spaced-func": "off",
|
|
1278
|
-
"no-template-curly-in-string": "error",
|
|
1279
|
-
"no-this-before-super": "error",
|
|
1280
|
-
"no-throw-literal": "error",
|
|
1281
|
-
"no-undef-init": "error",
|
|
1282
|
-
"no-undef": "error",
|
|
1283
|
-
"no-unexpected-multiline": "error",
|
|
1284
|
-
"no-unmodified-loop-condition": "error",
|
|
1285
|
-
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
1286
|
-
"no-unreachable-loop": "error",
|
|
1287
|
-
"no-unreachable": "error",
|
|
1288
|
-
"no-unsafe-finally": "error",
|
|
1289
|
-
"no-unsafe-negation": "error",
|
|
1290
|
-
"no-unused-expressions": ["error", {
|
|
1291
|
-
allowShortCircuit: true,
|
|
1292
|
-
allowTernary: true,
|
|
1293
|
-
allowTaggedTemplates: true
|
|
1294
|
-
}],
|
|
1295
|
-
"no-unused-vars": ["error", {
|
|
1296
|
-
args: "none",
|
|
1297
|
-
caughtErrors: "none",
|
|
1298
|
-
ignoreRestSiblings: true,
|
|
1299
|
-
vars: "all"
|
|
1300
|
-
}],
|
|
1301
|
-
"no-use-before-define": ["error", {
|
|
1302
|
-
functions: false,
|
|
1303
|
-
classes: false,
|
|
1304
|
-
variables: true
|
|
1305
|
-
}],
|
|
1306
|
-
"no-useless-backreference": "error",
|
|
1307
|
-
"no-useless-call": "error",
|
|
1308
|
-
"no-useless-catch": "error",
|
|
1309
|
-
"no-useless-computed-key": "error",
|
|
1310
|
-
"no-useless-constructor": "error",
|
|
1311
|
-
"no-useless-rename": "error",
|
|
1312
|
-
"no-useless-return": "error",
|
|
1313
|
-
"no-var": "error",
|
|
1314
|
-
"no-void": "error",
|
|
1315
|
-
"no-with": "error",
|
|
1316
|
-
"no-wrap-func": "off",
|
|
1317
|
-
"nonblock-statement-body-position": "off",
|
|
1318
|
-
"object-shorthand": [
|
|
1319
|
-
"error",
|
|
1320
|
-
"always",
|
|
1321
|
-
{ ignoreConstructors: false }
|
|
1322
|
-
],
|
|
1323
|
-
"one-var-declaration-per-line": "off",
|
|
1324
|
-
"one-var": ["error", "never"],
|
|
1325
|
-
"prefer-arrow-callback": ["error", {
|
|
1326
|
-
allowNamedFunctions: false,
|
|
1327
|
-
allowUnboundThis: true
|
|
1328
|
-
}],
|
|
1329
|
-
"prefer-const": ["error", {
|
|
1330
|
-
destructuring: "all",
|
|
1331
|
-
ignoreReadBeforeAssign: true
|
|
1332
|
-
}],
|
|
1333
|
-
"prefer-exponentiation-operator": "error",
|
|
1334
|
-
"prefer-promise-reject-errors": "error",
|
|
1335
|
-
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
1336
|
-
"prefer-rest-params": "error",
|
|
1337
|
-
"prefer-spread": "error",
|
|
1338
|
-
"prefer-template": "error",
|
|
1339
|
-
"require-await": "off",
|
|
1340
|
-
"so1ve/import-dedupe": "error",
|
|
1341
|
-
"so1ve/require-async-with-await": "error",
|
|
1342
|
-
"switch-colon-spacing": "off",
|
|
1343
|
-
"symbol-description": "off",
|
|
1344
|
-
"unused-imports/no-unused-imports": "error",
|
|
1345
|
-
"unused-imports/no-unused-vars": ["error", {
|
|
1346
|
-
vars: "all",
|
|
1347
|
-
varsIgnorePattern: "^_",
|
|
1348
|
-
args: "after-used",
|
|
1349
|
-
argsIgnorePattern: "^_",
|
|
1350
|
-
ignoreRestSiblings: true
|
|
1351
|
-
}],
|
|
1352
|
-
"use-isnan": ["error", {
|
|
1353
|
-
enforceForSwitchCase: true,
|
|
1354
|
-
enforceForIndexOf: true
|
|
1355
|
-
}],
|
|
1356
|
-
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
1357
|
-
"vars-on-top": "error",
|
|
1358
|
-
"wrap-regex": "off",
|
|
1359
|
-
"yoda": ["error", "never"],
|
|
1360
|
-
...overrides
|
|
1361
|
-
}
|
|
1362
|
-
},
|
|
1363
|
-
{
|
|
1364
|
-
...regexpRecommended,
|
|
1365
|
-
name: "so1ve/javascript/regexp",
|
|
1366
|
-
rules: {
|
|
1367
|
-
...regexpRecommended.rules,
|
|
1368
|
-
"regexp/no-unused-capturing-group": "off"
|
|
1369
|
-
}
|
|
1370
|
-
},
|
|
1371
|
-
{
|
|
1372
|
-
name: "so1ve/javascript/cli",
|
|
1373
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
1374
|
-
rules: { "no-console": "off" }
|
|
1375
|
-
}
|
|
1376
|
-
];
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
//#endregion
|
|
1380
|
-
//#region src/configs/jsonc.ts
|
|
1381
|
-
async function jsonc() {
|
|
1382
|
-
const [parserJsonc, pluginJsonc] = await Promise.all([interopDefault(import("jsonc-eslint-parser")), interopDefault(import("eslint-plugin-jsonc"))]);
|
|
1383
|
-
return [{
|
|
1384
|
-
name: "so1ve/jsonc/setup",
|
|
1385
|
-
plugins: { jsonc: pluginJsonc }
|
|
1386
|
-
}, {
|
|
1387
|
-
name: "so1ve/jsonc/rules",
|
|
1388
|
-
files: [
|
|
1389
|
-
GLOB_JSON,
|
|
1390
|
-
GLOB_JSON5,
|
|
1391
|
-
GLOB_JSONC,
|
|
1392
|
-
GLOB_ESLINTRC
|
|
1393
|
-
],
|
|
1394
|
-
languageOptions: { parser: parserJsonc },
|
|
1395
|
-
rules: {
|
|
1396
|
-
...pluginJsonc.configs.base.overrides[0].rules,
|
|
1397
|
-
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
1398
|
-
"jsonc/no-octal-escape": "error",
|
|
1399
|
-
"jsonc/quotes-props": "off",
|
|
1400
|
-
"jsonc/quotes": "off"
|
|
1401
|
-
}
|
|
1402
|
-
}];
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
//#endregion
|
|
1406
|
-
//#region src/configs/mdx.ts
|
|
1407
|
-
async function mdx({ componentExts = [], overrides } = {}) {
|
|
1408
|
-
const pluginMdx = await interopDefault(import("eslint-plugin-mdx"));
|
|
1409
|
-
return [{
|
|
1410
|
-
...pluginMdx.flat,
|
|
1411
|
-
name: "so1ve/mdx/setup",
|
|
1412
|
-
processor: pluginMdx.createRemarkProcessor({
|
|
1413
|
-
lintCodeBlocks: true,
|
|
1414
|
-
languageMapper: {}
|
|
1415
|
-
})
|
|
1416
|
-
}, {
|
|
1417
|
-
...pluginMdx.flatCodeBlocks,
|
|
1418
|
-
name: "so1ve/mdx/rules",
|
|
1419
|
-
files: [...pluginMdx.flatCodeBlocks.files, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/*.${ext}`)],
|
|
1420
|
-
rules: {
|
|
1421
|
-
...pluginMdx.flatCodeBlocks.rules,
|
|
1422
|
-
"html/require-doctype": "off",
|
|
1423
|
-
"import/no-unresolved": "off",
|
|
1424
|
-
"no-alert": "off",
|
|
1425
|
-
"no-console": "off",
|
|
1426
|
-
"no-restricted-imports": "off",
|
|
1427
|
-
"no-undef": "off",
|
|
1428
|
-
"no-unused-expressions": "off",
|
|
1429
|
-
"ts/consistent-type-imports": "off",
|
|
1430
|
-
"ts/no-namespace": "off",
|
|
1431
|
-
"ts/no-redeclare": "off",
|
|
1432
|
-
"ts/no-require-imports": "off",
|
|
1433
|
-
"ts/no-unused-expressions": "off",
|
|
1434
|
-
"ts/no-unused-vars": "off",
|
|
1435
|
-
"ts/no-use-before-define": "off",
|
|
1436
|
-
"ts/no-var-requires": "off",
|
|
1437
|
-
"unused-imports/no-unused-imports": "off",
|
|
1438
|
-
"unused-imports/no-unused-vars": "off",
|
|
1439
|
-
...overrides
|
|
1440
|
-
}
|
|
1441
|
-
}];
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
//#endregion
|
|
1445
|
-
//#region src/configs/node.ts
|
|
1446
|
-
const node = () => [{
|
|
1447
|
-
name: "so1ve/node/setup",
|
|
1448
|
-
plugins: { node: pluginNode }
|
|
1449
|
-
}, {
|
|
1450
|
-
name: "so1ve/node/rules",
|
|
1451
|
-
rules: {
|
|
1452
|
-
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1453
|
-
"node/no-callback-literal": "off",
|
|
1454
|
-
"node/no-deprecated-api": "error",
|
|
1455
|
-
"node/no-exports-assign": "error",
|
|
1456
|
-
"node/no-new-require": "error",
|
|
1457
|
-
"node/no-path-concat": "error",
|
|
1458
|
-
"node/process-exit-as-throw": "error"
|
|
1459
|
-
}
|
|
1460
|
-
}];
|
|
1461
|
-
|
|
1462
|
-
//#endregion
|
|
1463
|
-
//#region src/configs/only-error.ts
|
|
1464
|
-
const onlyError = () => [{
|
|
1465
|
-
name: "so1ve/only-error",
|
|
1466
|
-
plugins: { "only-error": pluginOnlyError }
|
|
1467
|
-
}];
|
|
1468
|
-
|
|
1469
|
-
//#endregion
|
|
1470
|
-
//#region src/configs/perfectionist.ts
|
|
1471
|
-
async function perfectionist() {
|
|
1472
|
-
return [{
|
|
1473
|
-
name: "so1ve/perfectionist/setup",
|
|
1474
|
-
plugins: { perfectionist: await interopDefault(import("eslint-plugin-perfectionist")) }
|
|
1475
|
-
}, {
|
|
1476
|
-
name: "so1ve/perfectionist/rules",
|
|
1477
|
-
rules: {
|
|
1478
|
-
"perfectionist/sort-array-includes": ["error", {
|
|
1479
|
-
ignoreCase: false,
|
|
1480
|
-
partitionByComment: true,
|
|
1481
|
-
partitionByNewLine: true,
|
|
1482
|
-
type: "natural"
|
|
1483
|
-
}],
|
|
1484
|
-
"perfectionist/sort-decorators": ["error", { type: "natural" }],
|
|
1485
|
-
"perfectionist/sort-heritage-clauses": ["error", { type: "natural" }],
|
|
1486
|
-
"perfectionist/sort-maps": ["error", {
|
|
1487
|
-
partitionByComment: true,
|
|
1488
|
-
partitionByNewLine: true,
|
|
1489
|
-
type: "natural"
|
|
1490
|
-
}],
|
|
1491
|
-
"perfectionist/sort-sets": ["error", {
|
|
1492
|
-
partitionByComment: true,
|
|
1493
|
-
partitionByNewLine: true,
|
|
1494
|
-
type: "natural"
|
|
1495
|
-
}]
|
|
1496
|
-
}
|
|
1497
|
-
}];
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
//#endregion
|
|
1501
|
-
//#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
1502
|
-
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
1503
|
-
function findUpSync(name$1, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
|
|
1504
|
-
let directory = path.resolve(toPath(cwd) ?? "");
|
|
1505
|
-
const { root } = path.parse(directory);
|
|
1506
|
-
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
1507
|
-
const isAbsoluteName = path.isAbsolute(name$1);
|
|
1508
|
-
while (directory) {
|
|
1509
|
-
const filePath = isAbsoluteName ? name$1 : path.join(directory, name$1);
|
|
1510
|
-
try {
|
|
1511
|
-
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
1512
|
-
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
1513
|
-
} catch {}
|
|
1514
|
-
if (directory === stopAt || directory === root) break;
|
|
1515
|
-
directory = path.dirname(directory);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
//#endregion
|
|
1520
|
-
//#region src/configs/pnpm.ts
|
|
1521
|
-
async function pnpm(options) {
|
|
1522
|
-
const { json = true, yaml: yaml$1 = true } = options;
|
|
1523
|
-
const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
1524
|
-
interopDefault(import("eslint-plugin-pnpm")),
|
|
1525
|
-
yaml$1 ? interopDefault(import("yaml-eslint-parser")) : void 0,
|
|
1526
|
-
json ? interopDefault(import("jsonc-eslint-parser")) : void 0
|
|
1527
|
-
]);
|
|
1528
|
-
const configs$1 = [];
|
|
1529
|
-
if (json) configs$1.push({
|
|
1530
|
-
files: ["package.json", "**/package.json"],
|
|
1531
|
-
languageOptions: { parser: jsoncParser },
|
|
1532
|
-
name: "so1ve/pnpm/package-json",
|
|
1533
|
-
plugins: { pnpm: pluginPnpm },
|
|
1534
|
-
rules: { "pnpm/json-prefer-workspace-settings": "error" }
|
|
1535
|
-
});
|
|
1536
|
-
if (yaml$1) configs$1.push({
|
|
1537
|
-
files: ["pnpm-workspace.yaml"],
|
|
1538
|
-
languageOptions: { parser: yamlParser },
|
|
1539
|
-
name: "so1ve/pnpm/pnpm-workspace-yaml",
|
|
1540
|
-
plugins: { pnpm: pluginPnpm },
|
|
1541
|
-
rules: { "pnpm/yaml-enforce-settings": ["error", { settings: { shellEmulator: true } }] }
|
|
1542
|
-
}, {
|
|
1543
|
-
files: ["pnpm-workspace.yaml"],
|
|
1544
|
-
name: "so1ve/yaml/pnpm-workspace-yaml-sort",
|
|
1545
|
-
rules: { "yaml/sort-keys": [
|
|
1546
|
-
"error",
|
|
1547
|
-
{
|
|
1548
|
-
order: [
|
|
1549
|
-
...[
|
|
1550
|
-
"cacheDir",
|
|
1551
|
-
"catalogMode",
|
|
1552
|
-
"cleanupUnusedCatalogs",
|
|
1553
|
-
"dedupeDirectDeps",
|
|
1554
|
-
"deployAllFiles",
|
|
1555
|
-
"enablePrePostScripts",
|
|
1556
|
-
"engineStrict",
|
|
1557
|
-
"extendNodePath",
|
|
1558
|
-
"hoist",
|
|
1559
|
-
"hoistPattern",
|
|
1560
|
-
"hoistWorkspacePackages",
|
|
1561
|
-
"ignoreCompatibilityDb",
|
|
1562
|
-
"ignoreDepScripts",
|
|
1563
|
-
"ignoreScripts",
|
|
1564
|
-
"ignoreWorkspaceRootCheck",
|
|
1565
|
-
"managePackageManagerVersions",
|
|
1566
|
-
"minimumReleaseAge",
|
|
1567
|
-
"minimumReleaseAgeExclude",
|
|
1568
|
-
"modulesDir",
|
|
1569
|
-
"nodeLinker",
|
|
1570
|
-
"nodeVersion",
|
|
1571
|
-
"optimisticRepeatInstall",
|
|
1572
|
-
"packageManagerStrict",
|
|
1573
|
-
"packageManagerStrictVersion",
|
|
1574
|
-
"preferSymlinkedExecutables",
|
|
1575
|
-
"preferWorkspacePackages",
|
|
1576
|
-
"publicHoistPattern",
|
|
1577
|
-
"registrySupportsTimeField",
|
|
1578
|
-
"requiredScripts",
|
|
1579
|
-
"resolutionMode",
|
|
1580
|
-
"savePrefix",
|
|
1581
|
-
"scriptShell",
|
|
1582
|
-
"shamefullyHoist",
|
|
1583
|
-
"shellEmulator",
|
|
1584
|
-
"stateDir",
|
|
1585
|
-
"supportedArchitectures",
|
|
1586
|
-
"symlink",
|
|
1587
|
-
"tag",
|
|
1588
|
-
"trustPolicy",
|
|
1589
|
-
"trustPolicyExclude",
|
|
1590
|
-
"updateNotifier"
|
|
1591
|
-
],
|
|
1592
|
-
"packages",
|
|
1593
|
-
"overrides",
|
|
1594
|
-
"patchedDependencies",
|
|
1595
|
-
...[
|
|
1596
|
-
"allowedDeprecatedVersions",
|
|
1597
|
-
"allowNonAppliedPatches",
|
|
1598
|
-
"configDependencies",
|
|
1599
|
-
"ignoredBuiltDependencies",
|
|
1600
|
-
"ignoredOptionalDependencies",
|
|
1601
|
-
"neverBuiltDependencies",
|
|
1602
|
-
"onlyBuiltDependencies",
|
|
1603
|
-
"onlyBuiltDependenciesFile",
|
|
1604
|
-
"packageExtensions",
|
|
1605
|
-
"peerDependencyRules"
|
|
1606
|
-
],
|
|
1607
|
-
"catalog",
|
|
1608
|
-
"catalogs"
|
|
1609
|
-
],
|
|
1610
|
-
pathPattern: "^$"
|
|
1611
|
-
},
|
|
1612
|
-
{
|
|
1613
|
-
order: { type: "asc" },
|
|
1614
|
-
pathPattern: ".*"
|
|
1615
|
-
}
|
|
1616
|
-
] }
|
|
1617
|
-
});
|
|
1618
|
-
return configs$1;
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
//#endregion
|
|
1622
|
-
//#region src/configs/promise.ts
|
|
1623
|
-
const promise = () => [{
|
|
1624
|
-
name: "so1ve/promise/setup",
|
|
1625
|
-
plugins: { promise: pluginPromise }
|
|
1626
|
-
}, {
|
|
1627
|
-
name: "so1ve/promise/rules",
|
|
1628
|
-
rules: { "promise/param-names": "error" }
|
|
1629
|
-
}];
|
|
1630
|
-
|
|
1631
|
-
//#endregion
|
|
1632
|
-
//#region src/configs/solid.ts
|
|
1633
|
-
async function solid({ overrides, typescript: typescript$1 } = {}) {
|
|
1634
|
-
const pluginSolid = await interopDefault(import("eslint-plugin-solid"));
|
|
1635
|
-
return [{
|
|
1636
|
-
name: "so1ve/solid/setup",
|
|
1637
|
-
plugins: { solid: pluginSolid }
|
|
1638
|
-
}, {
|
|
1639
|
-
name: "so1ve/solid/rules",
|
|
1640
|
-
languageOptions: {
|
|
1641
|
-
sourceType: "module",
|
|
1642
|
-
parserOptions: { ecmaFeatures: { jsx: true } }
|
|
1643
|
-
},
|
|
1644
|
-
rules: {
|
|
1645
|
-
...pluginSolid.configs.recommended.rules,
|
|
1646
|
-
...typescript$1 ? pluginSolid.configs.typescript.rules : {},
|
|
1647
|
-
...overrides
|
|
1648
|
-
}
|
|
1649
|
-
}];
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
//#endregion
|
|
1653
|
-
//#region src/configs/sort-imports.ts
|
|
1654
|
-
const sortImports = () => [{
|
|
1655
|
-
name: "so1ve/sort-imports/rules",
|
|
1656
|
-
rules: {
|
|
1657
|
-
"so1ve/sort-imports": "error",
|
|
1658
|
-
"so1ve/sort-exports": "error"
|
|
1659
|
-
}
|
|
1660
|
-
}];
|
|
1661
|
-
|
|
1662
|
-
//#endregion
|
|
1663
|
-
//#region src/configs/test.ts
|
|
1664
|
-
async function test({ overrides } = {}) {
|
|
1665
|
-
const [pluginNoOnlyTests, pluginVitest, pluginJestFormatting] = await Promise.all([
|
|
1666
|
-
interopDefault(import("eslint-plugin-no-only-tests")),
|
|
1667
|
-
interopDefault(import("@vitest/eslint-plugin")),
|
|
1668
|
-
interopDefault(import("eslint-plugin-jest-formatting"))
|
|
1669
|
-
]);
|
|
1670
|
-
return [{
|
|
1671
|
-
name: "so1ve/test/setup",
|
|
1672
|
-
plugins: {
|
|
1673
|
-
"jest-formatting": pluginJestFormatting,
|
|
1674
|
-
"no-only-tests": pluginNoOnlyTests,
|
|
1675
|
-
"vitest": pluginVitest
|
|
1676
|
-
}
|
|
1677
|
-
}, {
|
|
1678
|
-
name: "so1ve/test/rules",
|
|
1679
|
-
files: GLOB_TESTS,
|
|
1680
|
-
rules: {
|
|
1681
|
-
...pluginVitest.configs.recommended.rules,
|
|
1682
|
-
"no-only-tests/no-only-tests": "error",
|
|
1683
|
-
"vitest/expect-expect": "off",
|
|
1684
|
-
"vitest/no-alias-methods": "error",
|
|
1685
|
-
"vitest/no-interpolation-in-snapshots": "error",
|
|
1686
|
-
"vitest/no-test-prefixes": "error",
|
|
1687
|
-
"vitest/prefer-comparison-matcher": "error",
|
|
1688
|
-
"vitest/prefer-expect-resolves": "error",
|
|
1689
|
-
"vitest/prefer-mock-promise-shorthand": "error",
|
|
1690
|
-
"vitest/prefer-spy-on": "error",
|
|
1691
|
-
"vitest/prefer-to-be-falsy": "error",
|
|
1692
|
-
"vitest/prefer-to-be-object": "error",
|
|
1693
|
-
"vitest/prefer-to-be-truthy": "error",
|
|
1694
|
-
"vitest/prefer-to-contain": "error",
|
|
1695
|
-
"vitest/prefer-to-have-length": "error",
|
|
1696
|
-
"vitest/prefer-todo": "error",
|
|
1697
|
-
"vitest/valid-describe-callback": "off",
|
|
1698
|
-
"vitest/valid-title": "off",
|
|
1699
|
-
...overrides
|
|
1700
|
-
}
|
|
1701
|
-
}];
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
//#endregion
|
|
1705
|
-
//#region src/configs/toml.ts
|
|
1706
|
-
async function toml({ overrides } = {}) {
|
|
1707
|
-
const [parserToml, pluginToml] = await Promise.all([interopDefault(import("toml-eslint-parser")), interopDefault(import("eslint-plugin-toml"))]);
|
|
1708
|
-
return [{
|
|
1709
|
-
name: "so1ve/toml/setup",
|
|
1710
|
-
plugins: { toml: pluginToml }
|
|
1711
|
-
}, {
|
|
1712
|
-
name: "so1ve/toml/rules",
|
|
1713
|
-
languageOptions: { parser: parserToml },
|
|
1714
|
-
files: [GLOB_TOML],
|
|
1715
|
-
rules: {
|
|
1716
|
-
...pluginToml.configs.recommended.rules,
|
|
1717
|
-
"no-irregular-whitespace": "off",
|
|
1718
|
-
"style/spaced-comment": "off",
|
|
1719
|
-
...overrides
|
|
1720
|
-
}
|
|
1721
|
-
}];
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
//#endregion
|
|
1725
|
-
//#region src/configs/typescript.ts
|
|
1726
|
-
const typescript = async ({ componentExts = [], parserOptions, overrides } = {}) => [
|
|
1727
|
-
{
|
|
1728
|
-
name: "so1ve/typescript/setup",
|
|
1729
|
-
plugins: {
|
|
1730
|
-
import: pluginImport,
|
|
1731
|
-
ts: tseslint.plugin
|
|
1732
|
-
}
|
|
1733
|
-
},
|
|
1734
|
-
{
|
|
1735
|
-
name: "so1ve/typescript/rules",
|
|
1736
|
-
files: [
|
|
1737
|
-
GLOB_TS,
|
|
1738
|
-
GLOB_TSX,
|
|
1739
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1740
|
-
],
|
|
1741
|
-
languageOptions: {
|
|
1742
|
-
parser: tseslint.parser,
|
|
1743
|
-
parserOptions: {
|
|
1744
|
-
sourceType: "module",
|
|
1745
|
-
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1746
|
-
...parserOptions
|
|
1747
|
-
}
|
|
1748
|
-
},
|
|
1749
|
-
settings: { "import/resolver": {
|
|
1750
|
-
node: { extensions: [
|
|
1751
|
-
".js",
|
|
1752
|
-
".jsx",
|
|
1753
|
-
".mjs",
|
|
1754
|
-
".ts",
|
|
1755
|
-
".tsx",
|
|
1756
|
-
".d.ts"
|
|
1757
|
-
] },
|
|
1758
|
-
typescript: { extensions: [
|
|
1759
|
-
".js",
|
|
1760
|
-
".jsx",
|
|
1761
|
-
".mjs",
|
|
1762
|
-
".ts",
|
|
1763
|
-
".tsx",
|
|
1764
|
-
".d.ts"
|
|
1765
|
-
] }
|
|
1766
|
-
} },
|
|
1767
|
-
rules: {
|
|
1768
|
-
...renameRules(tseslint.configs.eslintRecommended.rules, { "@typescript-eslint": "ts" }),
|
|
1769
|
-
...renameRules(tseslint.configs.recommended.map((config) => config.rules).filter(Boolean).reduce((a, b) => ({
|
|
1770
|
-
...a,
|
|
1771
|
-
...b
|
|
1772
|
-
}), {}), { "@typescript-eslint": "ts" }),
|
|
1773
|
-
"import/named": "off",
|
|
1774
|
-
"no-dupe-class-members": "off",
|
|
1775
|
-
"no-invalid-this": "off",
|
|
1776
|
-
"no-redeclare": "off",
|
|
1777
|
-
"no-use-before-define": "off",
|
|
1778
|
-
"no-useless-constructor": "off",
|
|
1779
|
-
"object-curly-spacing": "off",
|
|
1780
|
-
"so1ve/no-inline-type-modifier": "error",
|
|
1781
|
-
"so1ve/prefer-ts-expect-error": "error",
|
|
1782
|
-
"space-before-blocks": "off",
|
|
1783
|
-
"space-before-function-paren": "off",
|
|
1784
|
-
"ts/ban-ts-comment": ["error", { minimumDescriptionLength: 0 }],
|
|
1785
|
-
"ts/ban-ts-ignore": "off",
|
|
1786
|
-
"ts/brace-style": "off",
|
|
1787
|
-
"ts/camelcase": "off",
|
|
1788
|
-
"ts/comma-dangle": "off",
|
|
1789
|
-
"ts/comma-spacing": "off",
|
|
1790
|
-
"ts/consistent-indexed-object-style": ["error", "record"],
|
|
1791
|
-
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1792
|
-
"ts/consistent-type-imports": ["error", {
|
|
1793
|
-
disallowTypeAnnotations: false,
|
|
1794
|
-
prefer: "type-imports"
|
|
1795
|
-
}],
|
|
1796
|
-
"ts/explicit-function-return-type": "off",
|
|
1797
|
-
"ts/explicit-member-accessibility": ["error", {
|
|
1798
|
-
accessibility: "explicit",
|
|
1799
|
-
overrides: { constructors: "no-public" }
|
|
1800
|
-
}],
|
|
1801
|
-
"ts/explicit-module-boundary-types": "off",
|
|
1802
|
-
"ts/func-call-spacing": "off",
|
|
1803
|
-
"ts/indent": "off",
|
|
1804
|
-
"ts/keyword-spacing": "off",
|
|
1805
|
-
"ts/member-delimiter-style": "off",
|
|
1806
|
-
"ts/method-signature-style": ["error", "property"],
|
|
1807
|
-
"ts/no-dupe-class-members": "error",
|
|
1808
|
-
"ts/no-duplicate-enum-values": "error",
|
|
1809
|
-
"ts/no-empty-function": "off",
|
|
1810
|
-
"ts/no-empty-interface": "off",
|
|
1811
|
-
"ts/no-empty-object-type": "off",
|
|
1812
|
-
"ts/no-explicit-any": "off",
|
|
1813
|
-
"ts/no-extra-semi": "off",
|
|
1814
|
-
"ts/no-invalid-this": "error",
|
|
1815
|
-
"ts/no-non-null-asserted-nullish-coalescing": "error",
|
|
1816
|
-
"ts/no-non-null-assertion": "off",
|
|
1817
|
-
"ts/no-parameter-properties": "off",
|
|
1818
|
-
"ts/no-redeclare": "error",
|
|
1819
|
-
"ts/no-require-imports": "error",
|
|
1820
|
-
"ts/no-restricted-types": ["error", { types: {
|
|
1821
|
-
String: {
|
|
1822
|
-
message: "Use `string` instead.",
|
|
1823
|
-
fixWith: "string"
|
|
1824
|
-
},
|
|
1825
|
-
Number: {
|
|
1826
|
-
message: "Use `number` instead.",
|
|
1827
|
-
fixWith: "number"
|
|
1828
|
-
},
|
|
1829
|
-
Boolean: {
|
|
1830
|
-
message: "Use `boolean` instead.",
|
|
1831
|
-
fixWith: "boolean"
|
|
1832
|
-
},
|
|
1833
|
-
Symbol: {
|
|
1834
|
-
message: "Use `symbol` instead.",
|
|
1835
|
-
fixWith: "symbol"
|
|
1836
|
-
},
|
|
1837
|
-
BigInt: {
|
|
1838
|
-
message: "Use `bigint` instead.",
|
|
1839
|
-
fixWith: "bigint"
|
|
1840
|
-
},
|
|
1841
|
-
Function: {
|
|
1842
|
-
message: "Use `(...args: any[]) => any` instead.",
|
|
1843
|
-
fixWith: "(...args: any[]) => any"
|
|
1844
|
-
}
|
|
1845
|
-
} }],
|
|
1846
|
-
"ts/no-unsafe-function-type": "error",
|
|
1847
|
-
"ts/no-unused-vars": "off",
|
|
1848
|
-
"ts/no-use-before-define": ["error", {
|
|
1849
|
-
functions: false,
|
|
1850
|
-
classes: false,
|
|
1851
|
-
variables: true
|
|
1852
|
-
}],
|
|
1853
|
-
"ts/no-wrapper-object-types": "error",
|
|
1854
|
-
"ts/prefer-for-of": "error",
|
|
1855
|
-
"ts/quotes": "off",
|
|
1856
|
-
"ts/semi": "off",
|
|
1857
|
-
"ts/space-before-blocks": "off",
|
|
1858
|
-
"ts/space-before-function-paren": "off",
|
|
1859
|
-
"ts/triple-slash-reference": "off",
|
|
1860
|
-
"ts/type-annotation-spacing": "off",
|
|
1861
|
-
...overrides
|
|
1862
|
-
}
|
|
1863
|
-
},
|
|
1864
|
-
{
|
|
1865
|
-
name: "so1ve/typescript/rules/type-aware",
|
|
1866
|
-
files: [
|
|
1867
|
-
GLOB_TS,
|
|
1868
|
-
GLOB_TSX,
|
|
1869
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1870
|
-
],
|
|
1871
|
-
ignores: [GLOB_MARKDOWN_CODE, GLOB_ASTRO_TS],
|
|
1872
|
-
languageOptions: {
|
|
1873
|
-
parser: tseslint.parser,
|
|
1874
|
-
parserOptions: {
|
|
1875
|
-
sourceType: "module",
|
|
1876
|
-
projectService: true,
|
|
1877
|
-
tsconfigRootDir: process.cwd()
|
|
1878
|
-
}
|
|
1879
|
-
},
|
|
1880
|
-
settings: { "import/resolver": {
|
|
1881
|
-
node: { extensions: [
|
|
1882
|
-
".js",
|
|
1883
|
-
".jsx",
|
|
1884
|
-
".mjs",
|
|
1885
|
-
".ts",
|
|
1886
|
-
".tsx",
|
|
1887
|
-
".d.ts"
|
|
1888
|
-
] },
|
|
1889
|
-
typescript: { extensions: [
|
|
1890
|
-
".js",
|
|
1891
|
-
".jsx",
|
|
1892
|
-
".mjs",
|
|
1893
|
-
".ts",
|
|
1894
|
-
".tsx",
|
|
1895
|
-
".d.ts"
|
|
1896
|
-
] }
|
|
1897
|
-
} },
|
|
1898
|
-
rules: {
|
|
1899
|
-
"dot-notation": "off",
|
|
1900
|
-
"no-implied-eval": "off",
|
|
1901
|
-
"no-throw-literal": "off",
|
|
1902
|
-
"no-void": ["error", { allowAsStatement: true }],
|
|
1903
|
-
"ts/array-type": ["error", {
|
|
1904
|
-
default: "array",
|
|
1905
|
-
readonly: "array"
|
|
1906
|
-
}],
|
|
1907
|
-
"ts/await-thenable": "error",
|
|
1908
|
-
"ts/consistent-generic-constructors": "error",
|
|
1909
|
-
"ts/consistent-type-assertions": ["error", {
|
|
1910
|
-
assertionStyle: "as",
|
|
1911
|
-
objectLiteralTypeAssertions: "allow"
|
|
1912
|
-
}],
|
|
1913
|
-
"ts/consistent-type-exports": "error",
|
|
1914
|
-
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1915
|
-
"ts/no-for-in-array": "error",
|
|
1916
|
-
"ts/no-implied-eval": "error",
|
|
1917
|
-
"ts/no-unnecessary-type-arguments": "error",
|
|
1918
|
-
"ts/no-unnecessary-type-assertion": "error",
|
|
1919
|
-
"ts/non-nullable-type-assertion-style": "error",
|
|
1920
|
-
"ts/only-throw-error": "error",
|
|
1921
|
-
"ts/prefer-nullish-coalescing": "error",
|
|
1922
|
-
"ts/prefer-optional-chain": "error",
|
|
1923
|
-
"ts/prefer-return-this-type": "error",
|
|
1924
|
-
"ts/restrict-template-expressions": ["error", {
|
|
1925
|
-
allowAny: true,
|
|
1926
|
-
allowNumber: true,
|
|
1927
|
-
allowBoolean: true
|
|
1928
|
-
}]
|
|
1929
|
-
}
|
|
1930
|
-
},
|
|
1931
|
-
{
|
|
1932
|
-
name: "so1ve/typescript/rules/dts",
|
|
1933
|
-
files: ["**/*.d.ts"],
|
|
1934
|
-
rules: {
|
|
1935
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
1936
|
-
"import/no-duplicates": "off",
|
|
1937
|
-
"unused-imports/no-unused-vars": "off"
|
|
1938
|
-
}
|
|
1939
|
-
},
|
|
1940
|
-
{
|
|
1941
|
-
name: "so1ve/typescript/rules/js",
|
|
1942
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
1943
|
-
rules: {
|
|
1944
|
-
"ts/no-require-imports": "off",
|
|
1945
|
-
"ts/no-var-requires": "off"
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
];
|
|
1949
|
-
|
|
1950
|
-
//#endregion
|
|
1951
|
-
//#region src/configs/unicorn.ts
|
|
1952
|
-
const unicorn = () => [{
|
|
1953
|
-
name: "so1ve/unicorn/setup",
|
|
1954
|
-
plugins: { unicorn: pluginUnicorn }
|
|
1955
|
-
}, {
|
|
1956
|
-
name: "so1ve/unicorn/rules",
|
|
1957
|
-
rules: {
|
|
1958
|
-
"unicorn/consistent-assert": "error",
|
|
1959
|
-
"unicorn/consistent-date-clone": "error",
|
|
1960
|
-
"unicorn/consistent-empty-array-spread": "error",
|
|
1961
|
-
"unicorn/consistent-existence-index-check": "error",
|
|
1962
|
-
"unicorn/error-message": "error",
|
|
1963
|
-
"unicorn/escape-case": "error",
|
|
1964
|
-
"unicorn/explicit-length-check": "error",
|
|
1965
|
-
"unicorn/new-for-builtins": "error",
|
|
1966
|
-
"unicorn/no-array-for-each": "error",
|
|
1967
|
-
"unicorn/no-await-in-promise-methods": "error",
|
|
1968
|
-
"unicorn/no-for-loop": "error",
|
|
1969
|
-
"unicorn/no-instanceof-builtins": "error",
|
|
1970
|
-
"unicorn/no-lonely-if": "error",
|
|
1971
|
-
"unicorn/no-negated-condition": "error",
|
|
1972
|
-
"unicorn/no-new-array": "error",
|
|
1973
|
-
"unicorn/no-new-buffer": "error",
|
|
1974
|
-
"unicorn/no-useless-collection-argument": "error",
|
|
1975
|
-
"unicorn/no-useless-spread": "error",
|
|
1976
|
-
"unicorn/no-zero-fractions": "error",
|
|
1977
|
-
"unicorn/numeric-separators-style": "error",
|
|
1978
|
-
"unicorn/prefer-array-find": "error",
|
|
1979
|
-
"unicorn/prefer-array-flat": "error",
|
|
1980
|
-
"unicorn/prefer-array-index-of": "error",
|
|
1981
|
-
"unicorn/prefer-array-some": "error",
|
|
1982
|
-
"unicorn/prefer-class-fields": "error",
|
|
1983
|
-
"unicorn/prefer-date-now": "error",
|
|
1984
|
-
"unicorn/prefer-includes": "error",
|
|
1985
|
-
"unicorn/prefer-json-parse-buffer": "error",
|
|
1986
|
-
"unicorn/prefer-modern-dom-apis": "error",
|
|
1987
|
-
"unicorn/prefer-modern-math-apis": "error",
|
|
1988
|
-
"unicorn/prefer-negative-index": "error",
|
|
1989
|
-
"unicorn/prefer-node-protocol": "error",
|
|
1990
|
-
"unicorn/prefer-object-from-entries": "error",
|
|
1991
|
-
"unicorn/prefer-optional-catch-binding": "error",
|
|
1992
|
-
"unicorn/prefer-prototype-methods": "error",
|
|
1993
|
-
"unicorn/prefer-query-selector": "error",
|
|
1994
|
-
"unicorn/prefer-regexp-test": "error",
|
|
1995
|
-
"unicorn/prefer-response-static-json": "error",
|
|
1996
|
-
"unicorn/prefer-set-size": "error",
|
|
1997
|
-
"unicorn/prefer-spread": "error",
|
|
1998
|
-
"unicorn/prefer-string-slice": "error",
|
|
1999
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2000
|
-
"unicorn/prefer-type-error": "error",
|
|
2001
|
-
"unicorn/relative-url-style": ["error", "always"],
|
|
2002
|
-
"unicorn/require-module-specifiers": "error",
|
|
2003
|
-
"unicorn/switch-case-braces": "error",
|
|
2004
|
-
"unicorn/throw-new-error": "error"
|
|
2005
|
-
}
|
|
2006
|
-
}];
|
|
2007
|
-
|
|
2008
|
-
//#endregion
|
|
2009
|
-
//#region src/configs/vue.ts
|
|
2010
|
-
async function vue({ overrides, typescript: typescript$1 } = {}) {
|
|
2011
|
-
const [parserVue, pluginVue] = await Promise.all([interopDefault(import("vue-eslint-parser")), interopDefault(import("eslint-plugin-vue"))]);
|
|
2012
|
-
return [{
|
|
2013
|
-
name: "so1ve/vue/setup",
|
|
2014
|
-
plugins: { vue: pluginVue }
|
|
2015
|
-
}, {
|
|
2016
|
-
name: "so1ve/vue/rules",
|
|
2017
|
-
files: [GLOB_VUE],
|
|
2018
|
-
languageOptions: {
|
|
2019
|
-
parser: parserVue,
|
|
2020
|
-
parserOptions: {
|
|
2021
|
-
ecmaFeatures: { jsx: true },
|
|
2022
|
-
extraFileExtensions: [".vue"],
|
|
2023
|
-
parser: typescript$1 ? tseslint.parser : null,
|
|
2024
|
-
sourceType: "module"
|
|
2025
|
-
}
|
|
2026
|
-
},
|
|
2027
|
-
processor: pluginVue.processors[".vue"],
|
|
2028
|
-
rules: {
|
|
2029
|
-
...pluginVue.configs.base.rules,
|
|
2030
|
-
...pluginVue.configs.essential.rules,
|
|
2031
|
-
...pluginVue.configs["strongly-recommended"].rules,
|
|
2032
|
-
...pluginVue.configs.recommended.rules,
|
|
2033
|
-
"no-undef": "off",
|
|
2034
|
-
"no-unused-vars": "off",
|
|
2035
|
-
"so1ve/vue-root-element-sort-attributes": "error",
|
|
2036
|
-
"ts/no-unused-vars": "off",
|
|
2037
|
-
"vue/array-bracket-spacing": "off",
|
|
2038
|
-
"vue/arrow-spacing": "off",
|
|
2039
|
-
"vue/attributes-order": ["error", {
|
|
2040
|
-
order: [
|
|
2041
|
-
"DEFINITION",
|
|
2042
|
-
"LIST_RENDERING",
|
|
2043
|
-
"CONDITIONALS",
|
|
2044
|
-
"RENDER_MODIFIERS",
|
|
2045
|
-
"TWO_WAY_BINDING",
|
|
2046
|
-
"OTHER_DIRECTIVES",
|
|
2047
|
-
["UNIQUE", "SLOT"],
|
|
2048
|
-
"GLOBAL",
|
|
2049
|
-
"OTHER_ATTR",
|
|
2050
|
-
"EVENTS",
|
|
2051
|
-
"CONTENT"
|
|
2052
|
-
],
|
|
2053
|
-
alphabetical: true
|
|
2054
|
-
}],
|
|
2055
|
-
"vue/block-lang": ["error", {
|
|
2056
|
-
script: { lang: ["js", "ts"] },
|
|
2057
|
-
template: { lang: [
|
|
2058
|
-
"html",
|
|
2059
|
-
"jade",
|
|
2060
|
-
"pug",
|
|
2061
|
-
"ejs"
|
|
2062
|
-
] },
|
|
2063
|
-
style: { lang: [
|
|
2064
|
-
"css",
|
|
2065
|
-
"sass",
|
|
2066
|
-
"scss",
|
|
2067
|
-
"less",
|
|
2068
|
-
"stylus",
|
|
2069
|
-
"postcss"
|
|
2070
|
-
] }
|
|
2071
|
-
}],
|
|
2072
|
-
"vue/block-order": ["error", { order: [
|
|
2073
|
-
"script:not([setup])",
|
|
2074
|
-
"script[setup]",
|
|
2075
|
-
"template",
|
|
2076
|
-
"style"
|
|
2077
|
-
] }],
|
|
2078
|
-
"vue/block-spacing": "off",
|
|
2079
|
-
"vue/brace-style": "off",
|
|
2080
|
-
"vue/comma-dangle": "off",
|
|
2081
|
-
"vue/comma-spacing": "off",
|
|
2082
|
-
"vue/comma-style": "off",
|
|
2083
|
-
"vue/component-api-style": ["error", ["script-setup", "composition"]],
|
|
2084
|
-
"vue/component-name-in-template-casing": [
|
|
2085
|
-
"error",
|
|
2086
|
-
"PascalCase",
|
|
2087
|
-
{ registeredComponentsOnly: false }
|
|
2088
|
-
],
|
|
2089
|
-
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
2090
|
-
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
2091
|
-
"vue/define-macros-order": ["error", { order: [
|
|
2092
|
-
"defineOptions",
|
|
2093
|
-
"defineEmits",
|
|
2094
|
-
"defineProps",
|
|
2095
|
-
"defineSlots"
|
|
2096
|
-
] }],
|
|
2097
|
-
"vue/dot-location": ["error", "property"],
|
|
2098
|
-
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
2099
|
-
"vue/eqeqeq": ["error", "smart"],
|
|
2100
|
-
"vue/html-closing-bracket-spacing": "off",
|
|
2101
|
-
"vue/html-comment-content-newline": ["error", {
|
|
2102
|
-
singleline: "ignore",
|
|
2103
|
-
multiline: "always"
|
|
2104
|
-
}],
|
|
2105
|
-
"vue/html-comment-content-spacing": [
|
|
2106
|
-
"error",
|
|
2107
|
-
"always",
|
|
2108
|
-
{ exceptions: ["-"] }
|
|
2109
|
-
],
|
|
2110
|
-
"vue/html-comment-indent": ["error", "tab"],
|
|
2111
|
-
"vue/html-indent": "off",
|
|
2112
|
-
"vue/html-quotes": "off",
|
|
2113
|
-
"vue/html-self-closing": ["error", {
|
|
2114
|
-
html: {
|
|
2115
|
-
void: "always",
|
|
2116
|
-
normal: "always",
|
|
2117
|
-
component: "always"
|
|
2118
|
-
},
|
|
2119
|
-
svg: "always",
|
|
2120
|
-
math: "always"
|
|
2121
|
-
}],
|
|
2122
|
-
"vue/key-spacing": "off",
|
|
2123
|
-
"vue/keyword-spacing": "off",
|
|
2124
|
-
"vue/max-attributes-per-line": "off",
|
|
2125
|
-
"vue/multi-word-component-names": "off",
|
|
2126
|
-
"vue/multiline-html-element-content-newline": "off",
|
|
2127
|
-
"vue/mustache-interpolation-spacing": "off",
|
|
2128
|
-
"vue/no-console": ["error", { allow: [
|
|
2129
|
-
"error",
|
|
2130
|
-
"warn",
|
|
2131
|
-
"table",
|
|
2132
|
-
"time"
|
|
2133
|
-
] }],
|
|
2134
|
-
"vue/no-constant-condition": "error",
|
|
2135
|
-
"vue/no-empty-pattern": "error",
|
|
2136
|
-
"vue/no-irregular-whitespace": "error",
|
|
2137
|
-
"vue/no-loss-of-precision": "error",
|
|
2138
|
-
"vue/no-multi-spaces": "off",
|
|
2139
|
-
"vue/no-multiple-template-root": "off",
|
|
2140
|
-
"vue/no-restricted-syntax": [
|
|
2141
|
-
"error",
|
|
2142
|
-
"DebuggerStatement",
|
|
2143
|
-
"LabeledStatement",
|
|
2144
|
-
"WithStatement"
|
|
2145
|
-
],
|
|
2146
|
-
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
2147
|
-
"vue/no-sparse-arrays": "error",
|
|
2148
|
-
"vue/no-static-inline-styles": ["error", { allowBinding: true }],
|
|
2149
|
-
"vue/no-unused-refs": "error",
|
|
2150
|
-
"vue/no-useless-concat": "error",
|
|
2151
|
-
"vue/no-useless-v-bind": ["error", { ignoreIncludesComment: true }],
|
|
2152
|
-
"vue/no-v-html": "off",
|
|
2153
|
-
"vue/no-v-text-v-html-on-component": "error",
|
|
2154
|
-
"vue/object-curly-newline": ["error", {
|
|
2155
|
-
multiline: true,
|
|
2156
|
-
consistent: true
|
|
2157
|
-
}],
|
|
2158
|
-
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
2159
|
-
"vue/object-shorthand": [
|
|
2160
|
-
"error",
|
|
2161
|
-
"always",
|
|
2162
|
-
{
|
|
2163
|
-
ignoreConstructors: false,
|
|
2164
|
-
avoidQuotes: true
|
|
2165
|
-
}
|
|
2166
|
-
],
|
|
2167
|
-
"vue/operator-linebreak": "off",
|
|
2168
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
2169
|
-
"vue/prefer-define-options": "error",
|
|
2170
|
-
"vue/prefer-separate-static-class": "error",
|
|
2171
|
-
"vue/prefer-template": "error",
|
|
2172
|
-
"vue/prefer-true-attribute-shorthand": "error",
|
|
2173
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
2174
|
-
"vue/require-default-prop": "off",
|
|
2175
|
-
"vue/require-macro-variable-name": ["error", {
|
|
2176
|
-
defineProps: "props",
|
|
2177
|
-
defineEmits: "emit",
|
|
2178
|
-
defineSlots: "slots",
|
|
2179
|
-
useSlots: "slots",
|
|
2180
|
-
useAttrs: "attrs"
|
|
2181
|
-
}],
|
|
2182
|
-
"vue/require-prop-types": "off",
|
|
2183
|
-
"vue/require-typed-ref": "error",
|
|
2184
|
-
"vue/singleline-html-element-content-newline": "off",
|
|
2185
|
-
"vue/template-curly-spacing": "off",
|
|
2186
|
-
"vue/v-bind-style": [
|
|
2187
|
-
"error",
|
|
2188
|
-
"shorthand",
|
|
2189
|
-
{ sameNameShorthand: "always" }
|
|
2190
|
-
],
|
|
2191
|
-
"vue/v-for-delimiter-style": ["error", "in"],
|
|
2192
|
-
...overrides
|
|
2193
|
-
}
|
|
2194
|
-
}];
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
//#endregion
|
|
2198
|
-
//#region src/configs/yaml.ts
|
|
2199
|
-
async function yaml({ overrides } = {}) {
|
|
2200
|
-
const [parserYaml, pluginYaml] = await Promise.all([interopDefault(import("yaml-eslint-parser")), interopDefault(import("eslint-plugin-yml"))]);
|
|
2201
|
-
return [{
|
|
2202
|
-
name: "so1ve/yaml/setup",
|
|
2203
|
-
plugins: { yaml: pluginYaml }
|
|
2204
|
-
}, {
|
|
2205
|
-
name: "so1ve/yaml/rules",
|
|
2206
|
-
languageOptions: { parser: parserYaml },
|
|
2207
|
-
files: [GLOB_YAML],
|
|
2208
|
-
rules: {
|
|
2209
|
-
...renameRules(pluginYaml.configs.prettier.rules, { yml: "yaml" }),
|
|
2210
|
-
...renameRules(pluginYaml.configs.recommended.rules, { yml: "yaml" }),
|
|
2211
|
-
"style/spaced-comment": "off",
|
|
2212
|
-
"yaml/no-empty-document": "off",
|
|
2213
|
-
...overrides
|
|
2214
|
-
}
|
|
2215
|
-
}];
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
//#endregion
|
|
2219
|
-
//#region src/factory.ts
|
|
2220
|
-
const flatConfigProps = [
|
|
2221
|
-
"files",
|
|
2222
|
-
"ignores",
|
|
2223
|
-
"languageOptions",
|
|
2224
|
-
"linterOptions",
|
|
2225
|
-
"processor",
|
|
2226
|
-
"plugins",
|
|
2227
|
-
"rules",
|
|
2228
|
-
"settings"
|
|
2229
|
-
];
|
|
2230
|
-
const VuePackages = [
|
|
2231
|
-
"vue",
|
|
2232
|
-
"nuxt",
|
|
2233
|
-
"vitepress",
|
|
2234
|
-
"@slidev/cli"
|
|
2235
|
-
];
|
|
2236
|
-
const defaultPluginRenaming = {
|
|
2237
|
-
"@html-eslint": "html",
|
|
2238
|
-
"@stylistic": "style",
|
|
2239
|
-
"@typescript-eslint": "ts",
|
|
2240
|
-
"import-x": "import",
|
|
2241
|
-
"n": "node",
|
|
2242
|
-
"yml": "yaml"
|
|
2243
|
-
};
|
|
2244
|
-
/**
|
|
2245
|
-
* Construct an array of ESLint flat config items.
|
|
2246
|
-
*/
|
|
2247
|
-
function so1ve(options = {}, ...userConfigs) {
|
|
2248
|
-
const { astro: enableAstro = isPackageExists("astro"), componentExts = [], gitignore: enableGitignore = true, ignores: userIgnores = [], pnpm: enablePnpm = !!findUpSync("pnpm-workspace.yaml"), solid: enableSolid = isPackageExists("solid-js"), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2249
|
-
const configs$1 = [];
|
|
2250
|
-
if (enableGitignore) if (typeof enableGitignore === "boolean") {
|
|
2251
|
-
if (fs.existsSync(".gitignore")) configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
2252
|
-
} else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
2253
|
-
configs$1.push(ignores(userIgnores), javascript({ overrides: getOverrides(options, "javascript") }), comments(), node(), onlyError(), promise(), sortImports(), imports(), unicorn(), command(), deMorgan());
|
|
2254
|
-
if (enablePnpm) configs$1.push(pnpm({
|
|
2255
|
-
json: options.jsonc !== false,
|
|
2256
|
-
yaml: options.yaml !== false,
|
|
2257
|
-
...typeof enablePnpm === "boolean" ? {} : enablePnpm
|
|
2258
|
-
}));
|
|
2259
|
-
if (enableVue) componentExts.push("vue");
|
|
2260
|
-
if (enableTypeScript) configs$1.push(typescript({
|
|
2261
|
-
componentExts,
|
|
2262
|
-
overrides: getOverrides(options, "typescript")
|
|
2263
|
-
}));
|
|
2264
|
-
if (options.test ?? true) configs$1.push(test({ overrides: getOverrides(options, "test") }));
|
|
2265
|
-
if (enableAstro) configs$1.push(astro({ overrides: getOverrides(options, "astro") }));
|
|
2266
|
-
if (enableVue) configs$1.push(vue({
|
|
2267
|
-
overrides: getOverrides(options, "vue"),
|
|
2268
|
-
typescript: !!enableTypeScript
|
|
2269
|
-
}));
|
|
2270
|
-
if (enableSolid) configs$1.push(solid({
|
|
2271
|
-
overrides: getOverrides(options, "solid"),
|
|
2272
|
-
typescript: !!enableTypeScript
|
|
2273
|
-
}));
|
|
2274
|
-
if (options.formatting ?? true) configs$1.push(formatting(options));
|
|
2275
|
-
if (options.perfectionist ?? true) configs$1.push(perfectionist());
|
|
2276
|
-
if (options.html ?? true) configs$1.push(html());
|
|
2277
|
-
if (options.jsonc ?? true) configs$1.push(jsonc());
|
|
2278
|
-
if (options.toml ?? true) configs$1.push(toml({ overrides: getOverrides(options, "toml") }));
|
|
2279
|
-
if (options.yaml ?? true) configs$1.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
2280
|
-
if (options.mdx ?? true) configs$1.push(mdx({
|
|
2281
|
-
componentExts,
|
|
2282
|
-
overrides: getOverrides(options, "mdx")
|
|
2283
|
-
}));
|
|
2284
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2285
|
-
if (key in options) acc[key] = options[key];
|
|
2286
|
-
return acc;
|
|
2287
|
-
}, {});
|
|
2288
|
-
if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
|
|
2289
|
-
return new FlatConfigComposer().append(...configs$1, ...userConfigs).renamePlugins(defaultPluginRenaming);
|
|
2290
|
-
}
|
|
2291
|
-
function getOverrides(options, key) {
|
|
2292
|
-
const sub = typeof options[key] === "boolean" ? {} : options[key] ?? {};
|
|
2293
|
-
return {
|
|
2294
|
-
...options.overrides?.[key],
|
|
2295
|
-
..."overrides" in sub ? sub.overrides : {}
|
|
2296
|
-
};
|
|
2297
|
-
}
|
|
2298
|
-
|
|
2299
|
-
//#endregion
|
|
2300
30
|
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, astro, command, comments, deMorgan, defaultPluginRenaming, formatting, getOverrides, html, ignores, imports, interopDefault, javascript, jsonc, mdx, node, onlyError, perfectionist, pnpm, promise, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, yaml };
|