@eienjs/eslint-config 1.2.2 → 1.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.
Files changed (76) hide show
  1. package/dist/cli/constants.js +74 -0
  2. package/dist/cli/constants_generated.js +13 -0
  3. package/dist/cli/index.d.ts +1 -1
  4. package/dist/cli/index.js +3 -268
  5. package/dist/cli/run.js +77 -0
  6. package/dist/cli/stages/update_eslint_files.js +39 -0
  7. package/dist/cli/stages/update_package_json.js +46 -0
  8. package/dist/cli/stages/update_vscode_settings.js +30 -0
  9. package/dist/cli/utils.js +23 -0
  10. package/dist/configs/adonisjs.d.ts +6 -0
  11. package/dist/configs/adonisjs.js +115 -0
  12. package/dist/configs/astro.d.ts +6 -0
  13. package/dist/configs/astro.js +52 -0
  14. package/dist/configs/command.d.ts +6 -0
  15. package/dist/configs/command.js +12 -0
  16. package/dist/configs/comments.d.ts +6 -0
  17. package/dist/configs/comments.js +19 -0
  18. package/dist/configs/disables.d.ts +6 -0
  19. package/dist/configs/disables.js +85 -0
  20. package/dist/configs/formatters.d.ts +6 -0
  21. package/dist/configs/formatters.js +134 -0
  22. package/dist/configs/ignores.d.ts +6 -0
  23. package/dist/configs/ignores.js +12 -0
  24. package/dist/configs/imports.d.ts +6 -0
  25. package/dist/configs/imports.js +28 -0
  26. package/dist/configs/index.d.ts +25 -95
  27. package/dist/configs/index.js +25 -1
  28. package/dist/configs/javascript.d.ts +6 -0
  29. package/dist/configs/javascript.js +289 -0
  30. package/dist/configs/jsdoc.d.ts +6 -0
  31. package/dist/configs/jsdoc.js +34 -0
  32. package/dist/configs/jsonc.d.ts +6 -0
  33. package/dist/configs/jsonc.js +71 -0
  34. package/dist/configs/markdown.d.ts +6 -0
  35. package/dist/configs/markdown.js +67 -0
  36. package/dist/configs/node.d.ts +6 -0
  37. package/dist/configs/node.js +22 -0
  38. package/dist/configs/nuxt.d.ts +6 -0
  39. package/dist/configs/nuxt.js +137 -0
  40. package/dist/configs/perfectionist.d.ts +12 -0
  41. package/dist/configs/perfectionist.js +56 -0
  42. package/dist/configs/pnpm.d.ts +6 -0
  43. package/dist/configs/pnpm.js +33 -0
  44. package/dist/configs/regexp.d.ts +6 -0
  45. package/dist/configs/regexp.js +21 -0
  46. package/dist/configs/sort.d.ts +18 -0
  47. package/dist/configs/sort.js +239 -0
  48. package/dist/configs/stylistic.d.ts +8 -0
  49. package/dist/configs/stylistic.js +76 -0
  50. package/dist/configs/test.d.ts +6 -0
  51. package/dist/configs/test.js +42 -0
  52. package/dist/configs/toml.d.ts +6 -0
  53. package/dist/configs/toml.js +45 -0
  54. package/dist/configs/typescript.d.ts +6 -0
  55. package/dist/configs/typescript.js +237 -0
  56. package/dist/configs/unicorn.d.ts +6 -0
  57. package/dist/configs/unicorn.js +42 -0
  58. package/dist/configs/vue.d.ts +6 -0
  59. package/dist/configs/vue.js +206 -0
  60. package/dist/configs/yaml.d.ts +6 -0
  61. package/dist/configs/yaml.js +83 -0
  62. package/dist/factory.d.ts +17 -0
  63. package/dist/factory.js +161 -0
  64. package/dist/globs.d.ts +32 -0
  65. package/dist/globs.js +89 -0
  66. package/dist/index.d.ts +6 -86
  67. package/dist/index.js +3 -133
  68. package/dist/package.js +5 -0
  69. package/dist/plugins.js +9 -0
  70. package/dist/{types-ClRJcxpY.d.ts → typegen.d.ts} +446 -747
  71. package/dist/types.d.ts +426 -0
  72. package/dist/utils.d.ts +42 -0
  73. package/dist/utils.js +62 -0
  74. package/dist/vendored/prettier_types.d.ts +121 -0
  75. package/package.json +45 -33
  76. package/dist/configs-D_4UWxl6.js +0 -2192
@@ -1,2192 +0,0 @@
1
- import { isPackageExists } from "local-pkg";
2
- import { join } from "pathe";
3
- import process from "node:process";
4
- import { fileURLToPath } from "node:url";
5
- import createCommand from "eslint-plugin-command/config";
6
- import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
7
- import pluginAntfu from "eslint-plugin-antfu";
8
- import pluginImportLite from "eslint-plugin-import-lite";
9
- import pluginNode from "eslint-plugin-n";
10
- import pluginPerfectionist from "eslint-plugin-perfectionist";
11
- import pluginUnicorn from "eslint-plugin-unicorn";
12
- import pluginUnusedImports from "eslint-plugin-unused-imports";
13
- import globals from "globals";
14
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
15
- import { configs } from "eslint-plugin-regexp";
16
-
17
- //#region src/globs.ts
18
- const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
19
- const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
20
- const GLOB_JS = "**/*.?([cm])js";
21
- const GLOB_JSX = "**/*.?([cm])jsx";
22
- const GLOB_TS = "**/*.?([cm])ts";
23
- const GLOB_TSX = "**/*.?([cm])tsx";
24
- const GLOB_STYLE = "**/*.{c,le,sc}ss";
25
- const GLOB_CSS = "**/*.css";
26
- const GLOB_POSTCSS = "**/*.{p,post}css";
27
- const GLOB_LESS = "**/*.less";
28
- const GLOB_SCSS = "**/*.scss";
29
- const GLOB_JSON = "**/*.json";
30
- const GLOB_JSON5 = "**/*.json5";
31
- const GLOB_JSONC = "**/*.jsonc";
32
- const GLOB_MARKDOWN = "**/*.md";
33
- const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
34
- const GLOB_VUE = "**/*.vue";
35
- const GLOB_YAML = "**/*.y?(a)ml";
36
- const GLOB_TOML = "**/*.toml";
37
- const GLOB_XML = "**/*.xml";
38
- const GLOB_SVG = "**/*.svg";
39
- const GLOB_HTML = "**/*.htm?(l)";
40
- const GLOB_ASTRO = "**/*.astro";
41
- const GLOB_ASTRO_TS = "**/*.astro/*.ts";
42
- const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
43
- const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
44
- const GLOB_TESTS = [
45
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
46
- `**/*.spec.${GLOB_SRC_EXT}`,
47
- `**/*.test.${GLOB_SRC_EXT}`,
48
- `**/*.bench.${GLOB_SRC_EXT}`,
49
- `**/*.benchmark.${GLOB_SRC_EXT}`
50
- ];
51
- const GLOB_ALL_SRC = [
52
- GLOB_SRC,
53
- GLOB_STYLE,
54
- GLOB_JSON,
55
- GLOB_JSON5,
56
- GLOB_MARKDOWN,
57
- GLOB_VUE,
58
- GLOB_YAML,
59
- GLOB_XML,
60
- GLOB_HTML
61
- ];
62
- const GLOB_EXCLUDE = [
63
- "**/node_modules",
64
- "**/dist",
65
- "**/build",
66
- "**/package-lock.json",
67
- "**/yarn.lock",
68
- "**/pnpm-lock.yaml",
69
- "**/bun.lockb",
70
- "**/composer.lock",
71
- "**/composer.json",
72
- "**/output",
73
- "**/coverage",
74
- "**/temp",
75
- "**/.temp",
76
- "**/tmp",
77
- "**/.tmp",
78
- "**/vendor",
79
- "**/public",
80
- "**/.history",
81
- "**/.vitepress/cache",
82
- "**/.adonisjs",
83
- "**/.nuxt",
84
- "**/.next",
85
- "**/.svelte-kit",
86
- "**/.vercel",
87
- "**/.husky",
88
- "**/.changeset",
89
- "**/.idea",
90
- "**/.cache",
91
- "**/.output",
92
- "**/.vite-inspect",
93
- "**/.yarn",
94
- "**/.pnpm-store",
95
- "**/vite.config.*.timestamp-*",
96
- "**/CHANGELOG*.md",
97
- "**/*.min.*",
98
- "**/LICENSE*",
99
- "**/__snapshots__",
100
- "**/auto-import?(s).d.ts",
101
- "**/components.d.ts"
102
- ];
103
-
104
- //#endregion
105
- //#region src/utils.ts
106
- const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
107
- const isCwdInScope = isPackageExists("@eienjs/eslint-config");
108
- const parserPlain = {
109
- meta: { name: "parser-plain" },
110
- parseForESLint: (code) => ({
111
- ast: {
112
- body: [],
113
- comments: [],
114
- loc: {
115
- end: code.length,
116
- start: 0
117
- },
118
- range: [0, code.length],
119
- tokens: [],
120
- type: "Program"
121
- },
122
- scopeManager: null,
123
- services: { isPlain: true },
124
- visitorKeys: { Program: [] }
125
- })
126
- };
127
- /**
128
- * Combine array and non-array configs into a single array.
129
- */
130
- async function combine(...configs$1) {
131
- const resolved = await Promise.all(configs$1);
132
- return resolved.flat();
133
- }
134
- function toArray(value) {
135
- return Array.isArray(value) ? value : [value];
136
- }
137
- async function interopDefault(m) {
138
- const resolved = await m;
139
- return resolved.default || resolved;
140
- }
141
- function isPackageInScope(name) {
142
- return isPackageExists(name, { paths: [scopeUrl] });
143
- }
144
- async function ensurePackages(packages) {
145
- if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
146
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
147
- if (nonExistingPackages.length === 0) return;
148
- const p = await import("@clack/prompts");
149
- const packagesMissing = nonExistingPackages.join(", ");
150
- const packagesMissingPlural = nonExistingPackages.length === 1 ? "Package is" : "Packages are";
151
- const result = await p.confirm({ message: `${packagesMissingPlural} required for this config: ${packagesMissing}. Do you want to install them?` });
152
- if (result) await import("@antfu/install-pkg").then(async (i) => i.installPackage(nonExistingPackages, { dev: true }));
153
- }
154
- function isInEditorEnv() {
155
- if (process.env.CI) return false;
156
- if (isInGitHooksOrLintStaged()) return false;
157
- return Boolean(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
158
- }
159
- function isInGitHooksOrLintStaged() {
160
- return Boolean(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
161
- }
162
-
163
- //#endregion
164
- //#region src/configs/adonisjs.ts
165
- async function adonisjs(options = {}) {
166
- const { overrides = {}, dirs = {} } = options;
167
- await ensurePackages(["@adonisjs/eslint-plugin"]);
168
- const pluginAdonisJS = await interopDefault(import("@adonisjs/eslint-plugin"));
169
- dirs.root = dirs.root || ".";
170
- const appPath = `${dirs.root}/app`;
171
- dirs.controllers = dirs.controllers || `${appPath}/controllers`;
172
- dirs.exceptions = dirs.exceptions || `${appPath}/exceptions`;
173
- dirs.models = dirs.models || `${appPath}/models`;
174
- dirs.mails = dirs.mails || `${appPath}/mails`;
175
- dirs.services = dirs.services || `${appPath}/services`;
176
- dirs.listeners = dirs.listeners || `${appPath}/listeners`;
177
- dirs.events = dirs.events || `${appPath}/events`;
178
- dirs.middleware = dirs.middleware || `${appPath}/middleware`;
179
- dirs.validators = dirs.validators || `${appPath}/validators`;
180
- dirs.policies = dirs.policies || `${appPath}/policies`;
181
- dirs.abilities = dirs.abilities || `${appPath}/abilities`;
182
- dirs.providers = dirs.providers || `${dirs.root}/providers`;
183
- dirs.database = dirs.database || `${dirs.root}/database`;
184
- dirs.bin = dirs.bin || `${dirs.root}/bin`;
185
- dirs.start = dirs.start || `${dirs.root}/start`;
186
- dirs.tests = dirs.tests || `${dirs.root}/tests`;
187
- dirs.config = dirs.config || `${dirs.root}/config`;
188
- dirs.commands = dirs.commands || `${dirs.root}/commands`;
189
- const nestedGlobPattern = `**/*.${GLOB_SRC_EXT}`;
190
- const fileRoutes = [...Object.values(dirs).map((dir) => join(dir, nestedGlobPattern)), `${dirs.root}/ace.js`];
191
- const commonRulesSet = {
192
- "@typescript-eslint/require-await": "off",
193
- "@typescript-eslint/explicit-function-return-type": "off",
194
- "@typescript-eslint/explicit-module-boundary-types": "off",
195
- "@typescript-eslint/no-floating-promises": "off",
196
- "@typescript-eslint/no-unsafe-return": "off",
197
- "unicorn/no-anonymous-default-export": "off"
198
- };
199
- return [
200
- {
201
- name: "eienjs/adonisjs/rules",
202
- plugins: { "@adonisjs": pluginAdonisJS },
203
- rules: {
204
- "@adonisjs/prefer-lazy-controller-import": "error",
205
- "@adonisjs/prefer-lazy-listener-import": "error",
206
- ...overrides
207
- }
208
- },
209
- {
210
- files: fileRoutes,
211
- name: "eienjs/adonisjs/disables",
212
- rules: { "antfu/no-top-level-await": "off" }
213
- },
214
- {
215
- files: [join(dirs.database, nestedGlobPattern)],
216
- name: "eienjs/adonisjs/database-disables",
217
- rules: { ...commonRulesSet }
218
- },
219
- {
220
- files: [join(dirs.bin, nestedGlobPattern)],
221
- name: "eienjs/adonisjs/bin-disables",
222
- rules: {
223
- ...commonRulesSet,
224
- "@typescript-eslint/no-misused-promises": "off"
225
- }
226
- },
227
- {
228
- files: [join(dirs.commands, nestedGlobPattern)],
229
- name: "eienjs/adonisjs/commands-disables",
230
- rules: { ...commonRulesSet }
231
- },
232
- {
233
- files: [join(dirs.middleware, nestedGlobPattern)],
234
- name: "eienjs/adonisjs/middleware-disables",
235
- rules: { ...commonRulesSet }
236
- },
237
- {
238
- files: [join(dirs.exceptions, nestedGlobPattern)],
239
- name: "eienjs/adonisjs/exceptions-disables",
240
- rules: { ...commonRulesSet }
241
- },
242
- {
243
- files: [join(dirs.controllers, nestedGlobPattern)],
244
- name: "eienjs/adonisjs/controllers-disables",
245
- rules: {
246
- "@typescript-eslint/explicit-function-return-type": "off",
247
- "@typescript-eslint/explicit-module-boundary-types": "off"
248
- }
249
- },
250
- {
251
- files: [join(dirs.config, nestedGlobPattern)],
252
- name: "eienjs/adonisjs/config-disables",
253
- rules: { "@typescript-eslint/consistent-type-definitions": "off" }
254
- },
255
- {
256
- files: [join(dirs.providers, nestedGlobPattern)],
257
- name: "eienjs/adonisjs/providers-disables",
258
- rules: { "@typescript-eslint/consistent-type-definitions": "off" }
259
- },
260
- {
261
- files: [join(dirs.tests, nestedGlobPattern)],
262
- name: "eienjs/adonisjs/tests-disables",
263
- rules: {
264
- "@typescript-eslint/unbound-method": "off",
265
- "@typescript-eslint/explicit-function-return-type": "off",
266
- "@typescript-eslint/explicit-module-boundary-types": "off",
267
- "@typescript-eslint/no-unsafe-assignment": "off"
268
- }
269
- }
270
- ];
271
- }
272
-
273
- //#endregion
274
- //#region src/configs/astro.ts
275
- async function astro(options = {}) {
276
- const { files = [GLOB_ASTRO], overrides = {}, stylistic: stylistic$1 = true } = options;
277
- const [pluginAstro, parserAstro, parserTs] = await Promise.all([
278
- interopDefault(import("eslint-plugin-astro")),
279
- interopDefault(import("astro-eslint-parser")),
280
- interopDefault(import("@typescript-eslint/parser"))
281
- ]);
282
- return [{
283
- name: "eienjs/astro/setup",
284
- plugins: { astro: pluginAstro }
285
- }, {
286
- files,
287
- languageOptions: {
288
- globals: pluginAstro.environments.astro.globals,
289
- parser: parserAstro,
290
- parserOptions: {
291
- extraFileExtensions: [".astro"],
292
- parser: parserTs
293
- },
294
- sourceType: "module"
295
- },
296
- name: "eienjs/astro/rules",
297
- processor: "astro/client-side-ts",
298
- rules: {
299
- "antfu/no-top-level-await": "off",
300
- "astro/missing-client-only-directive-value": "error",
301
- "astro/no-conflict-set-directives": "error",
302
- "astro/no-deprecated-astro-canonicalurl": "error",
303
- "astro/no-deprecated-astro-fetchcontent": "error",
304
- "astro/no-deprecated-astro-resolve": "error",
305
- "astro/no-deprecated-getentrybyslug": "error",
306
- "astro/no-set-html-directive": "off",
307
- "astro/no-unused-define-vars-in-style": "error",
308
- "astro/semi": "off",
309
- "astro/valid-compile": "error",
310
- ...stylistic$1 ? {} : {
311
- "@stylistic/indent": "off",
312
- "@stylistic/jsx-closing-tag-location": "off",
313
- "@stylistic/jsx-one-expression-per-line": "off",
314
- "@stylistic/no-multiple-empty-lines": "off"
315
- },
316
- ...overrides
317
- }
318
- }];
319
- }
320
-
321
- //#endregion
322
- //#region src/configs/command.ts
323
- function command() {
324
- return [{
325
- ...createCommand(),
326
- name: "eienjs/command/rules"
327
- }];
328
- }
329
-
330
- //#endregion
331
- //#region src/configs/comments.ts
332
- function comments() {
333
- return [{
334
- name: "eienjs/eslint-comments/rules",
335
- plugins: { "@eslint-community/eslint-comments": pluginComments },
336
- rules: {
337
- "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
338
- "@eslint-community/eslint-comments/no-aggregating-enable": "error",
339
- "@eslint-community/eslint-comments/no-duplicate-disable": "error",
340
- "@eslint-community/eslint-comments/no-unlimited-disable": "error",
341
- "@eslint-community/eslint-comments/no-unused-enable": "error"
342
- }
343
- }];
344
- }
345
-
346
- //#endregion
347
- //#region src/configs/disables.ts
348
- function disables() {
349
- return [
350
- {
351
- files: [`**/scripts/${GLOB_SRC}`],
352
- name: "eienjs/disables/scripts",
353
- rules: {
354
- "antfu/no-top-level-await": "off",
355
- "no-console": "off",
356
- "@typescript-eslint/explicit-function-return-type": "off",
357
- "@typescript-eslint/no-deprecated": "off"
358
- }
359
- },
360
- {
361
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
362
- name: "eienjs/disables/cli",
363
- rules: {
364
- "antfu/no-top-level-await": "off",
365
- "no-console": "off",
366
- "unicorn/no-process-exit": "off",
367
- "@typescript-eslint/no-unnecessary-condition": "off"
368
- }
369
- },
370
- {
371
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
372
- name: "eienjs/disables/bin",
373
- rules: {
374
- "antfu/no-import-dist": "off",
375
- "antfu/no-import-node-modules-by-path": "off"
376
- }
377
- },
378
- {
379
- files: ["**/*.d.?([cm])ts"],
380
- name: "eienjs/disables/dts",
381
- rules: {
382
- "@eslint-community/eslint-comments/no-unlimited-disable": "off",
383
- "no-restricted-syntax": "off",
384
- "unused-imports/no-unused-vars": "off"
385
- }
386
- },
387
- {
388
- files: ["**/*.js", "**/*.cjs"],
389
- name: "eienjs/disables/cjs",
390
- rules: { "@typescript-eslint/no-require-imports": "off" }
391
- },
392
- {
393
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
394
- name: "eienjs/disables/config-files",
395
- rules: {
396
- "antfu/no-top-level-await": "off",
397
- "no-console": "off",
398
- "@typescript-eslint/explicit-function-return-type": "off"
399
- }
400
- },
401
- {
402
- files: [
403
- GLOB_JSON,
404
- GLOB_JSON5,
405
- GLOB_JSONC
406
- ],
407
- name: "eienjs/disables/json",
408
- rules: { "@stylistic/max-len": "off" }
409
- },
410
- {
411
- files: [GLOB_YAML],
412
- name: "eienjs/disables/yaml",
413
- rules: { "@stylistic/max-len": "off" }
414
- },
415
- {
416
- files: [GLOB_TOML],
417
- name: "eienjs/disables/toml",
418
- rules: { "@stylistic/max-len": "off" }
419
- },
420
- {
421
- files: [GLOB_ASTRO],
422
- name: "eienjs/disables/astro",
423
- rules: { "@stylistic/max-len": "off" }
424
- }
425
- ];
426
- }
427
-
428
- //#endregion
429
- //#region src/configs/stylistic.ts
430
- const StylisticConfigDefaults = {
431
- indent: 2,
432
- quotes: "single"
433
- };
434
- async function stylistic(options = {}) {
435
- const { indent, overrides = {}, quotes, maxLineLength = 120 } = {
436
- ...StylisticConfigDefaults,
437
- ...options
438
- };
439
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
440
- const config = pluginStylistic.configs.customize({
441
- indent,
442
- quotes,
443
- semi: true
444
- });
445
- return [{
446
- name: "eienjs/stylistic/rules",
447
- plugins: {
448
- "antfu": pluginAntfu,
449
- "@stylistic": pluginStylistic
450
- },
451
- rules: {
452
- ...config.rules,
453
- "antfu/consistent-chaining": "error",
454
- "antfu/consistent-list-newline": "error",
455
- "@stylistic/arrow-parens": ["error", "always"],
456
- "@stylistic/brace-style": [
457
- "error",
458
- "1tbs",
459
- { allowSingleLine: true }
460
- ],
461
- "@stylistic/max-len": ["warn", {
462
- code: maxLineLength,
463
- ignoreComments: true
464
- }],
465
- "@stylistic/padding-line-between-statements": [
466
- "error",
467
- {
468
- blankLine: "always",
469
- prev: "*",
470
- next: ["interface", "type"]
471
- },
472
- {
473
- blankLine: "always",
474
- next: "return",
475
- prev: "*"
476
- }
477
- ],
478
- "@stylistic/lines-between-class-members": ["error", "always"],
479
- "@stylistic/generator-star-spacing": ["error", {
480
- after: true,
481
- before: false
482
- }],
483
- "@stylistic/quote-props": ["error", "consistent"],
484
- "@stylistic/quotes": [
485
- "error",
486
- quotes,
487
- { avoidEscape: true }
488
- ],
489
- "@stylistic/semi": "error",
490
- "@stylistic/comma-spacing": "error",
491
- "@stylistic/yield-star-spacing": ["error", {
492
- after: true,
493
- before: false
494
- }],
495
- ...overrides
496
- }
497
- }];
498
- }
499
-
500
- //#endregion
501
- //#region src/configs/formatters.ts
502
- function mergePrettierOptions(options, overrides = {}) {
503
- return {
504
- ...options,
505
- ...overrides,
506
- plugins: [...overrides.plugins ?? [], ...options.plugins ?? []]
507
- };
508
- }
509
- async function formatters(options = {}, stylistic$1 = {}) {
510
- if (options === true) {
511
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
512
- options = {
513
- astro: isPackageInScope("prettier-plugin-astro"),
514
- css: true,
515
- html: true,
516
- markdown: true,
517
- svg: isPrettierPluginXmlInScope,
518
- xml: isPrettierPluginXmlInScope
519
- };
520
- }
521
- await ensurePackages([
522
- "eslint-plugin-format",
523
- options.astro ? "prettier-plugin-astro" : void 0,
524
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
525
- ]);
526
- const { indent, quotes } = {
527
- ...StylisticConfigDefaults,
528
- ...stylistic$1
529
- };
530
- const prettierOptions = Object.assign({
531
- arrowParens: "always",
532
- endOfLine: "lf",
533
- printWidth: 120,
534
- semi: true,
535
- singleQuote: quotes === "single",
536
- tabWidth: typeof indent === "number" ? indent : 2,
537
- trailingComma: "all",
538
- useTabs: indent === "tab"
539
- }, options.prettierOptions ?? {});
540
- const prettierXmlOptions = {
541
- xmlQuoteAttributes: "double",
542
- xmlSelfClosingSpace: true,
543
- xmlSortAttributesByKey: false,
544
- xmlWhitespaceSensitivity: "ignore"
545
- };
546
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
547
- const configs$1 = [{
548
- name: "eienjs/formatter/setup",
549
- plugins: { format: pluginFormat }
550
- }];
551
- if (options.css) configs$1.push({
552
- files: [GLOB_CSS, GLOB_POSTCSS],
553
- languageOptions: { parser: parserPlain },
554
- name: "eienjs/formatter/css",
555
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
556
- }, {
557
- files: [GLOB_SCSS],
558
- languageOptions: { parser: parserPlain },
559
- name: "eienjs/formatter/scss",
560
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
561
- }, {
562
- files: [GLOB_LESS],
563
- languageOptions: { parser: parserPlain },
564
- name: "eienjs/formatter/less",
565
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
566
- });
567
- if (options.html) configs$1.push({
568
- files: [GLOB_HTML],
569
- languageOptions: { parser: parserPlain },
570
- name: "eienjs/formatter/html",
571
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
572
- });
573
- if (options.xml) configs$1.push({
574
- files: [GLOB_XML],
575
- languageOptions: { parser: parserPlain },
576
- name: "eienjs/formatter/xml",
577
- rules: { "format/prettier": ["error", mergePrettierOptions({
578
- ...prettierXmlOptions,
579
- ...prettierOptions
580
- }, {
581
- parser: "xml",
582
- plugins: ["@prettier/plugin-xml"]
583
- })] }
584
- });
585
- if (options.svg) configs$1.push({
586
- files: [GLOB_SVG],
587
- languageOptions: { parser: parserPlain },
588
- name: "eienjs/formatter/svg",
589
- rules: { "format/prettier": ["error", mergePrettierOptions({
590
- ...prettierXmlOptions,
591
- ...prettierOptions
592
- }, {
593
- parser: "xml",
594
- plugins: ["@prettier/plugin-xml"]
595
- })] }
596
- });
597
- if (options.markdown) configs$1.push({
598
- files: [GLOB_MARKDOWN],
599
- languageOptions: { parser: parserPlain },
600
- name: "eienjs/formatter/markdown",
601
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
602
- embeddedLanguageFormatting: "off",
603
- parser: "markdown"
604
- })] }
605
- });
606
- if (options.astro) configs$1.push({
607
- files: [GLOB_ASTRO],
608
- languageOptions: { parser: parserPlain },
609
- name: "eienjs/formatter/astro",
610
- rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
611
- parser: "astro",
612
- plugins: ["prettier-plugin-astro"]
613
- })] }
614
- }, {
615
- files: [GLOB_ASTRO, GLOB_ASTRO_TS],
616
- name: "eienjs/formatter/astro/disables",
617
- rules: {
618
- "@stylistic/arrow-parens": "off",
619
- "@stylistic/block-spacing": "off",
620
- "@stylistic/comma-dangle": "off",
621
- "@stylistic/indent": "off",
622
- "@stylistic/no-multi-spaces": "off",
623
- "@stylistic/quotes": "off",
624
- "@stylistic/semi": "off"
625
- }
626
- });
627
- return configs$1;
628
- }
629
-
630
- //#endregion
631
- //#region src/configs/ignores.ts
632
- function ignores(userIgnores = []) {
633
- return [{
634
- ignores: [...GLOB_EXCLUDE, ...userIgnores],
635
- name: "eienjs/ignores"
636
- }];
637
- }
638
-
639
- //#endregion
640
- //#region src/configs/imports.ts
641
- function imports(options = {}) {
642
- const { overrides = {}, stylistic: stylistic$1 = true } = options;
643
- return [{
644
- name: "eienjs/imports/rules",
645
- plugins: {
646
- antfu: pluginAntfu,
647
- import: pluginImportLite
648
- },
649
- rules: {
650
- "antfu/import-dedupe": "error",
651
- "antfu/no-import-dist": "error",
652
- "antfu/no-import-node-modules-by-path": "error",
653
- "import/consistent-type-specifier-style": ["error", "top-level"],
654
- "import/first": "error",
655
- "import/no-duplicates": "error",
656
- "import/no-mutable-exports": "error",
657
- "import/no-named-default": "error",
658
- ...stylistic$1 ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
659
- ...overrides
660
- }
661
- }];
662
- }
663
-
664
- //#endregion
665
- //#region src/configs/javascript.ts
666
- function javascript(options = {}) {
667
- const { isInEditor = false, overrides = {} } = options;
668
- return [{
669
- languageOptions: {
670
- globals: {
671
- ...globals.browser,
672
- ...globals.es2025,
673
- ...globals.node,
674
- document: "readonly",
675
- navigator: "readonly",
676
- window: "readonly"
677
- },
678
- parserOptions: { sourceType: "module" },
679
- sourceType: "module"
680
- },
681
- linterOptions: { reportUnusedDisableDirectives: true },
682
- name: "eienjs/javascript/setup"
683
- }, {
684
- name: "eienjs/javascript/rules",
685
- plugins: {
686
- "antfu": pluginAntfu,
687
- "unused-imports": pluginUnusedImports
688
- },
689
- rules: {
690
- "accessor-pairs": ["error", {
691
- enforceForClassMembers: true,
692
- setWithoutGet: true
693
- }],
694
- "antfu/no-top-level-await": "error",
695
- "array-callback-return": ["error", {
696
- allowImplicit: true,
697
- checkForEach: true
698
- }],
699
- "block-scoped-var": "error",
700
- "constructor-super": "error",
701
- "curly": "error",
702
- "default-case-last": "error",
703
- "dot-notation": ["error", { allowKeywords: true }],
704
- "eqeqeq": ["error", "smart"],
705
- "logical-assignment-operators": ["error", "never"],
706
- "new-cap": ["error", {
707
- capIsNew: false,
708
- newIsCap: true,
709
- properties: true
710
- }],
711
- "no-alert": "error",
712
- "no-array-constructor": "error",
713
- "no-async-promise-executor": "error",
714
- "no-caller": "error",
715
- "no-case-declarations": "error",
716
- "no-class-assign": "error",
717
- "no-compare-neg-zero": "error",
718
- "no-cond-assign": ["error", "always"],
719
- "no-console": ["error", { allow: [
720
- "warn",
721
- "error",
722
- "info",
723
- "table"
724
- ] }],
725
- "no-constant-binary-expression": "error",
726
- "no-const-assign": "error",
727
- "no-control-regex": "error",
728
- "no-debugger": "error",
729
- "no-delete-var": "error",
730
- "no-dupe-args": "error",
731
- "no-dupe-class-members": "error",
732
- "no-dupe-keys": "error",
733
- "no-duplicate-case": "error",
734
- "no-else-return": ["error", { allowElseIf: false }],
735
- "no-empty": ["error", { allowEmptyCatch: true }],
736
- "no-empty-character-class": "error",
737
- "no-empty-pattern": "error",
738
- "no-eval": "error",
739
- "no-ex-assign": "error",
740
- "no-extend-native": "error",
741
- "no-extra-bind": "error",
742
- "no-extra-boolean-cast": "error",
743
- "no-extra-label": "error",
744
- "no-fallthrough": "error",
745
- "no-func-assign": "error",
746
- "no-global-assign": "error",
747
- "no-implicit-coercion": "error",
748
- "no-implied-eval": "error",
749
- "no-import-assign": "error",
750
- "no-invalid-regexp": "error",
751
- "no-irregular-whitespace": "error",
752
- "no-iterator": "error",
753
- "no-labels": ["error", {
754
- allowLoop: false,
755
- allowSwitch: false
756
- }],
757
- "no-lone-blocks": "error",
758
- "no-loss-of-precision": "error",
759
- "no-misleading-character-class": "error",
760
- "no-multi-str": "error",
761
- "no-negated-condition": "error",
762
- "no-new": "error",
763
- "no-new-func": "error",
764
- "no-new-native-nonconstructor": "error",
765
- "no-new-wrappers": "error",
766
- "no-obj-calls": "error",
767
- "no-octal": "error",
768
- "no-octal-escape": "error",
769
- "no-promise-executor-return": "error",
770
- "no-proto": "error",
771
- "no-prototype-builtins": "error",
772
- "no-redeclare": ["error", { builtinGlobals: false }],
773
- "no-regex-spaces": "error",
774
- "no-restricted-globals": [
775
- "error",
776
- {
777
- message: "Use `globalThis` instead.",
778
- name: "global"
779
- },
780
- {
781
- message: "Use `globalThis` instead.",
782
- name: "self"
783
- }
784
- ],
785
- "no-restricted-properties": [
786
- "error",
787
- {
788
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
789
- property: "__proto__"
790
- },
791
- {
792
- message: "Use `Object.defineProperty` instead.",
793
- property: "__defineGetter__"
794
- },
795
- {
796
- message: "Use `Object.defineProperty` instead.",
797
- property: "__defineSetter__"
798
- },
799
- {
800
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
801
- property: "__lookupGetter__"
802
- },
803
- {
804
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
805
- property: "__lookupSetter__"
806
- },
807
- {
808
- message: "Please use Number.isFinite instead",
809
- object: "global",
810
- property: "isFinite"
811
- },
812
- {
813
- message: "Please use Number.isFinite instead",
814
- object: "self",
815
- property: "isFinite"
816
- },
817
- {
818
- message: "Please use Number.isFinite instead",
819
- object: "window",
820
- property: "isFinite"
821
- },
822
- {
823
- message: "Please use Number.isNaN instead",
824
- object: "global",
825
- property: "isNaN"
826
- },
827
- {
828
- message: "Please use Number.isNaN instead",
829
- object: "self",
830
- property: "isNaN"
831
- },
832
- {
833
- message: "Please use Number.isNaN instead",
834
- object: "window",
835
- property: "isNaN"
836
- }
837
- ],
838
- "no-restricted-syntax": [
839
- "error",
840
- "TSEnumDeclaration[const=true]",
841
- "TSExportAssignment"
842
- ],
843
- "no-return-assign": ["error", "always"],
844
- "no-self-assign": ["error", { props: true }],
845
- "no-self-compare": "error",
846
- "no-sequences": ["error", { allowInParentheses: false }],
847
- "no-shadow-restricted-names": "error",
848
- "no-sparse-arrays": "error",
849
- "no-this-before-super": "error",
850
- "no-throw-literal": "error",
851
- "no-undef": "error",
852
- "no-undef-init": "error",
853
- "no-unexpected-multiline": "error",
854
- "no-unmodified-loop-condition": "error",
855
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
856
- "no-unreachable": "error",
857
- "no-unreachable-loop": "error",
858
- "no-unsafe-finally": "error",
859
- "no-unsafe-negation": "error",
860
- "no-unused-expressions": ["error", {
861
- allowShortCircuit: true,
862
- allowTaggedTemplates: true,
863
- allowTernary: true
864
- }],
865
- "no-unused-vars": ["error", {
866
- args: "none",
867
- caughtErrors: "none",
868
- ignoreRestSiblings: true,
869
- vars: "all"
870
- }],
871
- "no-use-before-define": ["error", {
872
- classes: false,
873
- functions: false,
874
- variables: true
875
- }],
876
- "no-useless-backreference": "error",
877
- "no-useless-call": "error",
878
- "no-useless-catch": "error",
879
- "no-useless-computed-key": "error",
880
- "no-useless-constructor": "error",
881
- "no-useless-rename": "error",
882
- "no-useless-return": "error",
883
- "no-var": "error",
884
- "no-void": ["error", { allowAsStatement: true }],
885
- "no-with": "error",
886
- "object-shorthand": [
887
- "error",
888
- "always",
889
- {
890
- avoidQuotes: true,
891
- ignoreConstructors: false
892
- }
893
- ],
894
- "one-var": ["error", { initialized: "never" }],
895
- "operator-assignment": ["error", "always"],
896
- "prefer-arrow-callback": "off",
897
- "prefer-const": [isInEditor ? "warn" : "error", {
898
- destructuring: "all",
899
- ignoreReadBeforeAssign: true
900
- }],
901
- "prefer-destructuring": [
902
- "error",
903
- {
904
- AssignmentExpression: {
905
- array: false,
906
- object: false
907
- },
908
- VariableDeclarator: {
909
- array: false,
910
- object: true
911
- }
912
- },
913
- { enforceForRenamedProperties: false }
914
- ],
915
- "prefer-exponentiation-operator": "error",
916
- "prefer-object-has-own": "error",
917
- "prefer-object-spread": "error",
918
- "prefer-promise-reject-errors": "error",
919
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
920
- "prefer-rest-params": "error",
921
- "prefer-spread": "error",
922
- "prefer-template": "error",
923
- "symbol-description": "error",
924
- "unicode-bom": ["error", "never"],
925
- "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
926
- "unused-imports/no-unused-vars": ["error", {
927
- args: "after-used",
928
- argsIgnorePattern: "^_",
929
- ignoreRestSiblings: true,
930
- vars: "all",
931
- varsIgnorePattern: "^_"
932
- }],
933
- "use-isnan": ["error", {
934
- enforceForIndexOf: true,
935
- enforceForSwitchCase: true
936
- }],
937
- "valid-typeof": ["error", { requireStringLiterals: true }],
938
- "vars-on-top": "error",
939
- "yoda": ["error", "never"],
940
- ...overrides
941
- }
942
- }];
943
- }
944
-
945
- //#endregion
946
- //#region src/configs/jsdoc.ts
947
- async function jsdoc(options = {}) {
948
- const { stylistic: stylistic$1 = true } = options;
949
- return [{
950
- name: "eienjs/jsdoc/rules",
951
- plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
952
- rules: {
953
- "jsdoc/check-access": "warn",
954
- "jsdoc/check-param-names": "warn",
955
- "jsdoc/check-property-names": "warn",
956
- "jsdoc/check-types": "warn",
957
- "jsdoc/empty-tags": "warn",
958
- "jsdoc/implements-on-classes": "warn",
959
- "jsdoc/no-defaults": "warn",
960
- "jsdoc/no-multi-asterisks": "warn",
961
- "jsdoc/require-param-name": "warn",
962
- "jsdoc/require-property": "warn",
963
- "jsdoc/require-property-description": "warn",
964
- "jsdoc/require-property-name": "warn",
965
- "jsdoc/require-returns-check": "warn",
966
- "jsdoc/require-returns-description": "warn",
967
- "jsdoc/require-yields-check": "warn",
968
- ...stylistic$1 ? {
969
- "jsdoc/check-alignment": "warn",
970
- "jsdoc/multiline-blocks": "warn"
971
- } : {}
972
- }
973
- }];
974
- }
975
-
976
- //#endregion
977
- //#region src/configs/jsonc.ts
978
- async function jsonc(options = {}) {
979
- const { files = [
980
- GLOB_JSON,
981
- GLOB_JSON5,
982
- GLOB_JSONC
983
- ], overrides = {}, stylistic: stylistic$1 = true } = options;
984
- const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
985
- const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
986
- return [{
987
- name: "eienjs/jsonc/setup",
988
- plugins: { jsonc: pluginJsonc }
989
- }, {
990
- files,
991
- languageOptions: { parser: parserJsonc },
992
- name: "eienjs/jsonc/rules",
993
- rules: {
994
- "jsonc/no-bigint-literals": "error",
995
- "jsonc/no-binary-expression": "error",
996
- "jsonc/no-binary-numeric-literals": "error",
997
- "jsonc/no-dupe-keys": "error",
998
- "jsonc/no-escape-sequence-in-identifier": "error",
999
- "jsonc/no-floating-decimal": "error",
1000
- "jsonc/no-hexadecimal-numeric-literals": "error",
1001
- "jsonc/no-infinity": "error",
1002
- "jsonc/no-multi-str": "error",
1003
- "jsonc/no-nan": "error",
1004
- "jsonc/no-number-props": "error",
1005
- "jsonc/no-numeric-separators": "error",
1006
- "jsonc/no-octal": "error",
1007
- "jsonc/no-octal-escape": "error",
1008
- "jsonc/no-octal-numeric-literals": "error",
1009
- "jsonc/no-parenthesized": "error",
1010
- "jsonc/no-plus-sign": "error",
1011
- "jsonc/no-regexp-literals": "error",
1012
- "jsonc/no-sparse-arrays": "error",
1013
- "jsonc/no-template-literals": "error",
1014
- "jsonc/no-undefined-value": "error",
1015
- "jsonc/no-unicode-codepoint-escapes": "error",
1016
- "jsonc/no-useless-escape": "error",
1017
- "jsonc/space-unary-ops": "error",
1018
- "jsonc/valid-json-number": "error",
1019
- "jsonc/vue-custom-block/no-parsing-error": "error",
1020
- ...stylistic$1 ? {
1021
- "jsonc/array-bracket-spacing": ["error", "never"],
1022
- "jsonc/comma-dangle": ["error", "never"],
1023
- "jsonc/comma-style": ["error", "last"],
1024
- "jsonc/indent": ["error", indent],
1025
- "jsonc/key-spacing": ["error", {
1026
- afterColon: true,
1027
- beforeColon: false
1028
- }],
1029
- "jsonc/object-curly-newline": ["error", {
1030
- consistent: true,
1031
- multiline: true
1032
- }],
1033
- "jsonc/object-curly-spacing": ["error", "always"],
1034
- "jsonc/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
1035
- "jsonc/quote-props": "error",
1036
- "jsonc/quotes": "error"
1037
- } : {},
1038
- ...overrides
1039
- }
1040
- }];
1041
- }
1042
-
1043
- //#endregion
1044
- //#region src/configs/markdown.ts
1045
- async function markdown(options = {}) {
1046
- const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
1047
- const markdown$1 = await interopDefault(import("@eslint/markdown"));
1048
- return [
1049
- {
1050
- name: "eienjs/markdown/setup",
1051
- plugins: { markdown: markdown$1 }
1052
- },
1053
- {
1054
- files,
1055
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1056
- name: "eienjs/markdown/processor",
1057
- processor: mergeProcessors([markdown$1.processors.markdown, processorPassThrough])
1058
- },
1059
- {
1060
- files,
1061
- languageOptions: { parser: parserPlain },
1062
- name: "eienjs/markdown/parser"
1063
- },
1064
- {
1065
- files: [
1066
- GLOB_MARKDOWN,
1067
- GLOB_MARKDOWN_CODE,
1068
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1069
- ],
1070
- languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
1071
- name: "eienjs/markdown/disables",
1072
- rules: {
1073
- "antfu/no-top-level-await": "off",
1074
- "no-alert": "off",
1075
- "no-console": "off",
1076
- "no-labels": "off",
1077
- "no-lone-blocks": "off",
1078
- "no-restricted-syntax": "off",
1079
- "no-undef": "off",
1080
- "no-unused-expressions": "off",
1081
- "no-unused-labels": "off",
1082
- "no-unused-vars": "off",
1083
- "unicode-bom": "off",
1084
- "n/prefer-global/process": "off",
1085
- "@stylistic/comma-dangle": "off",
1086
- "@stylistic/eol-last": "off",
1087
- "@stylistic/padding-line-between-statements": "off",
1088
- "@stylistic/max-len": "off",
1089
- "@typescript-eslint/consistent-type-imports": "off",
1090
- "@typescript-eslint/explicit-function-return-type": "off",
1091
- "@typescript-eslint/no-namespace": "off",
1092
- "@typescript-eslint/no-redeclare": "off",
1093
- "@typescript-eslint/no-require-imports": "off",
1094
- "@typescript-eslint/no-unused-expressions": "off",
1095
- "@typescript-eslint/no-unused-vars": "off",
1096
- "@typescript-eslint/no-use-before-define": "off",
1097
- "unused-imports/no-unused-imports": "off",
1098
- "unused-imports/no-unused-vars": "off",
1099
- ...overrides
1100
- }
1101
- }
1102
- ];
1103
- }
1104
-
1105
- //#endregion
1106
- //#region src/configs/node.ts
1107
- function node() {
1108
- return [{
1109
- name: "eienjs/node/rules",
1110
- plugins: { n: pluginNode },
1111
- rules: {
1112
- "n/handle-callback-err": ["error", "^(err|error)$"],
1113
- "n/no-deprecated-api": "error",
1114
- "n/no-exports-assign": "error",
1115
- "n/no-new-require": "error",
1116
- "n/no-path-concat": "error",
1117
- "n/prefer-global/buffer": ["error", "never"],
1118
- "n/prefer-global/process": ["error", "never"],
1119
- "n/process-exit-as-throw": "error"
1120
- }
1121
- }];
1122
- }
1123
-
1124
- //#endregion
1125
- //#region src/configs/nuxt.ts
1126
- async function nuxt(options = {}) {
1127
- const { overrides = {}, dirs = {}, version = 4, stylistic: stylistic$1 = true } = options;
1128
- const { sortConfigKeys = Boolean(stylistic$1) } = options;
1129
- await ensurePackages(["@nuxt/eslint-plugin"]);
1130
- const pluginNuxt = await interopDefault(import("@nuxt/eslint-plugin"));
1131
- dirs.root = dirs.root ?? [version === 4 ? "./app" : "."];
1132
- dirs.src = dirs.src ?? dirs.root;
1133
- dirs.pages = dirs.pages ?? dirs.src.map((src) => `${src}/pages`);
1134
- dirs.layouts = dirs.layouts ?? dirs.src.map((src) => `${src}/layouts`);
1135
- dirs.components = dirs.components ?? dirs.src.map((src) => `${src}/components`);
1136
- dirs.composables = dirs.composables ?? dirs.src.map((src) => `${src}/composables`);
1137
- dirs.plugins = dirs.plugins ?? dirs.src.map((src) => `${src}/plugins`);
1138
- dirs.modules = dirs.modules ?? dirs.src.map((src) => `${src}/modules`);
1139
- dirs.middleware = dirs.middleware ?? dirs.src.map((src) => `${src}/middleware`);
1140
- dirs.servers = dirs.servers ?? dirs.src.map((src) => `${src}/servers`);
1141
- dirs.utils = dirs.utils ?? dirs.src.map((src) => `${src}/utils`);
1142
- dirs.componentsPrefixed = dirs.componentsPrefixed ?? [];
1143
- const fileSingleRoot = [
1144
- ...dirs.layouts.map((layoutsDir) => join(layoutsDir, `**/*.${GLOB_EXTS}`)),
1145
- ...dirs.pages.map((pagesDir) => join(pagesDir, `**/*.${GLOB_EXTS}`)),
1146
- ...dirs.components.map((componentsDir) => join(componentsDir, `**/*.server.${GLOB_EXTS}`))
1147
- ].sort();
1148
- const INLINE_ELEMENTS = [
1149
- "a",
1150
- "abbr",
1151
- "audio",
1152
- "b",
1153
- "bdi",
1154
- "bdo",
1155
- "canvas",
1156
- "cite",
1157
- "code",
1158
- "data",
1159
- "del",
1160
- "dfn",
1161
- "em",
1162
- "i",
1163
- "iframe",
1164
- "ins",
1165
- "kbd",
1166
- "label",
1167
- "map",
1168
- "mark",
1169
- "noscript",
1170
- "object",
1171
- "output",
1172
- "picture",
1173
- "q",
1174
- "ruby",
1175
- "s",
1176
- "samp",
1177
- "small",
1178
- "span",
1179
- "strong",
1180
- "sub",
1181
- "sup",
1182
- "svg",
1183
- "time",
1184
- "u",
1185
- "var",
1186
- "video"
1187
- ];
1188
- return [
1189
- {
1190
- name: "eienjs/nuxt/setup",
1191
- plugins: { nuxt: pluginNuxt },
1192
- languageOptions: { globals: { $fetch: "readonly" } }
1193
- },
1194
- ...fileSingleRoot.length > 0 ? [{
1195
- files: fileSingleRoot,
1196
- name: "eienjs/nuxt/vue/single-root",
1197
- rules: { "vue/no-multiple-template-root": "error" }
1198
- }] : [],
1199
- {
1200
- name: "eienjs/nuxt/rules",
1201
- rules: {
1202
- "nuxt/prefer-import-meta": "error",
1203
- ...overrides
1204
- }
1205
- },
1206
- {
1207
- files: dirs.utils.map((utilsDir) => join(utilsDir, GLOB_SRC)),
1208
- name: "eienjs/nuxt/utils-disables",
1209
- rules: { "@typescript-eslint/explicit-module-boundary-types": "off" }
1210
- },
1211
- ...sortConfigKeys ? [{
1212
- files: ["**/nuxt.config.?([cm])[jt]s?(x)"],
1213
- name: "eienjs/nuxt/sort-config",
1214
- rules: { "nuxt/nuxt-config-keys-order": "error" }
1215
- }] : [],
1216
- ...stylistic$1 ? [{
1217
- files: [GLOB_VUE],
1218
- name: "eienjs/nuxt/vue/rules",
1219
- rules: {
1220
- "vue/multiline-html-element-content-newline": ["error", {
1221
- ignoreWhenEmpty: true,
1222
- ignores: [
1223
- "pre",
1224
- "textarea",
1225
- "router-link",
1226
- "RouterLink",
1227
- "nuxt-link",
1228
- "NuxtLink",
1229
- "u-link",
1230
- "ULink",
1231
- ...INLINE_ELEMENTS
1232
- ],
1233
- allowEmptyLines: false
1234
- }],
1235
- "vue/singleline-html-element-content-newline": ["error", {
1236
- ignoreWhenNoAttributes: true,
1237
- ignoreWhenEmpty: true,
1238
- ignores: [
1239
- "pre",
1240
- "textarea",
1241
- "router-link",
1242
- "RouterLink",
1243
- "nuxt-link",
1244
- "NuxtLink",
1245
- "u-link",
1246
- "ULink",
1247
- ...INLINE_ELEMENTS
1248
- ],
1249
- externalIgnores: []
1250
- }]
1251
- }
1252
- }] : []
1253
- ];
1254
- }
1255
-
1256
- //#endregion
1257
- //#region src/configs/perfectionist.ts
1258
- /**
1259
- * Perfectionist plugin for props and items sorting.
1260
- *
1261
- * @see https://github.com/azat-io/eslint-plugin-perfectionist
1262
- */
1263
- function perfectionist() {
1264
- return [{
1265
- name: "eienjs/perfectionist/setup",
1266
- plugins: { perfectionist: pluginPerfectionist },
1267
- rules: {
1268
- "perfectionist/sort-exports": ["error", {
1269
- order: "asc",
1270
- type: "natural"
1271
- }],
1272
- "perfectionist/sort-imports": ["error", {
1273
- groups: [
1274
- "type",
1275
- [
1276
- "parent-type",
1277
- "sibling-type",
1278
- "index-type",
1279
- "internal-type"
1280
- ],
1281
- "builtin",
1282
- "external",
1283
- "internal",
1284
- [
1285
- "parent",
1286
- "sibling",
1287
- "index"
1288
- ],
1289
- "side-effect",
1290
- "object",
1291
- "unknown"
1292
- ],
1293
- newlinesBetween: "ignore",
1294
- order: "asc",
1295
- type: "natural"
1296
- }],
1297
- "perfectionist/sort-named-exports": ["error", {
1298
- order: "asc",
1299
- type: "natural"
1300
- }],
1301
- "perfectionist/sort-named-imports": ["error", {
1302
- order: "asc",
1303
- type: "natural"
1304
- }]
1305
- }
1306
- }];
1307
- }
1308
-
1309
- //#endregion
1310
- //#region src/configs/pnpm.ts
1311
- async function pnpm() {
1312
- const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
1313
- interopDefault(import("eslint-plugin-pnpm")),
1314
- interopDefault(import("yaml-eslint-parser")),
1315
- interopDefault(import("jsonc-eslint-parser"))
1316
- ]);
1317
- return [{
1318
- files: ["package.json", "**/package.json"],
1319
- languageOptions: { parser: jsoncParser },
1320
- name: "eienjs/pnpm/package-json",
1321
- plugins: { pnpm: pluginPnpm },
1322
- rules: {
1323
- "pnpm/json-enforce-catalog": "error",
1324
- "pnpm/json-prefer-workspace-settings": "error",
1325
- "pnpm/json-valid-catalog": "error"
1326
- }
1327
- }, {
1328
- files: ["pnpm-workspace.yaml"],
1329
- languageOptions: { parser: yamlParser },
1330
- name: "eienjs/pnpm/pnpm-workspace-yaml",
1331
- plugins: { pnpm: pluginPnpm },
1332
- rules: {
1333
- "pnpm/yaml-no-duplicate-catalog-item": "error",
1334
- "pnpm/yaml-no-unused-catalog-item": "error"
1335
- }
1336
- }];
1337
- }
1338
-
1339
- //#endregion
1340
- //#region src/configs/regexp.ts
1341
- function regexp(options = {}) {
1342
- const config = configs["flat/recommended"];
1343
- const rules = { ...config.rules };
1344
- if (options.level === "warn") {
1345
- for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
1346
- }
1347
- return [{
1348
- ...config,
1349
- name: "eienjs/regexp/rules",
1350
- rules: {
1351
- ...rules,
1352
- ...options.overrides
1353
- }
1354
- }];
1355
- }
1356
-
1357
- //#endregion
1358
- //#region src/configs/sort.ts
1359
- /**
1360
- * Sort package.json
1361
- *
1362
- * Requires `jsonc` config
1363
- */
1364
- function sortPackageJson() {
1365
- return [{
1366
- files: ["**/package.json"],
1367
- name: "eienjs/sort/package-json",
1368
- rules: {
1369
- "jsonc/sort-array-values": ["error", {
1370
- order: { type: "asc" },
1371
- pathPattern: "^files$"
1372
- }],
1373
- "jsonc/sort-keys": [
1374
- "error",
1375
- {
1376
- order: [
1377
- "publisher",
1378
- "name",
1379
- "displayName",
1380
- "type",
1381
- "version",
1382
- "private",
1383
- "packageManager",
1384
- "description",
1385
- "author",
1386
- "contributors",
1387
- "license",
1388
- "funding",
1389
- "homepage",
1390
- "repository",
1391
- "bugs",
1392
- "keywords",
1393
- "categories",
1394
- "sideEffects",
1395
- "imports",
1396
- "exports",
1397
- "main",
1398
- "module",
1399
- "unpkg",
1400
- "jsdelivr",
1401
- "types",
1402
- "typesVersions",
1403
- "bin",
1404
- "icon",
1405
- "files",
1406
- "engines",
1407
- "activationEvents",
1408
- "contributes",
1409
- "scripts",
1410
- "peerDependencies",
1411
- "peerDependenciesMeta",
1412
- "dependencies",
1413
- "optionalDependencies",
1414
- "devDependencies",
1415
- "pnpm",
1416
- "overrides",
1417
- "resolutions",
1418
- "husky",
1419
- "simple-git-hooks",
1420
- "lint-staged",
1421
- "eslintConfig",
1422
- "commitlint",
1423
- "publishConfig",
1424
- "auto-changelog",
1425
- "np"
1426
- ],
1427
- pathPattern: "^$"
1428
- },
1429
- {
1430
- order: { type: "asc" },
1431
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1432
- },
1433
- {
1434
- order: { type: "asc" },
1435
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1436
- },
1437
- {
1438
- order: [
1439
- "types",
1440
- "import",
1441
- "require",
1442
- "default"
1443
- ],
1444
- pathPattern: "^exports.*$"
1445
- },
1446
- {
1447
- order: [
1448
- "pre-commit",
1449
- "prepare-commit-msg",
1450
- "commit-msg",
1451
- "post-commit",
1452
- "pre-rebase",
1453
- "post-rewrite",
1454
- "post-checkout",
1455
- "post-merge",
1456
- "pre-push",
1457
- "pre-auto-gc"
1458
- ],
1459
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1460
- }
1461
- ]
1462
- }
1463
- }];
1464
- }
1465
- /**
1466
- * Sort tsconfig.json
1467
- *
1468
- * Requires `jsonc` config
1469
- */
1470
- function sortTsconfig() {
1471
- return [{
1472
- files: ["**/[jt]sconfig.json", "**/[jt]sconfig.*.json"],
1473
- name: "eienjs/sort/tsconfig-json",
1474
- rules: { "jsonc/sort-keys": [
1475
- "error",
1476
- {
1477
- order: [
1478
- "extends",
1479
- "compilerOptions",
1480
- "references",
1481
- "files",
1482
- "include",
1483
- "exclude"
1484
- ],
1485
- pathPattern: "^$"
1486
- },
1487
- {
1488
- order: [
1489
- "incremental",
1490
- "composite",
1491
- "tsBuildInfoFile",
1492
- "disableSourceOfProjectReferenceRedirect",
1493
- "disableSolutionSearching",
1494
- "disableReferencedProjectLoad",
1495
- "target",
1496
- "jsx",
1497
- "jsxFactory",
1498
- "jsxFragmentFactory",
1499
- "jsxImportSource",
1500
- "lib",
1501
- "moduleDetection",
1502
- "noLib",
1503
- "reactNamespace",
1504
- "useDefineForClassFields",
1505
- "emitDecoratorMetadata",
1506
- "experimentalDecorators",
1507
- "libReplacement",
1508
- "baseUrl",
1509
- "rootDir",
1510
- "rootDirs",
1511
- "customConditions",
1512
- "module",
1513
- "moduleResolution",
1514
- "moduleSuffixes",
1515
- "noResolve",
1516
- "paths",
1517
- "resolveJsonModule",
1518
- "resolvePackageJsonExports",
1519
- "resolvePackageJsonImports",
1520
- "typeRoots",
1521
- "types",
1522
- "allowArbitraryExtensions",
1523
- "allowImportingTsExtensions",
1524
- "allowUmdGlobalAccess",
1525
- "allowJs",
1526
- "checkJs",
1527
- "maxNodeModuleJsDepth",
1528
- "strict",
1529
- "strictBindCallApply",
1530
- "strictFunctionTypes",
1531
- "strictNullChecks",
1532
- "strictPropertyInitialization",
1533
- "allowUnreachableCode",
1534
- "allowUnusedLabels",
1535
- "alwaysStrict",
1536
- "exactOptionalPropertyTypes",
1537
- "noFallthroughCasesInSwitch",
1538
- "noImplicitAny",
1539
- "noImplicitOverride",
1540
- "noImplicitReturns",
1541
- "noImplicitThis",
1542
- "noPropertyAccessFromIndexSignature",
1543
- "noUncheckedIndexedAccess",
1544
- "noUnusedLocals",
1545
- "noUnusedParameters",
1546
- "useUnknownInCatchVariables",
1547
- "declaration",
1548
- "declarationDir",
1549
- "declarationMap",
1550
- "downlevelIteration",
1551
- "emitBOM",
1552
- "emitDeclarationOnly",
1553
- "importHelpers",
1554
- "importsNotUsedAsValues",
1555
- "inlineSourceMap",
1556
- "inlineSources",
1557
- "mapRoot",
1558
- "newLine",
1559
- "noEmit",
1560
- "noEmitHelpers",
1561
- "noEmitOnError",
1562
- "outDir",
1563
- "outFile",
1564
- "preserveConstEnums",
1565
- "preserveValueImports",
1566
- "removeComments",
1567
- "sourceMap",
1568
- "sourceRoot",
1569
- "stripInternal",
1570
- "allowSyntheticDefaultImports",
1571
- "esModuleInterop",
1572
- "forceConsistentCasingInFileNames",
1573
- "isolatedDeclarations",
1574
- "isolatedModules",
1575
- "preserveSymlinks",
1576
- "verbatimModuleSyntax",
1577
- "erasableSyntaxOnly",
1578
- "skipDefaultLibCheck",
1579
- "skipLibCheck"
1580
- ],
1581
- pathPattern: "^compilerOptions$"
1582
- }
1583
- ] }
1584
- }];
1585
- }
1586
-
1587
- //#endregion
1588
- //#region src/configs/test.ts
1589
- let _pluginTest;
1590
- async function test(options = {}) {
1591
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1592
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
1593
- _pluginTest = _pluginTest || {
1594
- ...pluginVitest,
1595
- rules: {
1596
- ...pluginVitest.rules,
1597
- ...pluginNoOnlyTests.rules
1598
- }
1599
- };
1600
- return [{
1601
- name: "eienjs/test/setup",
1602
- plugins: { test: _pluginTest }
1603
- }, {
1604
- files,
1605
- name: "eienjs/test/rules",
1606
- rules: {
1607
- "test/consistent-test-it": ["error", {
1608
- fn: "test",
1609
- withinDescribe: "test"
1610
- }],
1611
- "test/no-identical-title": "error",
1612
- "test/no-import-node-test": "error",
1613
- "test/no-only-tests": isInEditor ? "warn" : "error",
1614
- "test/prefer-hooks-in-order": "error",
1615
- "test/prefer-lowercase-title": "error",
1616
- "antfu/no-top-level-await": "off",
1617
- "no-unused-expressions": "off",
1618
- "n/prefer-global/process": "off",
1619
- "@typescript-eslint/explicit-function-return-type": "off",
1620
- ...overrides
1621
- }
1622
- }];
1623
- }
1624
-
1625
- //#endregion
1626
- //#region src/configs/toml.ts
1627
- async function toml(options = {}) {
1628
- const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic$1 = true } = options;
1629
- const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1630
- const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
1631
- return [{
1632
- name: "eienjs/toml/setup",
1633
- plugins: { toml: pluginToml }
1634
- }, {
1635
- files,
1636
- languageOptions: { parser: parserToml },
1637
- name: "eienjs/toml/rules",
1638
- rules: {
1639
- "@stylistic/spaced-comment": "off",
1640
- "toml/comma-style": "error",
1641
- "toml/keys-order": "error",
1642
- "toml/no-space-dots": "error",
1643
- "toml/no-unreadable-number-separator": "error",
1644
- "toml/precision-of-fractional-seconds": "error",
1645
- "toml/precision-of-integer": "error",
1646
- "toml/tables-order": "error",
1647
- "toml/vue-custom-block/no-parsing-error": "error",
1648
- ...stylistic$1 ? {
1649
- "toml/array-bracket-newline": "error",
1650
- "toml/array-bracket-spacing": "error",
1651
- "toml/array-element-newline": "error",
1652
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
1653
- "toml/inline-table-curly-spacing": "error",
1654
- "toml/key-spacing": "error",
1655
- "toml/padding-line-between-pairs": "error",
1656
- "toml/padding-line-between-tables": "error",
1657
- "toml/quoted-keys": "error",
1658
- "toml/spaced-comment": "error",
1659
- "toml/table-bracket-spacing": "error"
1660
- } : {},
1661
- ...overrides
1662
- }
1663
- }];
1664
- }
1665
-
1666
- //#endregion
1667
- //#region src/configs/typescript.ts
1668
- async function typescript(options = {}) {
1669
- const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, stylistic: stylistic$1 = true } = options;
1670
- const files = options.files ?? [
1671
- GLOB_TS,
1672
- GLOB_TSX,
1673
- ...componentExts.map((ext) => `**/*.${ext}`)
1674
- ];
1675
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1676
- const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
1677
- const tsconfigPath = options.tsconfigPath ?? void 0;
1678
- const isTypeAware = Boolean(tsconfigPath);
1679
- const typeAwareRules = {
1680
- "dot-notation": "off",
1681
- "no-implied-eval": "off",
1682
- "@typescript-eslint/await-thenable": "error",
1683
- "@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
1684
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
1685
- "@typescript-eslint/explicit-member-accessibility": "error",
1686
- "@typescript-eslint/explicit-module-boundary-types": "error",
1687
- "@typescript-eslint/naming-convention": [
1688
- "error",
1689
- {
1690
- format: ["camelCase", "UPPER_CASE"],
1691
- leadingUnderscore: "allowSingleOrDouble",
1692
- modifiers: ["const"],
1693
- selector: "variable",
1694
- trailingUnderscore: "allowSingleOrDouble",
1695
- types: ["string", "number"]
1696
- },
1697
- {
1698
- format: null,
1699
- leadingUnderscore: "allowSingleOrDouble",
1700
- selector: "objectLiteralProperty",
1701
- trailingUnderscore: "allowSingleOrDouble"
1702
- },
1703
- {
1704
- format: ["PascalCase"],
1705
- leadingUnderscore: "allowSingleOrDouble",
1706
- selector: "typeLike",
1707
- trailingUnderscore: "allowSingleOrDouble"
1708
- },
1709
- {
1710
- format: null,
1711
- modifiers: ["destructured"],
1712
- selector: "variable"
1713
- },
1714
- {
1715
- format: null,
1716
- selector: "typeProperty"
1717
- },
1718
- {
1719
- format: ["PascalCase"],
1720
- selector: "class"
1721
- },
1722
- {
1723
- custom: {
1724
- match: false,
1725
- regex: "^I[A-Z]"
1726
- },
1727
- format: ["PascalCase"],
1728
- selector: "interface"
1729
- },
1730
- {
1731
- selector: "variable",
1732
- format: [
1733
- "camelCase",
1734
- "UPPER_CASE",
1735
- "PascalCase"
1736
- ],
1737
- leadingUnderscore: "allow"
1738
- }
1739
- ],
1740
- "@typescript-eslint/no-floating-promises": "error",
1741
- "@typescript-eslint/no-for-in-array": "error",
1742
- "@typescript-eslint/no-implied-eval": "error",
1743
- "@typescript-eslint/no-misused-promises": "error",
1744
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
1745
- "@typescript-eslint/no-unsafe-argument": "error",
1746
- "@typescript-eslint/no-unsafe-assignment": "error",
1747
- "@typescript-eslint/no-unsafe-call": "error",
1748
- "@typescript-eslint/no-unsafe-member-access": "error",
1749
- "@typescript-eslint/no-unsafe-return": "error",
1750
- "@typescript-eslint/prefer-nullish-coalescing": ["error", { ignorePrimitives: { string: true } }],
1751
- "@typescript-eslint/prefer-optional-chain": "error",
1752
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
1753
- "@typescript-eslint/promise-function-async": "error",
1754
- "@typescript-eslint/restrict-plus-operands": "error",
1755
- "@typescript-eslint/restrict-template-expressions": "error",
1756
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
1757
- "@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }],
1758
- "@typescript-eslint/no-empty-object-type": "off",
1759
- "@typescript-eslint/no-unused-vars": ["error", {
1760
- "args": "all",
1761
- "argsIgnorePattern": "^_",
1762
- "caughtErrors": "all",
1763
- "caughtErrorsIgnorePattern": "^_",
1764
- "destructuredArrayIgnorePattern": "^_",
1765
- "varsIgnorePattern": "^_",
1766
- "ignoreRestSiblings": true
1767
- }],
1768
- "@typescript-eslint/no-non-null-assertion": "off"
1769
- };
1770
- const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
1771
- function makeParser(typeAware, files$1, ignores$1) {
1772
- return {
1773
- files: files$1,
1774
- ...ignores$1 ? { ignores: ignores$1 } : {},
1775
- languageOptions: {
1776
- parser: parserTs,
1777
- parserOptions: {
1778
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1779
- sourceType: "module",
1780
- ...typeAware ? {
1781
- projectService: {
1782
- allowDefaultProject: ["./*.js"],
1783
- defaultProject: tsconfigPath
1784
- },
1785
- tsconfigRootDir: process.cwd()
1786
- } : {},
1787
- ...parserOptions
1788
- }
1789
- },
1790
- name: `eienjs/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1791
- };
1792
- }
1793
- return [
1794
- {
1795
- name: "eienjs/typescript/setup",
1796
- plugins: {
1797
- "antfu": pluginAntfu,
1798
- "@typescript-eslint": pluginTs
1799
- }
1800
- },
1801
- ...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
1802
- {
1803
- files,
1804
- name: "eienjs/typescript/rules",
1805
- rules: {
1806
- ...pluginTs.configs["eslint-recommended"].overrides?.[0].rules,
1807
- ...pluginTs.configs.strict.rules,
1808
- ...stylistic$1 ? pluginTs.configs.stylistic.rules : {},
1809
- "no-dupe-class-members": "off",
1810
- "no-redeclare": "off",
1811
- "no-use-before-define": "off",
1812
- "no-useless-constructor": "off",
1813
- "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
1814
- "@typescript-eslint/consistent-type-assertions": "error",
1815
- "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
1816
- "@typescript-eslint/consistent-type-imports": ["error", {
1817
- disallowTypeAnnotations: false,
1818
- fixStyle: "separate-type-imports",
1819
- prefer: "type-imports"
1820
- }],
1821
- "@typescript-eslint/default-param-last": "error",
1822
- "@typescript-eslint/method-signature-style": ["error", "property"],
1823
- "@typescript-eslint/no-dupe-class-members": "error",
1824
- "@typescript-eslint/no-dynamic-delete": "off",
1825
- "@typescript-eslint/no-empty-object-type": "off",
1826
- "@typescript-eslint/no-explicit-any": "off",
1827
- "@typescript-eslint/no-extraneous-class": "off",
1828
- "@typescript-eslint/no-import-type-side-effects": "error",
1829
- "@typescript-eslint/no-invalid-void-type": "off",
1830
- "@typescript-eslint/no-non-null-assertion": "off",
1831
- "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
1832
- "@typescript-eslint/no-require-imports": "error",
1833
- "@typescript-eslint/no-unused-expressions": ["error", {
1834
- allowShortCircuit: true,
1835
- allowTaggedTemplates: true,
1836
- allowTernary: true
1837
- }],
1838
- "@typescript-eslint/no-unused-vars": ["error", {
1839
- "args": "all",
1840
- "argsIgnorePattern": "^_",
1841
- "caughtErrors": "all",
1842
- "caughtErrorsIgnorePattern": "^_",
1843
- "destructuredArrayIgnorePattern": "^_",
1844
- "varsIgnorePattern": "^_",
1845
- "ignoreRestSiblings": true
1846
- }],
1847
- "@typescript-eslint/no-use-before-define": ["error", {
1848
- classes: false,
1849
- functions: false,
1850
- variables: true
1851
- }],
1852
- "@typescript-eslint/no-useless-constructor": "off",
1853
- "@typescript-eslint/no-wrapper-object-types": "error",
1854
- "@typescript-eslint/triple-slash-reference": "off",
1855
- "@typescript-eslint/unified-signatures": "off",
1856
- ...overrides
1857
- }
1858
- },
1859
- ...isTypeAware ? [{
1860
- files: filesTypeAware,
1861
- ignores: ignoresTypeAware,
1862
- name: "eienjs/typescript/rules-type-aware",
1863
- rules: {
1864
- ...pluginTs.configs["strict-type-checked"].rules,
1865
- ...stylistic$1 ? pluginTs.configs["stylistic-type-checked"].rules : {},
1866
- ...typeAwareRules,
1867
- ...overridesTypeAware
1868
- }
1869
- }] : []
1870
- ];
1871
- }
1872
-
1873
- //#endregion
1874
- //#region src/configs/unicorn.ts
1875
- function unicorn(options = {}) {
1876
- const { overrides = {} } = options;
1877
- return [{
1878
- name: "eienjs/unicorn/rules",
1879
- plugins: { unicorn: pluginUnicorn },
1880
- rules: {
1881
- ...pluginUnicorn.configs.recommended.rules,
1882
- "unicorn/no-this-assignment": "off",
1883
- "unicorn/consistent-destructuring": "error",
1884
- "unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
1885
- "unicorn/no-null": "off",
1886
- "unicorn/no-static-only-class": "off",
1887
- "unicorn/numeric-separators-style": "off",
1888
- "unicorn/prefer-dom-node-append": "off",
1889
- "unicorn/prefer-dom-node-dataset": "off",
1890
- "unicorn/prefer-dom-node-remove": "off",
1891
- "unicorn/prefer-dom-node-text-content": "off",
1892
- "unicorn/prefer-modern-dom-apis": "off",
1893
- "unicorn/prefer-query-selector": "off",
1894
- "unicorn/prefer-switch": ["error", { emptyDefaultCase: "do-nothing-comment" }],
1895
- "unicorn/prevent-abbreviations": "off",
1896
- "unicorn/no-thenable": "off",
1897
- "unicorn/expiring-todo-comments": "off",
1898
- "unicorn/no-array-reduce": "off",
1899
- "unicorn/prefer-export-from": "off",
1900
- "unicorn/prefer-top-level-await": "off",
1901
- "unicorn/filename-case": "off",
1902
- ...overrides
1903
- }
1904
- }, {
1905
- files: [GLOB_SRC],
1906
- name: "eienjs/unicorn/special-rules",
1907
- rules: { "unicorn/filename-case": ["error", { case: "snakeCase" }] }
1908
- }];
1909
- }
1910
-
1911
- //#endregion
1912
- //#region src/configs/vue.ts
1913
- async function vue(options = {}) {
1914
- const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic$1 = true, typescript: typescript$1, componentNameInTemplateCasingOnlyRegistered = false, componentNameInTemplateCasingIgnores = [], componentNameInTemplateCasingGlobals = [] } = options;
1915
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1916
- const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1917
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1918
- interopDefault(import("eslint-plugin-vue")),
1919
- interopDefault(import("vue-eslint-parser")),
1920
- interopDefault(import("eslint-processor-vue-blocks"))
1921
- ]);
1922
- return [
1923
- {
1924
- languageOptions: { globals: {
1925
- computed: "readonly",
1926
- defineEmits: "readonly",
1927
- defineExpose: "readonly",
1928
- defineProps: "readonly",
1929
- onMounted: "readonly",
1930
- onUnmounted: "readonly",
1931
- reactive: "readonly",
1932
- ref: "readonly",
1933
- shallowReactive: "readonly",
1934
- shallowRef: "readonly",
1935
- toRef: "readonly",
1936
- toRefs: "readonly",
1937
- watch: "readonly",
1938
- watchEffect: "readonly"
1939
- } },
1940
- name: "eienjs/vue/setup",
1941
- plugins: { vue: pluginVue }
1942
- },
1943
- {
1944
- files,
1945
- languageOptions: {
1946
- parser: parserVue,
1947
- parserOptions: {
1948
- ecmaFeatures: { jsx: true },
1949
- extraFileExtensions: [".vue"],
1950
- parser: typescript$1 ? await interopDefault(import("@typescript-eslint/parser")) : null,
1951
- sourceType: "module"
1952
- }
1953
- },
1954
- name: "eienjs/vue/rules",
1955
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks({
1956
- ...sfcBlocks,
1957
- blocks: {
1958
- styles: true,
1959
- ...sfcBlocks.blocks
1960
- }
1961
- })]),
1962
- rules: {
1963
- ...pluginVue.configs.base.rules,
1964
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
1965
- ...acc,
1966
- ...c
1967
- }), {}),
1968
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
1969
- ...acc,
1970
- ...c
1971
- }), {}),
1972
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
1973
- ...acc,
1974
- ...c
1975
- }), {}),
1976
- "vue/block-lang": ["error", { script: { lang: "ts" } }],
1977
- "vue/block-order": ["error", { order: [
1978
- "script",
1979
- "template",
1980
- "style"
1981
- ] }],
1982
- "vue/component-api-style": ["error", ["script-setup"]],
1983
- "vue/component-name-in-template-casing": [
1984
- "error",
1985
- "PascalCase",
1986
- {
1987
- registeredComponentsOnly: componentNameInTemplateCasingOnlyRegistered,
1988
- ignores: componentNameInTemplateCasingIgnores,
1989
- globals: componentNameInTemplateCasingGlobals
1990
- }
1991
- ],
1992
- "vue/component-options-name-casing": ["error", "PascalCase"],
1993
- "vue/custom-event-name-casing": ["error", "camelCase"],
1994
- "vue/define-macros-order": ["error", { order: [
1995
- "defineOptions",
1996
- "defineProps",
1997
- "defineEmits",
1998
- "defineSlots"
1999
- ] }],
2000
- "vue/define-props-declaration": ["error", "runtime"],
2001
- "vue/dot-location": ["error", "property"],
2002
- "vue/dot-notation": ["error", { allowKeywords: true }],
2003
- "vue/eqeqeq": ["error", "smart"],
2004
- "vue/html-indent": ["error", indent],
2005
- "vue/html-quotes": ["error", "double"],
2006
- "vue/max-attributes-per-line": "off",
2007
- "vue/multi-word-component-names": "off",
2008
- "vue/no-dupe-keys": "off",
2009
- "vue/no-empty-component-block": "error",
2010
- "vue/no-empty-pattern": "error",
2011
- "vue/no-irregular-whitespace": "error",
2012
- "vue/no-loss-of-precision": "error",
2013
- "vue/no-multiple-objects-in-class": "error",
2014
- "vue/no-ref-object-reactivity-loss": "error",
2015
- "vue/no-required-prop-with-default": "error",
2016
- "vue/no-restricted-syntax": [
2017
- "error",
2018
- "DebuggerStatement",
2019
- "LabeledStatement",
2020
- "WithStatement"
2021
- ],
2022
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
2023
- "vue/no-root-v-if": "error",
2024
- "vue/no-setup-props-reactivity-loss": "off",
2025
- "vue/no-sparse-arrays": "error",
2026
- "vue/no-template-target-blank": "error",
2027
- "vue/no-unused-properties": "error",
2028
- "vue/no-unused-refs": "error",
2029
- "vue/no-use-v-else-with-v-for": "error",
2030
- "vue/no-useless-mustaches": "error",
2031
- "vue/no-useless-v-bind": "error",
2032
- "vue/no-v-html": "off",
2033
- "vue/object-shorthand": [
2034
- "error",
2035
- "always",
2036
- {
2037
- avoidQuotes: true,
2038
- ignoreConstructors: false
2039
- }
2040
- ],
2041
- "vue/prefer-separate-static-class": "error",
2042
- "vue/prefer-template": "error",
2043
- "vue/prefer-true-attribute-shorthand": "error",
2044
- "vue/prop-name-casing": ["error", "camelCase"],
2045
- "vue/require-typed-ref": "error",
2046
- "vue/space-infix-ops": "error",
2047
- "vue/space-unary-ops": ["error", {
2048
- nonwords: false,
2049
- words: true
2050
- }],
2051
- "vue/static-class-names-order": "off",
2052
- ...stylistic$1 ? {
2053
- "vue/array-bracket-spacing": ["error", "never"],
2054
- "vue/arrow-spacing": ["error", {
2055
- after: true,
2056
- before: true
2057
- }],
2058
- "vue/block-spacing": ["error", "always"],
2059
- "vue/block-tag-newline": ["error", {
2060
- multiline: "always",
2061
- singleline: "always"
2062
- }],
2063
- "vue/brace-style": [
2064
- "error",
2065
- "1tbs",
2066
- { allowSingleLine: true }
2067
- ],
2068
- "vue/comma-dangle": ["error", "always-multiline"],
2069
- "vue/comma-spacing": ["error", {
2070
- after: true,
2071
- before: false
2072
- }],
2073
- "vue/comma-style": ["error", "last"],
2074
- "vue/html-comment-content-spacing": [
2075
- "error",
2076
- "always",
2077
- { exceptions: ["-"] }
2078
- ],
2079
- "vue/key-spacing": ["error", {
2080
- afterColon: true,
2081
- beforeColon: false
2082
- }],
2083
- "vue/keyword-spacing": ["error", {
2084
- after: true,
2085
- before: true
2086
- }],
2087
- "vue/object-curly-newline": "off",
2088
- "vue/object-curly-spacing": ["error", "always"],
2089
- "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
2090
- "vue/operator-linebreak": ["error", "before"],
2091
- "vue/padding-line-between-blocks": ["error", "always"],
2092
- "vue/quote-props": ["error", "consistent-as-needed"],
2093
- "vue/space-in-parens": ["error", "never"],
2094
- "vue/template-curly-spacing": "error"
2095
- } : {},
2096
- "antfu/no-top-level-await": "off",
2097
- "n/prefer-global/process": "off",
2098
- "@typescript-eslint/explicit-function-return-type": "off",
2099
- "@typescript-eslint/naming-convention": "off",
2100
- "@stylistic/max-len": "off",
2101
- ...overrides
2102
- }
2103
- },
2104
- {
2105
- files: [`**/composables/${GLOB_SRC}`],
2106
- name: "eienjs/vue/composables-disables",
2107
- rules: { "@typescript-eslint/explicit-module-boundary-types": "off" }
2108
- }
2109
- ];
2110
- }
2111
-
2112
- //#endregion
2113
- //#region src/configs/yaml.ts
2114
- async function yaml(options = {}) {
2115
- const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic$1 = true } = options;
2116
- const { indent = 2, quotes = "single" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
2117
- const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
2118
- return [
2119
- {
2120
- name: "eienjs/yaml/setup",
2121
- plugins: { yaml: pluginYaml }
2122
- },
2123
- {
2124
- files,
2125
- languageOptions: { parser: parserYaml },
2126
- name: "eienjs/yaml/rules",
2127
- rules: {
2128
- "@stylistic/spaced-comment": "off",
2129
- "yaml/block-mapping": "error",
2130
- "yaml/block-sequence": "error",
2131
- "yaml/no-empty-key": "error",
2132
- "yaml/no-empty-sequence-entry": "error",
2133
- "yaml/no-irregular-whitespace": "error",
2134
- "yaml/plain-scalar": "error",
2135
- "yaml/vue-custom-block/no-parsing-error": "error",
2136
- ...stylistic$1 ? {
2137
- "yaml/block-mapping-question-indicator-newline": "error",
2138
- "yaml/block-sequence-hyphen-indicator-newline": "error",
2139
- "yaml/flow-mapping-curly-newline": "error",
2140
- "yaml/flow-mapping-curly-spacing": "error",
2141
- "yaml/flow-sequence-bracket-newline": "error",
2142
- "yaml/flow-sequence-bracket-spacing": "error",
2143
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2144
- "yaml/key-spacing": "error",
2145
- "yaml/no-tab-indent": "error",
2146
- "yaml/quotes": ["error", {
2147
- avoidEscape: true,
2148
- prefer: quotes === "backtick" ? "single" : quotes
2149
- }],
2150
- "yaml/spaced-comment": "error"
2151
- } : {},
2152
- ...overrides
2153
- }
2154
- },
2155
- {
2156
- files: ["pnpm-workspace.yaml"],
2157
- name: "eienjs/yaml/pnpm-workspace",
2158
- rules: { "yaml/sort-keys": [
2159
- "error",
2160
- {
2161
- order: [
2162
- "packages",
2163
- "overrides",
2164
- "patchedDependencies",
2165
- "hoistPattern",
2166
- "catalog",
2167
- "catalogs",
2168
- "allowedDeprecatedVersions",
2169
- "allowNonAppliedPatches",
2170
- "configDependencies",
2171
- "ignoredBuiltDependencies",
2172
- "ignoredOptionalDependencies",
2173
- "neverBuiltDependencies",
2174
- "onlyBuiltDependencies",
2175
- "onlyBuiltDependenciesFile",
2176
- "packageExtensions",
2177
- "peerDependencyRules",
2178
- "supportedArchitectures"
2179
- ],
2180
- pathPattern: "^$"
2181
- },
2182
- {
2183
- order: { type: "asc" },
2184
- pathPattern: ".*"
2185
- }
2186
- ] }
2187
- }
2188
- ];
2189
- }
2190
-
2191
- //#endregion
2192
- export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, adonisjs, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, nuxt, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml };