@frabbit/eslint-config 1.5.15 → 7.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +39 -34
- package/dist/index.d.mts +14606 -0
- package/dist/index.mjs +1117 -0
- package/package.json +79 -57
- package/dist/index.cjs +0 -1409
- package/dist/index.d.cts +0 -107
- package/dist/index.d.ts +0 -107
- package/dist/index.js +0 -1303
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1117 @@
|
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
|
+
import baselineJs from "eslint-plugin-baseline-js";
|
|
4
|
+
const configJs = __cjs_require("@eslint/js");
|
|
5
|
+
import pluginMarkdown from "@eslint/markdown";
|
|
6
|
+
const configComments = __cjs_require("@eslint-community/eslint-plugin-eslint-comments/configs");
|
|
7
|
+
import pluginIgnore from "eslint-config-flat-gitignore";
|
|
8
|
+
import pluginAntfu from "eslint-plugin-antfu";
|
|
9
|
+
import configCommand from "eslint-plugin-command/config";
|
|
10
|
+
import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
11
|
+
import pluginImport from "eslint-plugin-import-x";
|
|
12
|
+
import pluginJsdoc from "eslint-plugin-jsdoc";
|
|
13
|
+
const pluginJsonc = __cjs_require("eslint-plugin-jsonc");
|
|
14
|
+
const pluginNode = __cjs_require("eslint-plugin-n");
|
|
15
|
+
import pluginSxzz from "eslint-plugin-sxzz";
|
|
16
|
+
const tseslint = __cjs_require("typescript-eslint");
|
|
17
|
+
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
18
|
+
const pluginVue = __cjs_require("eslint-plugin-vue");
|
|
19
|
+
const pluginPerfectionist = __cjs_require("eslint-plugin-perfectionist");
|
|
20
|
+
const pluginPrettier = __cjs_require("eslint-plugin-prettier");
|
|
21
|
+
const pluginPrettierRecommended = __cjs_require("eslint-plugin-prettier/recommended");
|
|
22
|
+
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
23
|
+
import pluginPnpm from "eslint-plugin-pnpm";
|
|
24
|
+
const pluginSecurity = __cjs_require("eslint-plugin-security");
|
|
25
|
+
const pluginSonarJS = __cjs_require("eslint-plugin-sonarjs");
|
|
26
|
+
const pluginYml = __cjs_require("eslint-plugin-yml");
|
|
27
|
+
const parserVue = __cjs_require("vue-eslint-parser");
|
|
28
|
+
const parserYml = __cjs_require("yaml-eslint-parser");
|
|
29
|
+
const parserJsonc = __cjs_require("jsonc-eslint-parser");
|
|
30
|
+
const globals = __cjs_require("globals");
|
|
31
|
+
const {
|
|
32
|
+
configs
|
|
33
|
+
} = __cjs_require("eslint-plugin-regexp");
|
|
34
|
+
const {
|
|
35
|
+
defineConfig
|
|
36
|
+
} = __cjs_require("eslint/config");
|
|
37
|
+
import process from "node:process";
|
|
38
|
+
import { isPackageExists } from "local-pkg";
|
|
39
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
40
|
+
|
|
41
|
+
//#region src/configs/baseline.ts
|
|
42
|
+
const baseline = (options = {}) => [{
|
|
43
|
+
name: "frabbit/baseline",
|
|
44
|
+
plugins: { "baseline-js": baselineJs },
|
|
45
|
+
rules: { "baseline-js/use-baseline": ["warn", {
|
|
46
|
+
ignoreFeatures: ["functions-caller-arguments"],
|
|
47
|
+
includeJsBuiltins: { preset: "auto" },
|
|
48
|
+
includeWebApis: { preset: "auto" },
|
|
49
|
+
...options
|
|
50
|
+
}] }
|
|
51
|
+
}];
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/configs/command.ts
|
|
55
|
+
const command = () => [{
|
|
56
|
+
...configCommand(),
|
|
57
|
+
name: "frabbit/command"
|
|
58
|
+
}];
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/configs/comments.ts
|
|
62
|
+
const comments = () => [{
|
|
63
|
+
...configComments.recommended,
|
|
64
|
+
name: "frabbit/comments/recommended"
|
|
65
|
+
}, {
|
|
66
|
+
name: "frabbit/comments",
|
|
67
|
+
rules: { "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }] }
|
|
68
|
+
}];
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/configs/de-morgan.ts
|
|
72
|
+
const deMorgan = () => [{
|
|
73
|
+
...pluginDeMorgan.configs.recommended,
|
|
74
|
+
name: "frabbit/de-morgan"
|
|
75
|
+
}];
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/globs.ts
|
|
79
|
+
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
80
|
+
const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
81
|
+
const GLOB_JS = "**/*.?([cm])js";
|
|
82
|
+
const GLOB_JSX = "**/*.jsx";
|
|
83
|
+
const GLOB_TS = "**/*.?([cm])ts";
|
|
84
|
+
const GLOB_TSX = "**/*.tsx";
|
|
85
|
+
const GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
86
|
+
const GLOB_CSS = "**/*.css";
|
|
87
|
+
const GLOB_LESS = "**/*.less";
|
|
88
|
+
const GLOB_SCSS = "**/*.scss";
|
|
89
|
+
const GLOB_JSON = "**/*.json";
|
|
90
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
91
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
92
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
93
|
+
const GLOB_VUE = "**/*.vue";
|
|
94
|
+
const GLOB_NUXT_PAGE = "pages/**/*.vue";
|
|
95
|
+
const GLOB_NUXT_LAYOUTS = "layouts/**/*.vue";
|
|
96
|
+
const GLOB_YAML = "**/*.y?(a)ml";
|
|
97
|
+
const GLOB_HTML = "**/*.htm?(l)";
|
|
98
|
+
const GLOB_ALL_SRC = [
|
|
99
|
+
GLOB_SRC,
|
|
100
|
+
GLOB_STYLE,
|
|
101
|
+
GLOB_JSON,
|
|
102
|
+
GLOB_JSON5,
|
|
103
|
+
GLOB_MARKDOWN,
|
|
104
|
+
GLOB_VUE,
|
|
105
|
+
GLOB_NUXT_PAGE,
|
|
106
|
+
GLOB_NUXT_LAYOUTS,
|
|
107
|
+
GLOB_YAML,
|
|
108
|
+
GLOB_HTML
|
|
109
|
+
];
|
|
110
|
+
const GLOB_NODE_MODULES = "**/node_modules";
|
|
111
|
+
const GLOB_DIST = "**/dist";
|
|
112
|
+
const GLOB_LOCKFILE = [
|
|
113
|
+
"**/package-lock.json",
|
|
114
|
+
"**/yarn.lock",
|
|
115
|
+
"**/pnpm-lock.yaml",
|
|
116
|
+
"**/bun.lockb"
|
|
117
|
+
];
|
|
118
|
+
const GLOB_EXCLUDE = [
|
|
119
|
+
GLOB_NODE_MODULES,
|
|
120
|
+
GLOB_DIST,
|
|
121
|
+
...GLOB_LOCKFILE,
|
|
122
|
+
"output",
|
|
123
|
+
"**/coverage",
|
|
124
|
+
"**/temp",
|
|
125
|
+
"**/fixtures",
|
|
126
|
+
"**/.vitepress/cache",
|
|
127
|
+
"**/.nuxt",
|
|
128
|
+
"**/.vercel",
|
|
129
|
+
"**/.changeset",
|
|
130
|
+
"**/.idea",
|
|
131
|
+
"**/.output",
|
|
132
|
+
"**/.vite-inspect",
|
|
133
|
+
"**/.nitro",
|
|
134
|
+
"**/CHANGELOG*.md",
|
|
135
|
+
"**/*.min.*",
|
|
136
|
+
"**/LICENSE*",
|
|
137
|
+
"**/__snapshots__",
|
|
138
|
+
"**/auto-import?(s).d.ts",
|
|
139
|
+
"**/components.d.ts"
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/configs/ignores.ts
|
|
144
|
+
const ignores = () => [{
|
|
145
|
+
ignores: GLOB_EXCLUDE,
|
|
146
|
+
name: "frabbit/global-ignores"
|
|
147
|
+
}, {
|
|
148
|
+
...pluginIgnore({ strict: false }),
|
|
149
|
+
name: "frabbit/gitignore"
|
|
150
|
+
}];
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/configs/imports.ts
|
|
154
|
+
const imports = () => [{
|
|
155
|
+
name: "frabbit/imports",
|
|
156
|
+
plugins: {
|
|
157
|
+
antfu: pluginAntfu,
|
|
158
|
+
import: pluginImport
|
|
159
|
+
},
|
|
160
|
+
rules: {
|
|
161
|
+
"antfu/import-dedupe": "error",
|
|
162
|
+
"import/first": "error",
|
|
163
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
164
|
+
"import/no-default-export": "error",
|
|
165
|
+
"import/no-duplicates": "error",
|
|
166
|
+
"import/no-mutable-exports": "error",
|
|
167
|
+
"import/no-named-default": "error",
|
|
168
|
+
"import/no-self-import": "error",
|
|
169
|
+
"import/no-webpack-loader-syntax": "error",
|
|
170
|
+
"import/order": ["error", {
|
|
171
|
+
alphabetize: {
|
|
172
|
+
caseInsensitive: true,
|
|
173
|
+
order: "asc"
|
|
174
|
+
},
|
|
175
|
+
groups: [
|
|
176
|
+
"builtin",
|
|
177
|
+
"external",
|
|
178
|
+
"internal",
|
|
179
|
+
"parent",
|
|
180
|
+
"sibling",
|
|
181
|
+
"index",
|
|
182
|
+
"object",
|
|
183
|
+
"type"
|
|
184
|
+
],
|
|
185
|
+
"newlines-between": "always",
|
|
186
|
+
pathGroups: [{
|
|
187
|
+
group: "internal",
|
|
188
|
+
pattern: "{{@,~}/,#}**"
|
|
189
|
+
}],
|
|
190
|
+
pathGroupsExcludedImportTypes: ["type"]
|
|
191
|
+
}]
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
files: [
|
|
195
|
+
`**/*config*.${GLOB_SRC_EXT}`,
|
|
196
|
+
`**/views/${GLOB_SRC}`,
|
|
197
|
+
`**/pages/${GLOB_SRC}`,
|
|
198
|
+
`**/{index,vite,esbuild,rollup,webpack,rspack}.ts`,
|
|
199
|
+
"**/*.d.ts",
|
|
200
|
+
`${GLOB_MARKDOWN}/**`
|
|
201
|
+
],
|
|
202
|
+
plugins: { import: pluginImport },
|
|
203
|
+
rules: { "import/no-default-export": "off" }
|
|
204
|
+
}];
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/configs/javascript.ts
|
|
208
|
+
const restrictedSyntaxJs = ["ForInStatement", "LabeledStatement"];
|
|
209
|
+
const javascript = () => [{
|
|
210
|
+
...configJs.configs.recommended,
|
|
211
|
+
name: "frabbit/js/recommended"
|
|
212
|
+
}, {
|
|
213
|
+
languageOptions: {
|
|
214
|
+
globals: {
|
|
215
|
+
...globals.browser,
|
|
216
|
+
...globals.es2026,
|
|
217
|
+
...globals.node
|
|
218
|
+
},
|
|
219
|
+
parserOptions: {
|
|
220
|
+
ecmaFeatures: { jsx: true },
|
|
221
|
+
sourceType: "module"
|
|
222
|
+
},
|
|
223
|
+
sourceType: "module"
|
|
224
|
+
},
|
|
225
|
+
name: "frabbit/js",
|
|
226
|
+
plugins: {
|
|
227
|
+
sxzz: pluginSxzz,
|
|
228
|
+
"unused-imports": pluginUnusedImports
|
|
229
|
+
},
|
|
230
|
+
rules: {
|
|
231
|
+
"array-callback-return": "error",
|
|
232
|
+
"block-scoped-var": "error",
|
|
233
|
+
"dot-notation": "warn",
|
|
234
|
+
eqeqeq: ["error", "smart"],
|
|
235
|
+
"no-alert": "warn",
|
|
236
|
+
"no-console": ["warn", { allow: [
|
|
237
|
+
"warn",
|
|
238
|
+
"error",
|
|
239
|
+
"info",
|
|
240
|
+
"clear"
|
|
241
|
+
] }],
|
|
242
|
+
"no-debugger": "warn",
|
|
243
|
+
"no-duplicate-imports": "error",
|
|
244
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
245
|
+
"no-fallthrough": ["warn", { commentPattern: String.raw`break[\s\w]*omitted` }],
|
|
246
|
+
"no-inner-declarations": "error",
|
|
247
|
+
"no-lonely-if": "error",
|
|
248
|
+
"no-multi-str": "error",
|
|
249
|
+
"no-restricted-syntax": ["error", ...restrictedSyntaxJs],
|
|
250
|
+
"no-unused-expressions": ["error", {
|
|
251
|
+
allowShortCircuit: true,
|
|
252
|
+
allowTaggedTemplates: true,
|
|
253
|
+
allowTernary: true
|
|
254
|
+
}],
|
|
255
|
+
"no-unused-vars": "off",
|
|
256
|
+
"no-useless-call": "error",
|
|
257
|
+
"no-useless-computed-key": "error",
|
|
258
|
+
"no-useless-constructor": "error",
|
|
259
|
+
"no-useless-rename": "error",
|
|
260
|
+
"no-var": "error",
|
|
261
|
+
"no-void": "error",
|
|
262
|
+
"object-shorthand": [
|
|
263
|
+
"error",
|
|
264
|
+
"always",
|
|
265
|
+
{
|
|
266
|
+
avoidQuotes: true,
|
|
267
|
+
ignoreConstructors: false
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
"one-var": ["error", { initialized: "never" }],
|
|
271
|
+
"prefer-arrow-callback": ["error", {
|
|
272
|
+
allowNamedFunctions: false,
|
|
273
|
+
allowUnboundThis: true
|
|
274
|
+
}],
|
|
275
|
+
"prefer-const": ["warn", {
|
|
276
|
+
destructuring: "all",
|
|
277
|
+
ignoreReadBeforeAssign: true
|
|
278
|
+
}],
|
|
279
|
+
"prefer-exponentiation-operator": "error",
|
|
280
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
281
|
+
"prefer-rest-params": "error",
|
|
282
|
+
"prefer-spread": "error",
|
|
283
|
+
"prefer-template": "error",
|
|
284
|
+
"require-await": "error",
|
|
285
|
+
"sxzz/prefer-string-function": "warn",
|
|
286
|
+
"unicode-bom": ["error", "never"],
|
|
287
|
+
"unused-imports/no-unused-imports": "warn",
|
|
288
|
+
"unused-imports/no-unused-vars": ["error", {
|
|
289
|
+
args: "after-used",
|
|
290
|
+
ignoreRestSiblings: true
|
|
291
|
+
}],
|
|
292
|
+
"use-isnan": ["error", {
|
|
293
|
+
enforceForIndexOf: true,
|
|
294
|
+
enforceForSwitchCase: true
|
|
295
|
+
}],
|
|
296
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
297
|
+
"vars-on-top": "error"
|
|
298
|
+
}
|
|
299
|
+
}];
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/configs/jsdoc.ts
|
|
303
|
+
const jsdoc = () => [{
|
|
304
|
+
name: "frabbit/jsdoc",
|
|
305
|
+
plugins: { jsdoc: pluginJsdoc },
|
|
306
|
+
rules: {
|
|
307
|
+
"jsdoc/check-access": "warn",
|
|
308
|
+
"jsdoc/check-param-names": "warn",
|
|
309
|
+
"jsdoc/check-property-names": "warn",
|
|
310
|
+
"jsdoc/check-types": "warn",
|
|
311
|
+
"jsdoc/empty-tags": "warn",
|
|
312
|
+
"jsdoc/implements-on-classes": "warn",
|
|
313
|
+
"jsdoc/no-defaults": "warn",
|
|
314
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
315
|
+
"jsdoc/require-param-name": "warn",
|
|
316
|
+
"jsdoc/require-property": "warn",
|
|
317
|
+
"jsdoc/require-property-description": "warn",
|
|
318
|
+
"jsdoc/require-property-name": "warn",
|
|
319
|
+
"jsdoc/require-returns-check": "warn",
|
|
320
|
+
"jsdoc/require-returns-description": "warn",
|
|
321
|
+
"jsdoc/require-yields-check": "warn"
|
|
322
|
+
}
|
|
323
|
+
}];
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/configs/jsonc.ts
|
|
327
|
+
const jsonc = () => [{
|
|
328
|
+
files: [
|
|
329
|
+
GLOB_JSON,
|
|
330
|
+
GLOB_JSON5,
|
|
331
|
+
GLOB_JSONC
|
|
332
|
+
],
|
|
333
|
+
languageOptions: { parser: parserJsonc },
|
|
334
|
+
name: "frabbit/json",
|
|
335
|
+
plugins: { jsonc: pluginJsonc },
|
|
336
|
+
rules: {
|
|
337
|
+
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
338
|
+
"jsonc/quote-props": "off",
|
|
339
|
+
"jsonc/quotes": "off"
|
|
340
|
+
}
|
|
341
|
+
}];
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/configs/markdown.ts
|
|
345
|
+
const markdown = () => [...pluginMarkdown.configs.processor.map((config) => ({
|
|
346
|
+
...config,
|
|
347
|
+
name: `frabbit/${config.name || "anonymous"}`
|
|
348
|
+
})), {
|
|
349
|
+
files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
|
|
350
|
+
name: "frabbit/markdown-rules",
|
|
351
|
+
rules: {
|
|
352
|
+
"@typescript-eslint/comma-dangle": "off",
|
|
353
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
354
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
355
|
+
"@typescript-eslint/no-namespace": "off",
|
|
356
|
+
"@typescript-eslint/no-redeclare": "off",
|
|
357
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
358
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
359
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
360
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
361
|
+
"baseline-js/use-baseline": "off",
|
|
362
|
+
"no-alert": "off",
|
|
363
|
+
"no-console": "off",
|
|
364
|
+
"no-restricted-imports": "off",
|
|
365
|
+
"no-undef": "off",
|
|
366
|
+
"no-unused-expressions": "off",
|
|
367
|
+
"no-unused-vars": "off",
|
|
368
|
+
"node/prefer-global/buffer": "off",
|
|
369
|
+
"node/prefer-global/process": "off",
|
|
370
|
+
"unicorn/no-anonymous-default-export": "off",
|
|
371
|
+
"unicorn/no-useless-undefined": "off",
|
|
372
|
+
"unused-imports/no-unused-imports": "off",
|
|
373
|
+
"unused-imports/no-unused-vars": "off"
|
|
374
|
+
}
|
|
375
|
+
}];
|
|
376
|
+
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/configs/node.ts
|
|
379
|
+
const node = () => [{
|
|
380
|
+
name: "frabbit/node",
|
|
381
|
+
plugins: { node: pluginNode },
|
|
382
|
+
rules: {
|
|
383
|
+
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
384
|
+
"node/no-deprecated-api": "error",
|
|
385
|
+
"node/no-exports-assign": "error",
|
|
386
|
+
"node/no-new-require": "error",
|
|
387
|
+
"node/no-path-concat": "error",
|
|
388
|
+
"node/no-unsupported-features/es-builtins": "error",
|
|
389
|
+
"node/prefer-global/buffer": ["error", "never"],
|
|
390
|
+
"node/prefer-global/process": ["error", "never"],
|
|
391
|
+
"node/process-exit-as-throw": "error"
|
|
392
|
+
}
|
|
393
|
+
}];
|
|
394
|
+
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/configs/pnpm.ts
|
|
397
|
+
async function pnpm() {
|
|
398
|
+
return [{
|
|
399
|
+
files: ["package.json", "**/package.json"],
|
|
400
|
+
languageOptions: { parser: await import("jsonc-eslint-parser") },
|
|
401
|
+
name: "frabbit/pnpm/package-json",
|
|
402
|
+
plugins: { pnpm: pluginPnpm },
|
|
403
|
+
rules: {
|
|
404
|
+
"pnpm/json-enforce-catalog": "error",
|
|
405
|
+
"pnpm/json-prefer-workspace-settings": "error",
|
|
406
|
+
"pnpm/json-valid-catalog": "error"
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
files: ["pnpm-workspace.yaml"],
|
|
410
|
+
languageOptions: { parser: await import("yaml-eslint-parser") },
|
|
411
|
+
name: "frabbit/pnpm/pnpm-workspace-yaml",
|
|
412
|
+
plugins: { pnpm: pluginPnpm },
|
|
413
|
+
rules: {
|
|
414
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
415
|
+
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
416
|
+
}
|
|
417
|
+
}];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/configs/prettier.ts
|
|
422
|
+
const rules = { ...pluginPrettierRecommended.rules };
|
|
423
|
+
delete rules["vue/html-self-closing"];
|
|
424
|
+
const prettier = () => [{
|
|
425
|
+
name: "frabbit/prettier",
|
|
426
|
+
plugins: { prettier: pluginPrettier },
|
|
427
|
+
rules: {
|
|
428
|
+
...rules,
|
|
429
|
+
"prettier/prettier": "warn"
|
|
430
|
+
}
|
|
431
|
+
}];
|
|
432
|
+
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/configs/regexp.ts
|
|
435
|
+
const regexp = () => [{
|
|
436
|
+
...configs["flat/recommended"],
|
|
437
|
+
name: "frabbit/regexp"
|
|
438
|
+
}];
|
|
439
|
+
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/configs/security.ts
|
|
442
|
+
const security = () => [{
|
|
443
|
+
name: "frabbit/security",
|
|
444
|
+
plugins: { security: pluginSecurity },
|
|
445
|
+
rules: {
|
|
446
|
+
"security/detect-bidi-characters": "warn",
|
|
447
|
+
"security/detect-buffer-noassert": "warn",
|
|
448
|
+
"security/detect-child-process": "warn",
|
|
449
|
+
"security/detect-disable-mustache-escape": "warn",
|
|
450
|
+
"security/detect-eval-with-expression": "warn",
|
|
451
|
+
"security/detect-new-buffer": "warn",
|
|
452
|
+
"security/detect-no-csrf-before-method-override": "warn",
|
|
453
|
+
"security/detect-non-literal-fs-filename": "warn",
|
|
454
|
+
"security/detect-non-literal-regexp": "warn",
|
|
455
|
+
"security/detect-non-literal-require": "warn",
|
|
456
|
+
"security/detect-object-injection": "warn",
|
|
457
|
+
"security/detect-possible-timing-attacks": "warn",
|
|
458
|
+
"security/detect-pseudoRandomBytes": "warn",
|
|
459
|
+
"security/detect-unsafe-regex": "warn"
|
|
460
|
+
}
|
|
461
|
+
}];
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/configs/sonarjs.ts
|
|
465
|
+
const sonarjs = () => [{
|
|
466
|
+
name: "frabbit/sonarjs",
|
|
467
|
+
plugins: { sonarjs: pluginSonarJS },
|
|
468
|
+
rules: {
|
|
469
|
+
"sonarjs/cognitive-complexity": "error",
|
|
470
|
+
"sonarjs/elseif-without-else": "off",
|
|
471
|
+
"sonarjs/max-switch-cases": "error",
|
|
472
|
+
"sonarjs/no-all-duplicated-branches": "error",
|
|
473
|
+
"sonarjs/no-collapsible-if": "error",
|
|
474
|
+
"sonarjs/no-collection-size-mischeck": "error",
|
|
475
|
+
"sonarjs/no-duplicate-string": "error",
|
|
476
|
+
"sonarjs/no-duplicated-branches": "error",
|
|
477
|
+
"sonarjs/no-element-overwrite": "error",
|
|
478
|
+
"sonarjs/no-empty-collection": "error",
|
|
479
|
+
"sonarjs/no-extra-arguments": "error",
|
|
480
|
+
"sonarjs/no-gratuitous-expressions": "error",
|
|
481
|
+
"sonarjs/no-identical-conditions": "error",
|
|
482
|
+
"sonarjs/no-identical-expressions": "error",
|
|
483
|
+
"sonarjs/no-identical-functions": "error",
|
|
484
|
+
"sonarjs/no-ignored-return": "error",
|
|
485
|
+
"sonarjs/no-inverted-boolean-check": "off",
|
|
486
|
+
"sonarjs/no-nested-switch": "error",
|
|
487
|
+
"sonarjs/no-nested-template-literals": "error",
|
|
488
|
+
"sonarjs/no-one-iteration-loop": "error",
|
|
489
|
+
"sonarjs/no-redundant-boolean": "error",
|
|
490
|
+
"sonarjs/no-redundant-jump": "error",
|
|
491
|
+
"sonarjs/no-same-line-conditional": "error",
|
|
492
|
+
"sonarjs/no-small-switch": "error",
|
|
493
|
+
"sonarjs/no-unused-collection": "error",
|
|
494
|
+
"sonarjs/no-use-of-empty-return-value": "error",
|
|
495
|
+
"sonarjs/no-useless-catch": "error",
|
|
496
|
+
"sonarjs/non-existent-operator": "error",
|
|
497
|
+
"sonarjs/prefer-immediate-return": "error",
|
|
498
|
+
"sonarjs/prefer-object-literal": "error",
|
|
499
|
+
"sonarjs/prefer-single-boolean-return": "error",
|
|
500
|
+
"sonarjs/prefer-while": "error"
|
|
501
|
+
}
|
|
502
|
+
}];
|
|
503
|
+
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/configs/sort.ts
|
|
506
|
+
const sortPackageJson = () => [{
|
|
507
|
+
files: ["**/package.json"],
|
|
508
|
+
name: "frabbit/sort/package.json",
|
|
509
|
+
rules: {
|
|
510
|
+
"jsonc/sort-array-values": ["error", {
|
|
511
|
+
order: { type: "asc" },
|
|
512
|
+
pathPattern: "^files$"
|
|
513
|
+
}],
|
|
514
|
+
"jsonc/sort-keys": [
|
|
515
|
+
"error",
|
|
516
|
+
{
|
|
517
|
+
order: [
|
|
518
|
+
"publisher",
|
|
519
|
+
"name",
|
|
520
|
+
"displayName",
|
|
521
|
+
"type",
|
|
522
|
+
"version",
|
|
523
|
+
"private",
|
|
524
|
+
"packageManager",
|
|
525
|
+
"description",
|
|
526
|
+
"author",
|
|
527
|
+
"contributors",
|
|
528
|
+
"license",
|
|
529
|
+
"funding",
|
|
530
|
+
"homepage",
|
|
531
|
+
"repository",
|
|
532
|
+
"bugs",
|
|
533
|
+
"keywords",
|
|
534
|
+
"categories",
|
|
535
|
+
"sideEffects",
|
|
536
|
+
"imports",
|
|
537
|
+
"exports",
|
|
538
|
+
"main",
|
|
539
|
+
"module",
|
|
540
|
+
"unpkg",
|
|
541
|
+
"jsdelivr",
|
|
542
|
+
"types",
|
|
543
|
+
"typesVersions",
|
|
544
|
+
"bin",
|
|
545
|
+
"icon",
|
|
546
|
+
"files",
|
|
547
|
+
"engines",
|
|
548
|
+
"activationEvents",
|
|
549
|
+
"contributes",
|
|
550
|
+
"scripts",
|
|
551
|
+
"peerDependencies",
|
|
552
|
+
"peerDependenciesMeta",
|
|
553
|
+
"dependencies",
|
|
554
|
+
"optionalDependencies",
|
|
555
|
+
"devDependencies",
|
|
556
|
+
"pnpm",
|
|
557
|
+
"overrides",
|
|
558
|
+
"resolutions",
|
|
559
|
+
"husky",
|
|
560
|
+
"simple-git-hooks",
|
|
561
|
+
"lint-staged",
|
|
562
|
+
"eslintConfig",
|
|
563
|
+
"prettier",
|
|
564
|
+
"tsdown"
|
|
565
|
+
],
|
|
566
|
+
pathPattern: "^$"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
order: { type: "asc" },
|
|
570
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
order: [
|
|
574
|
+
"types",
|
|
575
|
+
"require",
|
|
576
|
+
"import",
|
|
577
|
+
"default"
|
|
578
|
+
],
|
|
579
|
+
pathPattern: "^exports.*$"
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
order: { type: "asc" },
|
|
583
|
+
pathPattern: String.raw`^(?:resolutions|overrides|pnpm\.overrides)$`
|
|
584
|
+
}
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
}];
|
|
588
|
+
const sortTsconfig = () => [{
|
|
589
|
+
files: ["**/[jt]sconfig.json", "**/[jt]sconfig.*.json"],
|
|
590
|
+
name: "frabbit/sort/tsconfig",
|
|
591
|
+
rules: { "jsonc/sort-keys": [
|
|
592
|
+
"error",
|
|
593
|
+
{
|
|
594
|
+
order: [
|
|
595
|
+
"extends",
|
|
596
|
+
"compilerOptions",
|
|
597
|
+
"references",
|
|
598
|
+
"files",
|
|
599
|
+
"include",
|
|
600
|
+
"exclude"
|
|
601
|
+
],
|
|
602
|
+
pathPattern: "^$"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
order: [
|
|
606
|
+
"incremental",
|
|
607
|
+
"composite",
|
|
608
|
+
"tsBuildInfoFile",
|
|
609
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
610
|
+
"disableSolutionSearching",
|
|
611
|
+
"disableReferencedProjectLoad",
|
|
612
|
+
"target",
|
|
613
|
+
"jsx",
|
|
614
|
+
"jsxFactory",
|
|
615
|
+
"jsxFragmentFactory",
|
|
616
|
+
"jsxImportSource",
|
|
617
|
+
"lib",
|
|
618
|
+
"moduleDetection",
|
|
619
|
+
"noLib",
|
|
620
|
+
"reactNamespace",
|
|
621
|
+
"useDefineForClassFields",
|
|
622
|
+
"emitDecoratorMetadata",
|
|
623
|
+
"experimentalDecorators",
|
|
624
|
+
"libReplacement",
|
|
625
|
+
"baseUrl",
|
|
626
|
+
"rootDir",
|
|
627
|
+
"rootDirs",
|
|
628
|
+
"customConditions",
|
|
629
|
+
"module",
|
|
630
|
+
"moduleResolution",
|
|
631
|
+
"moduleSuffixes",
|
|
632
|
+
"noResolve",
|
|
633
|
+
"paths",
|
|
634
|
+
"resolveJsonModule",
|
|
635
|
+
"resolvePackageJsonExports",
|
|
636
|
+
"resolvePackageJsonImports",
|
|
637
|
+
"typeRoots",
|
|
638
|
+
"types",
|
|
639
|
+
"allowArbitraryExtensions",
|
|
640
|
+
"allowImportingTsExtensions",
|
|
641
|
+
"allowUmdGlobalAccess",
|
|
642
|
+
"allowJs",
|
|
643
|
+
"checkJs",
|
|
644
|
+
"maxNodeModuleJsDepth",
|
|
645
|
+
"strict",
|
|
646
|
+
"strictBindCallApply",
|
|
647
|
+
"strictFunctionTypes",
|
|
648
|
+
"strictNullChecks",
|
|
649
|
+
"strictPropertyInitialization",
|
|
650
|
+
"allowUnreachableCode",
|
|
651
|
+
"allowUnusedLabels",
|
|
652
|
+
"alwaysStrict",
|
|
653
|
+
"exactOptionalPropertyTypes",
|
|
654
|
+
"noFallthroughCasesInSwitch",
|
|
655
|
+
"noImplicitAny",
|
|
656
|
+
"noImplicitOverride",
|
|
657
|
+
"noImplicitReturns",
|
|
658
|
+
"noImplicitThis",
|
|
659
|
+
"noPropertyAccessFromIndexSignature",
|
|
660
|
+
"noUncheckedIndexedAccess",
|
|
661
|
+
"noUnusedLocals",
|
|
662
|
+
"noUnusedParameters",
|
|
663
|
+
"useUnknownInCatchVariables",
|
|
664
|
+
"declaration",
|
|
665
|
+
"declarationDir",
|
|
666
|
+
"declarationMap",
|
|
667
|
+
"downlevelIteration",
|
|
668
|
+
"emitBOM",
|
|
669
|
+
"emitDeclarationOnly",
|
|
670
|
+
"importHelpers",
|
|
671
|
+
"importsNotUsedAsValues",
|
|
672
|
+
"inlineSourceMap",
|
|
673
|
+
"inlineSources",
|
|
674
|
+
"mapRoot",
|
|
675
|
+
"newLine",
|
|
676
|
+
"noEmit",
|
|
677
|
+
"noEmitHelpers",
|
|
678
|
+
"noEmitOnError",
|
|
679
|
+
"outDir",
|
|
680
|
+
"outFile",
|
|
681
|
+
"preserveConstEnums",
|
|
682
|
+
"preserveValueImports",
|
|
683
|
+
"removeComments",
|
|
684
|
+
"sourceMap",
|
|
685
|
+
"sourceRoot",
|
|
686
|
+
"stripInternal",
|
|
687
|
+
"allowSyntheticDefaultImports",
|
|
688
|
+
"esModuleInterop",
|
|
689
|
+
"forceConsistentCasingInFileNames",
|
|
690
|
+
"isolatedDeclarations",
|
|
691
|
+
"isolatedModules",
|
|
692
|
+
"preserveSymlinks",
|
|
693
|
+
"verbatimModuleSyntax",
|
|
694
|
+
"erasableSyntaxOnly",
|
|
695
|
+
"skipDefaultLibCheck",
|
|
696
|
+
"skipLibCheck"
|
|
697
|
+
],
|
|
698
|
+
pathPattern: "^compilerOptions$"
|
|
699
|
+
}
|
|
700
|
+
] }
|
|
701
|
+
}];
|
|
702
|
+
const sortPnpmWorkspace = () => [{
|
|
703
|
+
files: ["**/pnpm-workspace.yaml"],
|
|
704
|
+
name: "frabbit/sort/pnpm-workspace",
|
|
705
|
+
rules: { "yml/sort-keys": [
|
|
706
|
+
"error",
|
|
707
|
+
{
|
|
708
|
+
order: [
|
|
709
|
+
"packages",
|
|
710
|
+
"overrides",
|
|
711
|
+
"patchedDependencies",
|
|
712
|
+
"defines",
|
|
713
|
+
"catalog",
|
|
714
|
+
"catalogs",
|
|
715
|
+
{ order: { type: "asc" } }
|
|
716
|
+
],
|
|
717
|
+
pathPattern: "^$"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
allowLineSeparatedGroups: true,
|
|
721
|
+
order: { type: "asc" },
|
|
722
|
+
pathPattern: "^(catalog|catalogs|overrides)$"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
allowLineSeparatedGroups: true,
|
|
726
|
+
order: { type: "asc" },
|
|
727
|
+
pathPattern: String.raw`^catalogs\..+$`
|
|
728
|
+
}
|
|
729
|
+
] }
|
|
730
|
+
}];
|
|
731
|
+
const sortImports = () => [{
|
|
732
|
+
name: "frabbit/sort/imports",
|
|
733
|
+
plugins: { perfectionist: pluginPerfectionist },
|
|
734
|
+
rules: {
|
|
735
|
+
"perfectionist/sort-exports": ["error", {
|
|
736
|
+
groups: ["value-export", "type-export"],
|
|
737
|
+
type: "natural"
|
|
738
|
+
}],
|
|
739
|
+
"perfectionist/sort-imports": ["warn", {
|
|
740
|
+
groups: [
|
|
741
|
+
"builtin",
|
|
742
|
+
"external",
|
|
743
|
+
"internal",
|
|
744
|
+
"internal-type",
|
|
745
|
+
"parent",
|
|
746
|
+
"parent-type",
|
|
747
|
+
"sibling",
|
|
748
|
+
"sibling-type",
|
|
749
|
+
"index",
|
|
750
|
+
"index-type",
|
|
751
|
+
"object",
|
|
752
|
+
"type",
|
|
753
|
+
"side-effect",
|
|
754
|
+
"side-effect-style"
|
|
755
|
+
],
|
|
756
|
+
internalPattern: ["^[~@#]/.*"],
|
|
757
|
+
newlinesBetween: "ignore",
|
|
758
|
+
type: "natural"
|
|
759
|
+
}],
|
|
760
|
+
"perfectionist/sort-named-exports": ["warn", {
|
|
761
|
+
groupKind: "values-first",
|
|
762
|
+
type: "natural"
|
|
763
|
+
}],
|
|
764
|
+
"perfectionist/sort-named-imports": ["warn", {
|
|
765
|
+
groupKind: "values-first",
|
|
766
|
+
type: "natural"
|
|
767
|
+
}]
|
|
768
|
+
}
|
|
769
|
+
}];
|
|
770
|
+
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region src/configs/special-cases.ts
|
|
773
|
+
const specialCases = () => [
|
|
774
|
+
{
|
|
775
|
+
files: ["**/scripts/*", "**/cli.*"],
|
|
776
|
+
name: "frabbit/special/cli",
|
|
777
|
+
rules: { "no-console": "off" }
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
files: [`**/*.{test,spec}.${GLOB_SRC_EXT}`],
|
|
781
|
+
name: "frabbit/special/tests",
|
|
782
|
+
rules: {
|
|
783
|
+
"baseline-js/use-baseline": "off",
|
|
784
|
+
"no-unused-expressions": "off",
|
|
785
|
+
"unicorn/consistent-function-scoping": "off"
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
files: [
|
|
790
|
+
`**/*config*.${GLOB_SRC_EXT}`,
|
|
791
|
+
`**/{views,pages,routes,middleware,plugins,api,modules}/${GLOB_SRC}`,
|
|
792
|
+
`**/{index,vite,esbuild,rollup,rolldown,webpack,rspack,farm,unloader,nuxt}.${GLOB_SRC_EXT}`,
|
|
793
|
+
"**/*.d.ts",
|
|
794
|
+
`${GLOB_MARKDOWN}/**`,
|
|
795
|
+
"**/.prettierrc*"
|
|
796
|
+
],
|
|
797
|
+
name: "frabbit/special/allow-default-export",
|
|
798
|
+
plugins: { import: pluginImport },
|
|
799
|
+
rules: { "import/no-default-export": "off" }
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
files: ["**/ISSUE_TEMPLATE/**"],
|
|
803
|
+
name: "frabbit/special/github",
|
|
804
|
+
rules: { "unicorn/filename-case": "off" }
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
808
|
+
name: "frabbit/special/components",
|
|
809
|
+
rules: { "unicorn/no-anonymous-default-export": "off" }
|
|
810
|
+
}
|
|
811
|
+
];
|
|
812
|
+
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/configs/typescript.ts
|
|
815
|
+
const typescriptCore = defineConfig({
|
|
816
|
+
extends: [...tseslint.configs.recommended],
|
|
817
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
818
|
+
name: "frabbit/typescript",
|
|
819
|
+
rules: {
|
|
820
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
821
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
822
|
+
assertionStyle: "as",
|
|
823
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
824
|
+
}],
|
|
825
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
826
|
+
disallowTypeAnnotations: false,
|
|
827
|
+
fixStyle: "inline-type-imports"
|
|
828
|
+
}],
|
|
829
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
830
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
831
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
832
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
833
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
834
|
+
"@typescript-eslint/no-redeclare": "error",
|
|
835
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
836
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
837
|
+
allowShortCircuit: true,
|
|
838
|
+
allowTaggedTemplates: true,
|
|
839
|
+
allowTernary: true
|
|
840
|
+
}],
|
|
841
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
842
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
843
|
+
"@typescript-eslint/prefer-as-const": "warn",
|
|
844
|
+
"@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
|
|
845
|
+
"no-restricted-syntax": [
|
|
846
|
+
"error",
|
|
847
|
+
...restrictedSyntaxJs,
|
|
848
|
+
"TSEnumDeclaration[const=true]"
|
|
849
|
+
]
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
const typescript = () => [
|
|
853
|
+
...typescriptCore,
|
|
854
|
+
{
|
|
855
|
+
files: ["**/*.d.ts"],
|
|
856
|
+
name: "frabbit/typescript/dts-rules",
|
|
857
|
+
rules: {
|
|
858
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
859
|
+
"import/no-duplicates": "off",
|
|
860
|
+
"no-restricted-syntax": "off",
|
|
861
|
+
"unused-imports/no-unused-vars": "off"
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
files: [GLOB_JS, "**/*.cjs"],
|
|
866
|
+
name: "frabbit/typescript/cjs-rules",
|
|
867
|
+
rules: { "@typescript-eslint/no-require-imports": "off" }
|
|
868
|
+
}
|
|
869
|
+
];
|
|
870
|
+
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/configs/unicorn.ts
|
|
873
|
+
const unicorn = () => [{
|
|
874
|
+
...pluginUnicorn.configs.unopinionated,
|
|
875
|
+
name: "frabbit/unicorn/unopinionated"
|
|
876
|
+
}, {
|
|
877
|
+
name: "frabbit/unicorn",
|
|
878
|
+
rules: {
|
|
879
|
+
"unicorn/catch-error-name": "error",
|
|
880
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
881
|
+
"unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
|
|
882
|
+
"unicorn/custom-error-definition": "error",
|
|
883
|
+
"unicorn/filename-case": ["error", {
|
|
884
|
+
cases: {
|
|
885
|
+
kebabCase: true,
|
|
886
|
+
pascalCase: true
|
|
887
|
+
},
|
|
888
|
+
ignore: [/^[A-Z]+\..*$/, /import_map\.json/]
|
|
889
|
+
}],
|
|
890
|
+
"unicorn/import-style": "off",
|
|
891
|
+
"unicorn/no-abusive-eslint-disable": "off",
|
|
892
|
+
"unicorn/no-array-for-each": "off",
|
|
893
|
+
"unicorn/no-empty-file": "off",
|
|
894
|
+
"unicorn/no-for-loop": "error",
|
|
895
|
+
"unicorn/no-process-exit": "off",
|
|
896
|
+
"unicorn/no-this-assignment": "off",
|
|
897
|
+
"unicorn/no-unreadable-array-destructuring": "off",
|
|
898
|
+
"unicorn/no-useless-undefined": ["error", {
|
|
899
|
+
checkArguments: false,
|
|
900
|
+
checkArrowFunctionBody: false
|
|
901
|
+
}],
|
|
902
|
+
"unicorn/numeric-separators-style": "off",
|
|
903
|
+
"unicorn/prefer-module": "off",
|
|
904
|
+
"unicorn/prefer-query-selector": "error",
|
|
905
|
+
"unicorn/prefer-ternary": "off",
|
|
906
|
+
"unicorn/prefer-top-level-await": "off",
|
|
907
|
+
"unicorn/require-module-specifiers": "off"
|
|
908
|
+
}
|
|
909
|
+
}];
|
|
910
|
+
|
|
911
|
+
//#endregion
|
|
912
|
+
//#region src/configs/unocss.ts
|
|
913
|
+
const unocss = async () => {
|
|
914
|
+
const { default: unocss$1 } = await import("@unocss/eslint-plugin");
|
|
915
|
+
return [{
|
|
916
|
+
...unocss$1.configs.flat,
|
|
917
|
+
name: "frabbit/unocss"
|
|
918
|
+
}];
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/configs/vue.ts
|
|
923
|
+
const reactivityTransform = () => [{
|
|
924
|
+
languageOptions: { globals: {
|
|
925
|
+
$: "readonly",
|
|
926
|
+
$$: "readonly",
|
|
927
|
+
$computed: "readonly",
|
|
928
|
+
$customRef: "readonly",
|
|
929
|
+
$ref: "readonly",
|
|
930
|
+
$shallowRef: "readonly",
|
|
931
|
+
$toRef: "readonly"
|
|
932
|
+
} },
|
|
933
|
+
name: "frabbit/vue/reactivity-transform",
|
|
934
|
+
plugins: { vue: pluginVue },
|
|
935
|
+
rules: { "vue/no-setup-props-reactivity-loss": "off" }
|
|
936
|
+
}];
|
|
937
|
+
const vueTs = typescriptCore.filter((config) => config.name !== "typescript-eslint/base").map((config) => {
|
|
938
|
+
return {
|
|
939
|
+
...config,
|
|
940
|
+
files: [GLOB_VUE],
|
|
941
|
+
name: `frabbit/vue/${config.name?.replace("frabbit/", "") || "anonymous"}`
|
|
942
|
+
};
|
|
943
|
+
});
|
|
944
|
+
const recommendedRules = pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
945
|
+
...acc,
|
|
946
|
+
...c
|
|
947
|
+
}), {});
|
|
948
|
+
const vue = () => [
|
|
949
|
+
...vueTs,
|
|
950
|
+
{
|
|
951
|
+
files: [GLOB_VUE],
|
|
952
|
+
languageOptions: {
|
|
953
|
+
parser: parserVue,
|
|
954
|
+
parserOptions: {
|
|
955
|
+
ecmaFeatures: { jsx: true },
|
|
956
|
+
extraFileExtensions: [".vue"],
|
|
957
|
+
parser: tseslint.parser,
|
|
958
|
+
sourceType: "module"
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
name: "frabbit/vue",
|
|
962
|
+
plugins: {
|
|
963
|
+
"@typescript-eslint": tseslint.plugin,
|
|
964
|
+
vue: pluginVue
|
|
965
|
+
},
|
|
966
|
+
processor: pluginVue.processors[".vue"],
|
|
967
|
+
rules: {
|
|
968
|
+
...recommendedRules,
|
|
969
|
+
"vue/block-order": ["error", { order: [
|
|
970
|
+
"script",
|
|
971
|
+
"template",
|
|
972
|
+
"style"
|
|
973
|
+
] }],
|
|
974
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
975
|
+
"vue/eqeqeq": ["error", "smart"],
|
|
976
|
+
"vue/html-self-closing": ["error", {
|
|
977
|
+
html: {
|
|
978
|
+
component: "always",
|
|
979
|
+
normal: "always",
|
|
980
|
+
void: "any"
|
|
981
|
+
},
|
|
982
|
+
math: "always",
|
|
983
|
+
svg: "always"
|
|
984
|
+
}],
|
|
985
|
+
"vue/max-attributes-per-line": "off",
|
|
986
|
+
"vue/multi-word-component-names": "off",
|
|
987
|
+
"vue/no-constant-condition": "warn",
|
|
988
|
+
"vue/no-empty-pattern": "error",
|
|
989
|
+
"vue/no-loss-of-precision": "error",
|
|
990
|
+
"vue/no-ref-as-operand": "off",
|
|
991
|
+
"vue/no-unused-refs": "error",
|
|
992
|
+
"vue/no-useless-v-bind": "error",
|
|
993
|
+
"vue/no-v-html": "off",
|
|
994
|
+
"vue/object-shorthand": [
|
|
995
|
+
"error",
|
|
996
|
+
"always",
|
|
997
|
+
{
|
|
998
|
+
avoidQuotes: true,
|
|
999
|
+
ignoreConstructors: false
|
|
1000
|
+
}
|
|
1001
|
+
],
|
|
1002
|
+
"vue/one-component-per-file": "off",
|
|
1003
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1004
|
+
"vue/prefer-template": "error",
|
|
1005
|
+
"vue/require-default-prop": "off",
|
|
1006
|
+
"vue/require-prop-types": "off",
|
|
1007
|
+
"vue/return-in-computed-property": ["error", { treatUndefinedAsUnspecified: false }]
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1010
|
+
...reactivityTransform()
|
|
1011
|
+
];
|
|
1012
|
+
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region src/configs/yml.ts
|
|
1015
|
+
const yml = () => [{
|
|
1016
|
+
name: "frabbit/yaml/setup",
|
|
1017
|
+
plugins: { yml: pluginYml }
|
|
1018
|
+
}, {
|
|
1019
|
+
files: [GLOB_YAML],
|
|
1020
|
+
languageOptions: { parser: parserYml },
|
|
1021
|
+
name: "frabbit/yaml/rules",
|
|
1022
|
+
rules: {
|
|
1023
|
+
...pluginYml.configs.standard.rules,
|
|
1024
|
+
...pluginYml.configs.prettier.rules,
|
|
1025
|
+
"yml/no-empty-mapping-value": "off"
|
|
1026
|
+
}
|
|
1027
|
+
}];
|
|
1028
|
+
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region src/env.ts
|
|
1031
|
+
const hasTypeScript = () => isPackageExists("typescript");
|
|
1032
|
+
const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli");
|
|
1033
|
+
const hasUnocss = () => isPackageExists("unocss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt") || isPackageExists("@unocss/eslint-plugin");
|
|
1034
|
+
function isInEditorEnv() {
|
|
1035
|
+
if (process.env.CI) return false;
|
|
1036
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
1037
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
1038
|
+
}
|
|
1039
|
+
function isInGitHooksOrLintStaged() {
|
|
1040
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/presets.ts
|
|
1045
|
+
/** Ignore common files and include javascript support */
|
|
1046
|
+
const presetJavaScript = () => [
|
|
1047
|
+
...ignores(),
|
|
1048
|
+
...javascript(),
|
|
1049
|
+
...comments(),
|
|
1050
|
+
...imports(),
|
|
1051
|
+
...unicorn(),
|
|
1052
|
+
...sonarjs(),
|
|
1053
|
+
...security(),
|
|
1054
|
+
...node(),
|
|
1055
|
+
...jsdoc(),
|
|
1056
|
+
...regexp(),
|
|
1057
|
+
...deMorgan()
|
|
1058
|
+
];
|
|
1059
|
+
/** Includes basic json(c) file support and sorting json keys */
|
|
1060
|
+
const presetJsonc = () => [
|
|
1061
|
+
...jsonc(),
|
|
1062
|
+
...sortPackageJson(),
|
|
1063
|
+
...sortTsconfig(),
|
|
1064
|
+
...sortPnpmWorkspace()
|
|
1065
|
+
];
|
|
1066
|
+
/** Includes markdown, yaml + `presetJsonc` support */
|
|
1067
|
+
const presetLangsExtensions = () => [
|
|
1068
|
+
...markdown(),
|
|
1069
|
+
...yml(),
|
|
1070
|
+
...presetJsonc()
|
|
1071
|
+
];
|
|
1072
|
+
/** Includes `presetJavaScript` and typescript support */
|
|
1073
|
+
const presetBasic = () => [
|
|
1074
|
+
...presetJavaScript(),
|
|
1075
|
+
...typescript(),
|
|
1076
|
+
...sortImports()
|
|
1077
|
+
];
|
|
1078
|
+
/**
|
|
1079
|
+
* Includes
|
|
1080
|
+
* - `presetBasic` (JS+TS) support
|
|
1081
|
+
* - `presetLangsExtensions` (markdown, yaml, jsonc) support
|
|
1082
|
+
* - Vue support
|
|
1083
|
+
* - UnoCSS support (`uno.config.ts` is required)
|
|
1084
|
+
* - Prettier support
|
|
1085
|
+
*/
|
|
1086
|
+
const presetAll = async () => [
|
|
1087
|
+
...presetBasic(),
|
|
1088
|
+
...presetLangsExtensions(),
|
|
1089
|
+
...vue(),
|
|
1090
|
+
...await unocss(),
|
|
1091
|
+
...prettier(),
|
|
1092
|
+
...command(),
|
|
1093
|
+
...await pnpm(),
|
|
1094
|
+
...baseline(),
|
|
1095
|
+
...specialCases()
|
|
1096
|
+
];
|
|
1097
|
+
/** `@frabbit`'s preset. */
|
|
1098
|
+
function frabbit(options = {}, ...userConfigs) {
|
|
1099
|
+
const { baseline: enableBaseline = true, command: enableCommand = true, markdown: enableMarkdown = true, pnpm: enablePnpm = false, prettier: enablePrettier = true, unocss: enableUnocss = hasUnocss(), vue: enableVue = hasVue() } = options;
|
|
1100
|
+
const configs$1 = [
|
|
1101
|
+
presetBasic(),
|
|
1102
|
+
yml(),
|
|
1103
|
+
presetJsonc()
|
|
1104
|
+
];
|
|
1105
|
+
if (enableBaseline) configs$1.push(baseline(typeof enableBaseline === "object" ? enableBaseline : {}));
|
|
1106
|
+
if (enableVue) configs$1.push(vue());
|
|
1107
|
+
if (enableMarkdown) configs$1.push(markdown());
|
|
1108
|
+
if (enableUnocss) configs$1.push(unocss());
|
|
1109
|
+
if (enablePrettier) configs$1.push(prettier());
|
|
1110
|
+
if (enableCommand) configs$1.push(command());
|
|
1111
|
+
if (enablePnpm) configs$1.push(pnpm());
|
|
1112
|
+
configs$1.push(specialCases());
|
|
1113
|
+
return new FlatConfigComposer(...configs$1, ...userConfigs);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
//#endregion
|
|
1117
|
+
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_NODE_MODULES, GLOB_NUXT_LAYOUTS, GLOB_NUXT_PAGE, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, baseline, command, comments, configCommand, configComments, configJs, deMorgan, frabbit, hasTypeScript, hasUnocss, hasVue, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, jsdoc, jsonc, markdown, node, parserJsonc, parserVue, parserYml, pluginAntfu, pluginDeMorgan, pluginIgnore, pluginImport, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNode, pluginPerfectionist, pluginPnpm, pluginPrettier, pluginPrettierRecommended, pluginSecurity, pluginSonarJS, pluginSxzz, pluginUnicorn, pluginUnusedImports, pluginVue, pluginYml, pnpm, presetAll, presetBasic, presetJavaScript, presetJsonc, presetLangsExtensions, prettier, reactivityTransform, regexp, restrictedSyntaxJs, security, sonarjs, sortImports, sortPackageJson, sortPnpmWorkspace, sortTsconfig, specialCases, tseslint, typescript, typescriptCore, unicorn, unocss, vue, yml };
|