@cuiqg/eslint-config 2.2.3 → 2.4.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/index.js CHANGED
@@ -1,47 +1,41 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
- import globals from "globals";
3
- import process from "node:process";
2
+ import process$1 from "node:process";
4
3
  import { isPackageExists } from "local-pkg";
5
- import fs from "node:fs";
6
- import { dirname, resolve } from "node:path";
7
- import { loadConfig } from "unconfig";
8
-
9
- //#region src/utils.js
10
- async function interopDefault(m) {
11
- const resolved = await m;
12
- return resolved.default || m;
13
- }
4
+ import globals from "globals";
14
5
 
15
- //#endregion
16
- //#region src/configs/comments.js
17
- /**
18
- * Comments
19
- *
20
- * @see https://mysticatea.github.io/eslint-plugin-eslint-comments/
21
- * @returns {import('eslint').Linter.FlatConfig[]}
22
- */
23
- const comments = async () => {
24
- const pluginComments = await interopDefault(import("eslint-plugin-eslint-comments"));
25
- return [{
26
- name: "cuiqg/eslint-comments",
27
- plugins: { "eslint-comments": pluginComments },
28
- rules: { ...pluginComments.configs.recommended.rules }
29
- }];
6
+ //#region src/env.ts
7
+ const isInGitHookOrLintStaged = () => {
8
+ return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
30
9
  };
10
+ const isInEditor = () => {
11
+ if (process$1.env.CI) return false;
12
+ if (isInGitHookOrLintStaged()) return false;
13
+ return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
14
+ };
15
+ const hasVue = () => [
16
+ "vue",
17
+ "nuxt",
18
+ "vitepress",
19
+ "@slidev/cli"
20
+ ].some((i) => isPackageExists("vue"));
21
+ const hasTypeScript = () => isPackageExists("typescript");
22
+ const hasUnoCss = () => isPackageExists("unocss");
23
+ const hasNextjs = () => isPackageExists("next");
31
24
 
32
25
  //#endregion
33
- //#region src/globs.js
26
+ //#region src/globs.ts
34
27
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
35
- const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
36
- const GLOB_JS = "**/*.?([cm])js";
37
- const GLOB_JSX = "**/*.?([cm])jsx";
38
- const GLOB_TS = "**/*.?([cm])ts";
39
- const GLOB_TSX = "**/*.?([cm])tsx";
28
+ const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
29
+ const GLOB_TS = `**/*.?([cm])ts`;
30
+ const GLOB_TSX = `**/*.?([cm])tsx`;
31
+ const GLOB_JS = `**/*.?([cm])js`;
32
+ const GLOB_JSX = `**/*.?([cm])jsx`;
40
33
  const GLOB_STYLE = "**/*.{c,le,sc}ss";
41
34
  const GLOB_CSS = "**/*.css";
42
- const GLOB_POSTCSS = "**/*.{p,post}css";
43
- const GLOB_LESS = "**/*.less";
44
35
  const GLOB_SCSS = "**/*.scss";
36
+ const GLOB_LESS = "**/*.less";
37
+ const GLOB_STYLUS = "**/*.styl";
38
+ const GLOB_POSTCSS = "**/*.{p,post}css";
45
39
  const GLOB_JSON = "**/*.json";
46
40
  const GLOB_JSON5 = "**/*.json5";
47
41
  const GLOB_JSONC = "**/*.jsonc";
@@ -52,6 +46,17 @@ const GLOB_TOML = "**/*.toml";
52
46
  const GLOB_XML = "**/*.xml";
53
47
  const GLOB_SVG = "**/*.svg";
54
48
  const GLOB_HTML = "**/*.htm?(l)";
49
+ const GLOB_ALL_SRC = [
50
+ GLOB_SRC,
51
+ GLOB_STYLE,
52
+ GLOB_HTML,
53
+ GLOB_VUE,
54
+ GLOB_YAML,
55
+ GLOB_XML,
56
+ GLOB_JSONC,
57
+ GLOB_JSON5,
58
+ GLOB_JSON
59
+ ];
55
60
  const GLOB_EXCLUDE = [
56
61
  "**/node_modules",
57
62
  "**/dist",
@@ -61,14 +66,15 @@ const GLOB_EXCLUDE = [
61
66
  "**/bun.lockb",
62
67
  "**/output",
63
68
  "**/coverage",
64
- "**/tmp",
65
- "**/.tmp",
66
69
  "**/temp",
67
70
  "**/.temp",
71
+ "**/tmp",
72
+ "**/.tmp",
68
73
  "**/.history",
69
74
  "**/.vitepress/cache",
70
75
  "**/.nuxt",
71
76
  "**/.next",
77
+ "**/.svelte-kit",
72
78
  "**/.vercel",
73
79
  "**/.changeset",
74
80
  "**/.idea",
@@ -77,7 +83,6 @@ const GLOB_EXCLUDE = [
77
83
  "**/.vite-inspect",
78
84
  "**/.yarn",
79
85
  "**/vite.config.*.timestamp-*",
80
- "**/.eslint-config-inspector",
81
86
  "**/CHANGELOG*.md",
82
87
  "**/*.min.*",
83
88
  "**/LICENSE*",
@@ -87,120 +92,306 @@ const GLOB_EXCLUDE = [
87
92
  ];
88
93
 
89
94
  //#endregion
90
- //#region src/configs/disables.js
91
- /**
92
- * Disables
93
- *
94
- * @see https://npm.im/@eslint/js
95
- * @returns {import('eslint').Linter.FlatConfig[]}
96
- */
97
- const disables = () => {
95
+ //#region src/utils.ts
96
+ async function interopDefault(module) {
97
+ try {
98
+ let resolved = await module;
99
+ return resolved.default || resolved;
100
+ } catch (error) {
101
+ throw new Error(`Cannot import module: ${String(error)}`);
102
+ }
103
+ }
104
+ function renameRules(rules, map) {
105
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
106
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
107
+ return [key, value];
108
+ }));
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/configs/nextjs.ts
113
+ function normalizeRules(rules) {
114
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => [key, typeof value === "string" ? [value] : value]));
115
+ }
116
+ async function nextjs() {
117
+ const files = [GLOB_SRC];
118
+ const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
98
119
  return [{
99
- files: [
100
- `**/scripts/${GLOB_SRC}`,
101
- `**/cli/${GLOB_SRC}`,
102
- `**/cli.${GLOB_SRC_EXT}`
103
- ],
104
- name: "cuiqg/disables",
105
- rules: { "no-console": "off" }
120
+ name: "cuiqg/nextjs/setup",
121
+ plugins: { next: pluginNextJS }
122
+ }, {
123
+ files,
124
+ languageOptions: {
125
+ parserOptions: { ecmaFeatures: { jsx: true } },
126
+ sourceType: "module"
127
+ },
128
+ name: "cuiqg/nextjs/rules",
129
+ rules: {
130
+ ...normalizeRules(pluginNextJS.configs.recommended.rules),
131
+ ...normalizeRules(pluginNextJS.configs["core-web-vitals"].rules)
132
+ },
133
+ settings: { react: { version: "detect" } }
106
134
  }];
107
- };
135
+ }
108
136
 
109
137
  //#endregion
110
- //#region src/configs/gitignore.js
111
- /**
112
- * Gitignore
113
- *
114
- * @see https://github.com/antfu/eslint-config-flat-gitignore
115
- * @returns {import('eslint').Linter.FlatConfig[]}
116
- */
117
- const gitignore = async () => {
118
- const pluginGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
119
- return [pluginGitignore({
120
- name: "cuiqg/gitignore",
121
- strict: false
122
- })];
123
- };
138
+ //#region src/configs/node.ts
139
+ async function node() {
140
+ const pluginNode = await interopDefault(import("eslint-plugin-n"));
141
+ return [{
142
+ name: "cuiqg/node/rules",
143
+ plugins: { node: pluginNode },
144
+ rules: { ...pluginNode.configs.recommended.rules }
145
+ }];
146
+ }
124
147
 
125
148
  //#endregion
126
- //#region src/configs/ignores.js
127
- /**
128
- * Ignores
129
- *
130
- * @returns {import('eslint').Linter.FlatConfig[]}
131
- */
132
- const ignores = () => {
149
+ //#region src/configs/package-json.ts
150
+ async function packageJson() {
151
+ const [pluginPackageJson, parserJson] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
133
152
  return [{
134
- name: "cuiqg/ignores",
135
- ignores: GLOB_EXCLUDE
153
+ files: ["**/package.json"],
154
+ plugins: { "package-json": pluginPackageJson },
155
+ name: "cuiqg/package-json/setup",
156
+ languageOptions: { parser: parserJson }
157
+ }, {
158
+ name: "cuiqg/package-json/rules",
159
+ rules: { ...pluginPackageJson.configs.recommended.rules }
136
160
  }];
137
- };
161
+ }
138
162
 
139
163
  //#endregion
140
- //#region src/configs/imports.js
141
- /**
142
- * Imports
143
- *
144
- * @see https://npm.im/eslint-plugin-import-x
145
- * @returns {import('eslint').Linter.FlatConfig[]}
146
- */
147
- const imports = async () => {
148
- const pluginImport = await interopDefault(import("eslint-plugin-import-x"));
164
+ //#region src/configs/vue.ts
165
+ async function vue() {
166
+ const files = [GLOB_VUE];
167
+ const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
149
168
  return [{
150
- name: "cuiqg/imports",
151
- plugins: { import: pluginImport },
169
+ languageOptions: { globals: {
170
+ computed: "readonly",
171
+ defineEmits: "readonly",
172
+ defineExpose: "readonly",
173
+ defineProps: "readonly",
174
+ onMounted: "readonly",
175
+ onUnmounted: "readonly",
176
+ reactive: "readonly",
177
+ ref: "readonly",
178
+ shallowReactive: "readonly",
179
+ shallowRef: "readonly",
180
+ toRef: "readonly",
181
+ toRefs: "readonly",
182
+ watch: "readonly",
183
+ watchEffect: "readonly"
184
+ } },
185
+ name: "cuiqg/vue/setup",
186
+ plugins: { vue: pluginVue }
187
+ }, {
188
+ files,
189
+ languageOptions: {
190
+ parser: parserVue,
191
+ parserOptions: {
192
+ ecmaFeatures: { jsx: true },
193
+ extraFileExtensions: [".vue"],
194
+ parser: hasTypeScript() ? await interopDefault(import("@typescript-eslint/parser")) : null,
195
+ sourceType: "module"
196
+ }
197
+ },
198
+ name: "cuiqg/vue/rules",
199
+ processor: pluginVue.processors[".vue"],
152
200
  rules: {
153
- "import/first": "error",
154
- "import/no-duplicates": "error",
155
- "import/no-mutable-exports": "error",
156
- "import/no-named-default": "error",
157
- "import/no-self-import": "error",
158
- "import/no-webpack-loader-syntax": "error",
159
- "import/newline-after-import": "error",
160
- "import/order": "error"
201
+ ...pluginVue.configs.base.rules,
202
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
203
+ ...acc,
204
+ ...c
205
+ }), {}),
206
+ ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
207
+ ...acc,
208
+ ...c
209
+ }), {}),
210
+ ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
211
+ ...acc,
212
+ ...c
213
+ }), {}),
214
+ "node/prefer-global/process": "off",
215
+ "ts/explicit-function-return-type": "off",
216
+ "vue/block-order": ["error", { order: [
217
+ "script",
218
+ "template",
219
+ "style"
220
+ ] }],
221
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
222
+ "vue/component-options-name-casing": ["error", "PascalCase"],
223
+ "vue/component-tags-order": "off",
224
+ "vue/custom-event-name-casing": ["error", "camelCase"],
225
+ "vue/define-macros-order": ["error", { order: [
226
+ "defineOptions",
227
+ "defineProps",
228
+ "defineEmits",
229
+ "defineSlots"
230
+ ] }],
231
+ "vue/dot-location": ["error", "property"],
232
+ "vue/dot-notation": ["error", { allowKeywords: true }],
233
+ "vue/eqeqeq": ["error", "smart"],
234
+ "vue/html-indent": ["error", 2],
235
+ "vue/html-quotes": ["error", "double"],
236
+ "vue/max-attributes-per-line": "off",
237
+ "vue/multi-word-component-names": "off",
238
+ "vue/no-dupe-keys": "off",
239
+ "vue/no-empty-pattern": "error",
240
+ "vue/no-irregular-whitespace": "error",
241
+ "vue/no-loss-of-precision": "error",
242
+ "vue/no-restricted-syntax": [
243
+ "error",
244
+ "DebuggerStatement",
245
+ "LabeledStatement",
246
+ "WithStatement"
247
+ ],
248
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
249
+ "vue/no-setup-props-reactivity-loss": "off",
250
+ "vue/no-sparse-arrays": "error",
251
+ "vue/no-unused-refs": "error",
252
+ "vue/no-useless-v-bind": "error",
253
+ "vue/no-v-html": "off",
254
+ "vue/object-shorthand": [
255
+ "error",
256
+ "always",
257
+ {
258
+ avoidQuotes: true,
259
+ ignoreConstructors: false
260
+ }
261
+ ],
262
+ "vue/prefer-separate-static-class": "error",
263
+ "vue/prefer-template": "error",
264
+ "vue/prop-name-casing": ["error", "camelCase"],
265
+ "vue/require-default-prop": "off",
266
+ "vue/require-prop-types": "off",
267
+ "vue/space-infix-ops": "error",
268
+ "vue/space-unary-ops": ["error", {
269
+ nonwords: false,
270
+ words: true
271
+ }],
272
+ "vue/array-bracket-spacing": ["error", "never"],
273
+ "vue/arrow-spacing": ["error", {
274
+ after: true,
275
+ before: true
276
+ }],
277
+ "vue/block-spacing": ["error", "always"],
278
+ "vue/block-tag-newline": ["error", {
279
+ multiline: "always",
280
+ singleline: "always"
281
+ }],
282
+ "vue/brace-style": [
283
+ "error",
284
+ "stroustrup",
285
+ { allowSingleLine: true }
286
+ ],
287
+ "vue/comma-dangle": ["error", "always-multiline"],
288
+ "vue/comma-spacing": ["error", {
289
+ after: true,
290
+ before: false
291
+ }],
292
+ "vue/comma-style": ["error", "last"],
293
+ "vue/html-comment-content-spacing": [
294
+ "error",
295
+ "always",
296
+ { exceptions: ["-"] }
297
+ ],
298
+ "vue/key-spacing": ["error", {
299
+ afterColon: true,
300
+ beforeColon: false
301
+ }],
302
+ "vue/keyword-spacing": ["error", {
303
+ after: true,
304
+ before: true
305
+ }],
306
+ "vue/object-curly-newline": "off",
307
+ "vue/object-curly-spacing": ["error", "always"],
308
+ "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
309
+ "vue/operator-linebreak": ["error", "before"],
310
+ "vue/padding-line-between-blocks": ["error", "always"],
311
+ "vue/quote-props": ["error", "consistent-as-needed"],
312
+ "vue/space-in-parens": ["error", "never"],
313
+ "vue/template-curly-spacing": "error"
161
314
  }
162
315
  }];
163
- };
316
+ }
317
+
318
+ //#endregion
319
+ //#region src/configs/ignores.ts
320
+ async function ignores() {
321
+ const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
322
+ return [{
323
+ ignores: [...GLOB_EXCLUDE],
324
+ name: "cuiqg/ignores"
325
+ }, configGitignore({
326
+ name: "cuiqg/ignores/gitignore",
327
+ strict: false
328
+ })];
329
+ }
164
330
 
165
331
  //#endregion
166
- //#region src/env.js
167
- const hasTypescript = () => isPackageExists("typescript");
168
- const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli");
169
- const hasUnocss = () => isPackageExists("unocss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
170
- function isInEditor() {
171
- if (process.env.CI) return false;
172
- if (isInGitHooksOrLintStaged()) return false;
173
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
332
+ //#region src/configs/unocss.ts
333
+ async function unocss() {
334
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
335
+ return [{
336
+ name: "cuiqg/unocss",
337
+ plugins: { unocss: pluginUnoCSS },
338
+ rules: { ...renameRules(pluginUnoCSS.configs.recommended.rules, { "@unocss": "unocss" }) }
339
+ }];
174
340
  }
175
- function isInGitHooksOrLintStaged() {
176
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
341
+
342
+ //#endregion
343
+ //#region src/configs/de-morgan.ts
344
+ async function deMorgan() {
345
+ const pluginDeMorgan = await interopDefault(import("eslint-plugin-de-morgan"));
346
+ return [{
347
+ ...pluginDeMorgan.configs.recommended,
348
+ name: "cuiqg/de-morgan"
349
+ }];
177
350
  }
178
351
 
179
352
  //#endregion
180
- //#region src/configs/javascript.js
181
- /**
182
- * JavaScript
183
- *
184
- * @see https://npm.im/@eslint/js
185
- * @returns {import('eslint').Linter.FlatConfig[]}
186
- */
187
- const javascript = async () => {
353
+ //#region src/configs/prettier.ts
354
+ async function prettier() {
355
+ const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
188
356
  return [{
189
- name: "cuiqg/javascript",
357
+ plugins: { prettier: pluginPrettier },
358
+ name: "cuiqg/prettier",
359
+ rules: {
360
+ ...recommendedPrettier.rules,
361
+ "prettier/prettier": "warn"
362
+ }
363
+ }];
364
+ }
365
+
366
+ //#endregion
367
+ //#region src/configs/javascript.ts
368
+ async function javascript() {
369
+ const [pluginUnuseImports, pluginJs] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports")), interopDefault(import("@eslint/js"))]);
370
+ return [{
371
+ name: "cuiqg/javascript/setup",
190
372
  languageOptions: {
373
+ ecmaVersion: "latest",
191
374
  globals: {
192
375
  ...globals.browser,
193
- ...globals.es2021,
376
+ ...globals.es2025,
194
377
  ...globals.node
195
378
  },
196
379
  parserOptions: {
197
380
  ecmaFeatures: { jsx: true },
381
+ ecmaVersion: "latest",
198
382
  sourceType: "module"
199
383
  },
200
384
  sourceType: "module"
201
385
  },
202
- linterOptions: { reportUnusedDisableDirectives: true },
386
+ linterOptions: { reportUnusedDisableDirectives: true }
387
+ }, {
388
+ plugins: {
389
+ "unused-imports": pluginUnuseImports,
390
+ js: pluginJs
391
+ },
392
+ name: "cuiqg/javascript/rules",
203
393
  rules: {
394
+ ...pluginJs.configs.recommended.rules,
204
395
  "accessor-pairs": ["error", {
205
396
  enforceForClassMembers: true,
206
397
  setWithoutGet: true
@@ -210,7 +401,7 @@ const javascript = async () => {
210
401
  "constructor-super": "error",
211
402
  "default-case-last": "error",
212
403
  "dot-notation": ["error", { allowKeywords: true }],
213
- "eqeqeq": ["error", "smart"],
404
+ eqeqeq: ["error", "smart"],
214
405
  "new-cap": ["error", {
215
406
  capIsNew: false,
216
407
  newIsCap: true,
@@ -374,783 +565,126 @@ const javascript = async () => {
374
565
  "prefer-template": "error",
375
566
  "symbol-description": "error",
376
567
  "unicode-bom": ["error", "never"],
568
+ "unused-imports/no-unused-imports": isInEditor() ? "warn" : "error",
569
+ "unused-imports/no-unused-vars": ["error", {
570
+ args: "after-used",
571
+ argsIgnorePattern: "^_",
572
+ ignoreRestSiblings: true,
573
+ vars: "all",
574
+ varsIgnorePattern: "^_"
575
+ }],
377
576
  "use-isnan": ["error", {
378
577
  enforceForIndexOf: true,
379
578
  enforceForSwitchCase: true
380
579
  }],
381
580
  "valid-typeof": ["error", { requireStringLiterals: true }],
382
581
  "vars-on-top": "error",
383
- "yoda": ["error", "never"]
384
- }
385
- }];
386
- };
387
-
388
- //#endregion
389
- //#region src/configs/jsdoc.js
390
- /**
391
- * JsDoc
392
- * @see https://npm.im/eslint-plugin-jsdoc
393
- * @returns {import('eslint').Linter.FlatConfig[]}
394
- */
395
- const jsdoc = async () => {
396
- const pluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
397
- const files = [GLOB_JS];
398
- return [{
399
- files,
400
- name: "cuiqg/jsdoc",
401
- plugins: { jsdoc: pluginJsdoc },
402
- rules: { ...pluginJsdoc.configs["flat/recommended"].rules }
403
- }];
404
- };
405
-
406
- //#endregion
407
- //#region src/configs/jsonc.js
408
- /**
409
- * JSONC
410
- *
411
- * @link https://ota-meshi.github.io/eslint-plugin-jsonc/
412
- * @returns {import('eslint').Linter.FlatConfig[]}
413
- */
414
- const jsonc = async () => {
415
- const files = [
416
- GLOB_JSON,
417
- GLOB_JSON5,
418
- GLOB_JSONC
419
- ];
420
- const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
421
- return [{
422
- name: "cuiqg/jsonc",
423
- files,
424
- plugins: { jsonc: pluginJsonc },
425
- languageOptions: { parser: parserJsonc },
426
- rules: {
427
- ...pluginJsonc.configs["recommended-with-jsonc"].rules,
428
- "jsonc/array-bracket-spacing": ["error", "never"],
429
- "jsonc/comma-dangle": ["error", "never"],
430
- "jsonc/comma-style": ["error", "last"],
431
- "jsonc/indent": ["error", 2],
432
- "jsonc/key-spacing": ["error", {
433
- afterColon: true,
434
- beforeColon: false
435
- }],
436
- "jsonc/object-curly-newline": ["error", {
437
- consistent: true,
438
- multiline: true
439
- }],
440
- "jsonc/object-curly-spacing": ["error", "always"],
441
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
442
- "jsonc/quote-props": "error",
443
- "jsonc/quotes": "error"
444
- }
445
- }];
446
- };
447
-
448
- //#endregion
449
- //#region src/configs/macros.js
450
- /**
451
- * Vue Macros
452
- * @see https://vue-macros.dev/zh-CN/guide/eslint-integration.html
453
- * @returns {import('eslint').Linter.FlatConfig[]}
454
- */
455
- const macros = () => {
456
- return [{
457
- name: "cuiqg/macros",
458
- languageOptions: { globals: {
459
- $: "readonly",
460
- $$: "readonly",
461
- $computed: "readonly",
462
- $customRef: "readonly",
463
- $defineModels: "readonly",
464
- $defineProps: "readonly",
465
- $definePropsRefs: "readonly",
466
- $ref: "readonly",
467
- $shallowRef: "readonly",
468
- $toRef: "readonly",
469
- defineEmit: "readonly",
470
- defineModels: "readonly",
471
- defineOptions: "readonly",
472
- defineProp: "readonly",
473
- defineProps: "readonly",
474
- defineRender: "readonly",
475
- defineSetupComponent: "readonly",
476
- defineSlots: "readonly"
477
- } },
478
- rules: {
479
- "vue/no-export-in-script-setup": "off",
480
- "vue/valid-attribute-name": "off",
481
- "vue/valid-define-props": "off",
482
- "vue/valid-v-bind": "off"
582
+ yoda: ["error", "never"]
483
583
  }
484
584
  }];
485
- };
486
-
487
- //#endregion
488
- //#region src/configs/node.js
489
- /**
490
- * Node
491
- *
492
- * @see https://github.com/eslint-community/eslint-plugin-n
493
- * @returns {import('eslint').Linter.FlatConfig[]}
494
- */
495
- const node = async () => {
496
- const pluginNode = await interopDefault(import("eslint-plugin-n"));
497
- return [{
498
- name: "cuiqg/node",
499
- plugins: { node: pluginNode },
500
- rules: {
501
- "node/handle-callback-err": ["error", "^(err|error)$"],
502
- "node/no-deprecated-api": "error",
503
- "node/no-exports-assign": "error",
504
- "node/no-new-require": "error",
505
- "node/no-path-concat": "error",
506
- "node/prefer-global/buffer": ["error", "never"],
507
- "node/prefer-global/process": ["error", "never"],
508
- "node/process-exit-as-throw": "error"
509
- }
510
- }];
511
- };
512
-
513
- //#endregion
514
- //#region src/configs/pnpm.js
515
- const pnpm = async () => {
516
- const [parserJsonc, parserYaml, pluginPnpm] = await Promise.all([
517
- interopDefault(import("jsonc-eslint-parser")),
518
- interopDefault(import("yaml-eslint-parser")),
519
- interopDefault(import("eslint-plugin-pnpm"))
520
- ]);
521
- return [{
522
- files: ["package.json", "**/package.json"],
523
- languageOptions: { parser: parserJsonc },
524
- name: "cuiqg/pnpm/package-json",
525
- plugins: { pnpm: pluginPnpm },
526
- rules: {
527
- "pnpm/json-enforce-catalog": "error",
528
- "pnpm/json-prefer-workspace-settings": "error",
529
- "pnpm/json-valid-catalog": "error"
530
- }
531
- }, {
532
- files: ["pnpm-workspace.yaml"],
533
- languageOptions: { parser: parserYaml },
534
- name: "cuiqg/pnpm/pnpm-workspace-yaml",
535
- plugins: { pnpm: pluginPnpm },
536
- rules: {
537
- "pnpm/yaml-no-duplicate-catalog-item": "error",
538
- "pnpm/yaml-no-unused-catalog-item": "error",
539
- "yaml/sort-keys": [
540
- "error",
541
- {
542
- order: [
543
- "packages",
544
- "overrides",
545
- "patchedDependencies",
546
- "hoistPattern",
547
- "catalog",
548
- "catalogs",
549
- "allowedDeprecatedVersions",
550
- "allowNonAppliedPatches",
551
- "configDependencies",
552
- "ignoredBuiltDependencies",
553
- "ignoredOptionalDependencies",
554
- "neverBuiltDependencies",
555
- "onlyBuiltDependencies",
556
- "onlyBuiltDependenciesFile",
557
- "packageExtensions",
558
- "peerDependencyRules",
559
- "supportedArchitectures"
560
- ],
561
- pathPattern: "^$"
562
- },
563
- {
564
- order: { type: "asc" },
565
- pathPattern: ".*"
566
- }
567
- ]
568
- }
569
- }];
570
- };
571
-
572
- //#endregion
573
- //#region src/configs/prettier.js
574
- /**
575
- * Prettier
576
- *
577
- * @see https://github.com/prettier/eslint-plugin-prettier
578
- * @returns {import('eslint').Linter.FlatConfig[]}
579
- */
580
- const prettier = async () => {
581
- const [pluginJsonc, pluginPrettier] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("eslint-plugin-prettier"))]);
582
- return [{
583
- name: "cuiqg/prettier",
584
- plugins: { prettier: pluginPrettier },
585
- rules: {
586
- ...pluginPrettier.configs.recommended.rules,
587
- ...pluginJsonc.configs.prettier.rules,
588
- "prettier/prettier": "warn"
589
- }
590
- }];
591
- };
592
-
593
- //#endregion
594
- //#region src/configs/sorts.js
595
- /**
596
- * Sort package.json
597
- *
598
- * Requires `jsonc` config
599
- */
600
- const sortPackageJson = async () => {
601
- return [{
602
- name: "cuiqg/sort/package-json",
603
- files: ["**/package.json"],
604
- rules: {
605
- "jsonc/sort-array-values": ["error", {
606
- order: { type: "asc" },
607
- pathPattern: "^files$"
608
- }],
609
- "jsonc/sort-keys": [
610
- "error",
611
- {
612
- order: [
613
- "name",
614
- "version",
615
- "private",
616
- "packageManager",
617
- "description",
618
- "type",
619
- "keywords",
620
- "license",
621
- "homepage",
622
- "bugs",
623
- "repository",
624
- "author",
625
- "contributors",
626
- "funding",
627
- "files",
628
- "main",
629
- "module",
630
- "types",
631
- "exports",
632
- "typesVersions",
633
- "sideEffects",
634
- "unpkg",
635
- "jsdelivr",
636
- "browser",
637
- "bin",
638
- "man",
639
- "directories",
640
- "publishConfig",
641
- "scripts",
642
- "peerDependencies",
643
- "peerDependenciesMeta",
644
- "optionalDependencies",
645
- "dependencies",
646
- "devDependencies",
647
- "engines",
648
- "config",
649
- "overrides",
650
- "pnpm",
651
- "husky",
652
- "lint-staged",
653
- "eslintConfig",
654
- "prettier"
655
- ],
656
- pathPattern: "^$"
657
- },
658
- {
659
- order: { type: "asc" },
660
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
661
- },
662
- {
663
- order: [
664
- "types",
665
- "require",
666
- "import",
667
- "default"
668
- ],
669
- pathPattern: "^exports.*$"
670
- },
671
- {
672
- order: { type: "asc" },
673
- pathPattern: "^resolutions$"
674
- },
675
- {
676
- order: { type: "asc" },
677
- pathPattern: "^pnpm.overrides$"
678
- }
679
- ]
680
- }
681
- }];
682
- };
683
- /**
684
- * Sort jsconfig.json
685
- *
686
- * Requires `jsonc` config
687
- */
688
- const sortJsconfig = () => {
689
- return [{
690
- name: "cuiqg/sort/jsconfig-json",
691
- files: ["**/jsconfig.json", "**/jsconfig.*.json"],
692
- rules: { "jsonc/sort-keys": [
693
- "error",
694
- {
695
- order: [
696
- "extends",
697
- "compilerOptions",
698
- "references",
699
- "files",
700
- "include",
701
- "exclude"
702
- ],
703
- pathPattern: "^$"
704
- },
705
- {
706
- order: [
707
- "incremental",
708
- "composite",
709
- "tsBuildInfoFile",
710
- "disableSourceOfProjectReferenceRedirect",
711
- "disableSolutionSearching",
712
- "disableReferencedProjectLoad",
713
- "target",
714
- "jsx",
715
- "jsxFactory",
716
- "jsxFragmentFactory",
717
- "jsxImportSource",
718
- "lib",
719
- "moduleDetection",
720
- "noLib",
721
- "reactNamespace",
722
- "useDefineForClassFields",
723
- "emitDecoratorMetadata",
724
- "experimentalDecorators",
725
- "baseUrl",
726
- "rootDir",
727
- "rootDirs",
728
- "customConditions",
729
- "module",
730
- "moduleResolution",
731
- "moduleSuffixes",
732
- "noResolve",
733
- "paths",
734
- "resolveJsonModule",
735
- "resolvePackageJsonExports",
736
- "resolvePackageJsonImports",
737
- "typeRoots",
738
- "types",
739
- "allowArbitraryExtensions",
740
- "allowImportingTsExtensions",
741
- "allowUmdGlobalAccess",
742
- "allowJs",
743
- "checkJs",
744
- "maxNodeModuleJsDepth",
745
- "strict",
746
- "strictBindCallApply",
747
- "strictFunctionTypes",
748
- "strictNullChecks",
749
- "strictPropertyInitialization",
750
- "allowUnreachableCode",
751
- "allowUnusedLabels",
752
- "alwaysStrict",
753
- "exactOptionalPropertyTypes",
754
- "noFallthroughCasesInSwitch",
755
- "noImplicitAny",
756
- "noImplicitOverride",
757
- "noImplicitReturns",
758
- "noImplicitThis",
759
- "noPropertyAccessFromIndexSignature",
760
- "noUncheckedIndexedAccess",
761
- "noUnusedLocals",
762
- "noUnusedParameters",
763
- "useUnknownInCatchVariables",
764
- "declaration",
765
- "declarationDir",
766
- "declarationMap",
767
- "downlevelIteration",
768
- "emitBOM",
769
- "emitDeclarationOnly",
770
- "importHelpers",
771
- "importsNotUsedAsValues",
772
- "inlineSourceMap",
773
- "inlineSources",
774
- "mapRoot",
775
- "newLine",
776
- "noEmit",
777
- "noEmitHelpers",
778
- "noEmitOnError",
779
- "outDir",
780
- "outFile",
781
- "preserveConstEnums",
782
- "preserveValueImports",
783
- "removeComments",
784
- "sourceMap",
785
- "sourceRoot",
786
- "stripInternal",
787
- "allowSyntheticDefaultImports",
788
- "esModuleInterop",
789
- "forceConsistentCasingInFileNames",
790
- "isolatedModules",
791
- "preserveSymlinks",
792
- "verbatimModuleSyntax",
793
- "skipDefaultLibCheck",
794
- "skipLibCheck"
795
- ],
796
- pathPattern: "^compilerOptions$"
797
- }
798
- ] }
799
- }];
800
- };
801
-
802
- //#endregion
803
- //#region src/configs/stylistic.js
804
- /**
805
- * Stylistic
806
- *
807
- * @see https://eslint.style/
808
- * @returns {import('eslint').Linter.FlatConfig[]}
809
- */
810
- const stylistic = async () => {
811
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
812
- const config = pluginStylistic.configs.customize({
813
- flat: true,
814
- pluginName: "style",
815
- indent: 2,
816
- jsx: true,
817
- quotes: "single",
818
- semi: false,
819
- commaDangle: "never"
820
- });
821
- return [{
822
- name: "cuiqg/stylistic",
823
- plugins: { style: pluginStylistic },
824
- rules: { ...config.rules }
825
- }];
826
- };
827
-
828
- //#endregion
829
- //#region src/configs/toml.js
830
- /**
831
- * TOML
832
- *
833
- * @see https://ota-meshi.github.io/eslint-plugin-yml/
834
- * @returns {import('eslint').Linter.FlatConfig[]}
835
- */
836
- const toml = async () => {
837
- const files = [GLOB_TOML];
838
- const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
839
- return [{
840
- name: "cuiqg/toml",
841
- files,
842
- plugins: { toml: pluginToml },
843
- languageOptions: { parser: parserToml },
844
- rules: { ...pluginToml.configs.recommended.rules }
845
- }];
846
- };
847
-
848
- //#endregion
849
- //#region src/configs/unicorn.js
850
- /**
851
- * Unicorn
852
- *
853
- * @see https://github.com/sindresorhus/eslint-plugin-unicorn
854
- * @returns {import('eslint').Linter.FlatConfig[]}
855
- */
856
- const unicorn = async () => {
857
- const pluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
858
- return [{
859
- name: "cuiqg/unicorn",
860
- plugins: { unicorn: pluginUnicorn },
861
- rules: {
862
- "unicorn/consistent-empty-array-spread": "error",
863
- "unicorn/error-message": "error",
864
- "unicorn/escape-case": "error",
865
- "unicorn/new-for-builtins": "error",
866
- "unicorn/no-new-array": "error",
867
- "unicorn/no-new-buffer": "error",
868
- "unicorn/number-literal-case": "error",
869
- "unicorn/prefer-dom-node-text-content": "error",
870
- "unicorn/prefer-includes": "error",
871
- "unicorn/prefer-node-protocol": "error",
872
- "unicorn/prefer-number-properties": "error",
873
- "unicorn/prefer-string-starts-ends-with": "error",
874
- "unicorn/prefer-type-error": "error",
875
- "unicorn/throw-new-error": "error"
876
- }
877
- }];
878
- };
879
-
880
- //#endregion
881
- //#region src/configs/unocss.js
882
- /**
883
- * UnoCSS
884
- *
885
- * @see https://unocss.dev/integrations/eslint
886
- * @returns {import('eslint').Linter.FlatConfig[]}
887
- */
888
- const unocss = async () => {
889
- const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
890
- return [{
891
- ...pluginUnoCSS.configs.flat,
892
- name: "cuiqg/unocss"
893
- }];
894
- };
895
-
896
- //#endregion
897
- //#region src/configs/unplugin.js
898
- /**
899
- * UnPlugin
900
- * @returns {import('eslint').Linter.FlatConfig[]}
901
- */
902
- const unplugin = async () => {
903
- const resolved = resolve(process.cwd(), `./.eslintrc-auto-import.json`);
904
- let globals$1 = {};
905
- if (fs.existsSync(resolved) && fs.statSync(resolved).isFile) {
906
- const cwd = dirname(resolved);
907
- const { config } = await loadConfig({
908
- sources: [{
909
- files: resolved,
910
- extensions: [],
911
- rewrite(config$1) {
912
- return config$1?.globals;
913
- }
914
- }],
915
- cwd
916
- });
917
- globals$1 = { ...config };
918
- }
919
- return [{
920
- name: "cuiqg/unplugin/auto-import",
921
- languageOptions: { globals: globals$1 }
922
- }];
923
- };
585
+ }
924
586
 
925
587
  //#endregion
926
- //#region src/configs/vue.js
927
- /**
928
- * Vue
929
- *
930
- * @see https://eslint.vuejs.org/
931
- * @returns {import('eslint').Linter.FlatConfig[]}
932
- */
933
- const vue = async () => {
934
- const files = [GLOB_VUE];
935
- const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
588
+ //#region src/configs/typescript.ts
589
+ async function typescript() {
590
+ const files = [GLOB_TS, GLOB_TSX];
591
+ const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
936
592
  return [{
937
593
  files,
594
+ name: "cuiqg/typescript/setup",
595
+ plugins: { ts: pluginTs },
938
596
  languageOptions: {
939
- globals: {
940
- computed: "readonly",
941
- defineModel: "readonly",
942
- defineOptions: "readonly",
943
- defineProps: "readonly",
944
- defineRender: "readonly",
945
- defineSlots: "readonly",
946
- defineEmits: "readonly",
947
- defineExpose: "readonly",
948
- definePage: "readonly",
949
- onMounted: "readonly",
950
- onUnmounted: "readonly",
951
- onActivated: "readonly",
952
- onDeactivated: "readonly",
953
- reactive: "readonly",
954
- ref: "readonly",
955
- shallowReactive: "readonly",
956
- shallowRef: "readonly",
957
- toRef: "readonly",
958
- toRefs: "readonly",
959
- watch: "readonly",
960
- watchEffect: "readonly"
961
- },
962
- parser: parserVue,
597
+ parser: parserTs,
963
598
  parserOptions: {
964
599
  ecmaFeatures: { jsx: true },
965
- extraFileExtensions: [".vue"],
966
- parser: null,
967
- sourceType: "module"
600
+ ecmaVersion: "latest",
601
+ projectService: true,
602
+ sourceType: "module",
603
+ tsconfigRootDir: process.cwd()
968
604
  }
969
- },
970
- name: "cuiqg/vue",
971
- plugins: { vue: pluginVue },
972
- processor: pluginVue.processors[".vue"],
605
+ }
606
+ }, {
607
+ name: "cuiqg/typescript/rules",
973
608
  rules: {
974
- ...pluginVue.configs.base.rules,
975
- ...pluginVue.configs["flat/essential"].rules,
976
- ...pluginVue.configs["flat/strongly-recommended"].rules,
977
- ...pluginVue.configs["flat/recommended"].rules,
978
- "vue/block-order": ["error", { order: [
979
- "script",
980
- "template",
981
- "style",
982
- "route"
983
- ] }],
984
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
985
- "vue/component-options-name-casing": ["error", "PascalCase"],
986
- "vue/component-tags-order": "off",
987
- "vue/custom-event-name-casing": ["error", "camelCase"],
988
- "vue/define-macros-order": ["error", { order: [
989
- "defineOptions",
990
- "defineProps",
991
- "defineEmits",
992
- "defineSlots"
993
- ] }],
994
- "vue/dot-location": ["error", "property"],
995
- "vue/dot-notation": ["error", { allowKeywords: true }],
996
- "vue/eqeqeq": ["error", "smart"],
997
- "vue/html-indent": ["error", 2],
998
- "vue/html-quotes": ["error", "double"],
999
- "vue/max-attributes-per-line": ["error", {
1000
- singleline: { max: 1 },
1001
- multiline: { max: 1 }
1002
- }],
1003
- "vue/multi-word-component-names": "off",
1004
- "vue/no-dupe-keys": "off",
1005
- "vue/no-empty-pattern": "error",
1006
- "vue/no-irregular-whitespace": "error",
1007
- "vue/no-loss-of-precision": "error",
1008
- "vue/no-restricted-syntax": [
1009
- "error",
1010
- "DebuggerStatement",
1011
- "LabeledStatement",
1012
- "WithStatement"
1013
- ],
1014
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1015
- "vue/no-setup-props-reactivity-loss": "off",
1016
- "vue/no-sparse-arrays": "error",
1017
- "vue/no-unused-refs": "error",
1018
- "vue/no-useless-v-bind": "error",
1019
- "vue/no-v-html": "off",
1020
- "vue/object-shorthand": [
1021
- "error",
1022
- "always",
1023
- {
1024
- avoidQuotes: true,
1025
- ignoreConstructors: false
1026
- }
1027
- ],
1028
- "vue/prefer-separate-static-class": "error",
1029
- "vue/prefer-template": "error",
1030
- "vue/prop-name-casing": ["error", "camelCase"],
1031
- "vue/require-default-prop": "off",
1032
- "vue/require-prop-types": "off",
1033
- "vue/space-infix-ops": "error",
1034
- "vue/space-unary-ops": ["error", {
1035
- nonwords: false,
1036
- words: true
1037
- }],
1038
- "vue/array-bracket-spacing": ["error", "never"],
1039
- "vue/arrow-spacing": ["error", {
1040
- after: true,
1041
- before: true
1042
- }],
1043
- "vue/block-spacing": ["error", "always"],
1044
- "vue/block-tag-newline": ["error", {
1045
- multiline: "always",
1046
- singleline: "always"
609
+ ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
610
+ ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
611
+ "no-dupe-class-members": "off",
612
+ "no-redeclare": "off",
613
+ "no-use-before-define": "off",
614
+ "no-useless-constructor": "off",
615
+ "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
616
+ "ts/consistent-type-definitions": ["error", "interface"],
617
+ "ts/consistent-type-imports": ["error", {
618
+ disallowTypeAnnotations: false,
619
+ fixStyle: "separate-type-imports",
620
+ prefer: "type-imports"
1047
621
  }],
1048
- "vue/brace-style": [
1049
- "error",
1050
- "stroustrup",
1051
- { allowSingleLine: true }
1052
- ],
1053
- "vue/comma-dangle": ["error", "always-multiline"],
1054
- "vue/comma-spacing": ["error", {
1055
- after: true,
1056
- before: false
1057
- }],
1058
- "vue/comma-style": ["error", "last"],
1059
- "vue/html-comment-content-spacing": [
1060
- "error",
1061
- "always",
1062
- { exceptions: ["-"] }
1063
- ],
1064
- "vue/key-spacing": ["error", {
1065
- afterColon: true,
1066
- beforeColon: false
622
+ "ts/method-signature-style": ["error", "property"],
623
+ "ts/no-dupe-class-members": "error",
624
+ "ts/no-dynamic-delete": "off",
625
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
626
+ "ts/no-explicit-any": "off",
627
+ "ts/no-extraneous-class": "off",
628
+ "ts/no-import-type-side-effects": "error",
629
+ "ts/no-invalid-void-type": "off",
630
+ "ts/no-non-null-assertion": "off",
631
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
632
+ "ts/no-require-imports": "error",
633
+ "ts/no-unused-expressions": ["error", {
634
+ allowShortCircuit: true,
635
+ allowTaggedTemplates: true,
636
+ allowTernary: true
1067
637
  }],
1068
- "vue/keyword-spacing": ["error", {
1069
- after: true,
1070
- before: true
638
+ "ts/no-unused-vars": "off",
639
+ "ts/no-use-before-define": ["error", {
640
+ classes: false,
641
+ functions: false,
642
+ variables: true
1071
643
  }],
1072
- "vue/object-curly-newline": "off",
1073
- "vue/object-curly-spacing": ["error", "always"],
1074
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1075
- "vue/operator-linebreak": ["error", "before"],
1076
- "vue/padding-line-between-blocks": ["error", "always"],
1077
- "vue/quote-props": ["error", "consistent-as-needed"],
1078
- "vue/space-in-parens": ["error", "never"],
1079
- "vue/template-curly-spacing": "error",
1080
- "vue/no-export-in-script-setup": "off",
1081
- "vue/valid-attribute-name": "off",
1082
- "vue/valid-define-props": "off",
1083
- "vue/valid-v-bind": "off",
1084
- "vue/no-unused-vars": "off"
644
+ "ts/no-useless-constructor": "off",
645
+ "ts/no-wrapper-object-types": "error",
646
+ "ts/triple-slash-reference": "off",
647
+ "ts/unified-signatures": "off"
1085
648
  }
1086
649
  }];
1087
- };
1088
-
1089
- //#endregion
1090
- //#region src/configs/yaml.js
1091
- /**
1092
- * Yaml
1093
- *
1094
- * @see https://ota-meshi.github.io/eslint-plugin-yml/
1095
- * @returns {import('eslint').Linter.FlatConfig[]}
1096
- */
1097
- const yaml = async () => {
1098
- const files = [GLOB_YAML];
1099
- const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
1100
- return [{
1101
- name: "cuiqg/yaml",
1102
- files,
1103
- plugins: { yaml: pluginYaml },
1104
- languageOptions: { parser: parserYaml },
1105
- rules: {
1106
- ...pluginYaml.configs.recommended.rules,
1107
- ...pluginYaml.configs.prettier.rules
1108
- }
1109
- }];
1110
- };
650
+ }
1111
651
 
1112
652
  //#endregion
1113
- //#region src/presets.js
653
+ //#region src/presets.ts
1114
654
  const defaultPluginRenaming = {
1115
- "@stylistic": "style",
1116
- "import-x": "import",
1117
- "n": "node",
1118
- "yml": "yaml",
655
+ "@next/next": "next",
656
+ n: "node",
657
+ vitest: "test",
658
+ yml: "yaml",
1119
659
  "@typescript-eslint": "ts"
1120
660
  };
1121
661
  function cuiqg(options = {}, ...userConfigs) {
1122
- const { prettier: enablePrettier = false, gitignore: enableGitignore = true, unocss: enableUnocss = hasUnocss, vue: enableVue = hasVue, stylistic: enableStylistic = true, jsdoc: enableJsdoc = false, pnpm: enablePnpm = false } = options;
662
+ const { prettier: enablePrettier = false, typescript: enableTypeScript = hasTypeScript(), vue: enableVue = hasVue(), unocss: enableUnocss = hasUnoCss(), nextjs: enableNextjs = hasNextjs() } = options;
1123
663
  const configs = [
1124
- unplugin(),
664
+ packageJson(),
1125
665
  ignores(),
1126
- javascript(),
1127
- comments(),
1128
666
  node(),
1129
- imports(),
1130
- unicorn(),
1131
- macros(),
1132
- jsonc(),
1133
- sortPackageJson(),
1134
- sortJsconfig(),
1135
- yaml(),
1136
- toml(),
1137
- disables()
667
+ deMorgan(),
668
+ javascript()
1138
669
  ];
1139
- if (enableGitignore) configs.push(gitignore());
1140
- if (enableStylistic) configs.push(stylistic());
670
+ if (enableTypeScript) configs.push(typescript());
1141
671
  if (enableVue) configs.push(vue());
1142
672
  if (enableUnocss) configs.push(unocss());
673
+ if (enableNextjs) configs.push(nextjs());
1143
674
  if (enablePrettier) configs.push(prettier());
1144
- if (enableJsdoc) configs.push(jsdoc());
1145
- if (enablePnpm) configs.push(pnpm());
1146
- let composer = new FlatConfigComposer(...configs, ...userConfigs);
1147
- composer = composer.renamePlugins(defaultPluginRenaming);
675
+ let composer = new FlatConfigComposer();
676
+ composer = composer.append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
677
+ if (isInEditor()) composer = composer.disableRulesFix([
678
+ "unused-imports/no-unused-imports",
679
+ "test/no-only-tests",
680
+ "prefer-const"
681
+ ], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
1148
682
  return composer;
1149
683
  }
1150
684
 
1151
685
  //#endregion
1152
- //#region src/index.js
686
+ //#region src/index.ts
1153
687
  var src_default = cuiqg;
1154
688
 
1155
689
  //#endregion
1156
- export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, comments, cuiqg, src_default as default, defaultPluginRenaming, disables, gitignore, hasTypescript, hasUnocss, hasVue, ignores, imports, interopDefault, isInEditor, isInGitHooksOrLintStaged, javascript, jsdoc, jsonc, macros, node, pnpm, prettier, sortJsconfig, sortPackageJson, stylistic, toml, unicorn, unocss, unplugin, vue, yaml };
690
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, deMorgan, src_default as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, nextjs, node, packageJson, prettier, typescript, unocss, vue };