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