@ntnyq/eslint-config 5.3.1 → 5.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 (3) hide show
  1. package/package.json +38 -37
  2. package/dist/index.d.ts +0 -17213
  3. package/dist/index.js +0 -3170
package/dist/index.js DELETED
@@ -1,3170 +0,0 @@
1
- import { FlatConfigComposer } from "eslint-flat-config-utils";
2
- import { mergeProcessors, mergeProcessors as mergeProcessors$1, processorPassThrough } from "eslint-merge-processors";
3
- import { configs as configsTypeScript, parser as parserTypeScript, plugin as pluginTypeScript } from "typescript-eslint";
4
- import * as parserVue from "vue-eslint-parser";
5
- import * as parserToml from "toml-eslint-parser";
6
- import * as parserYaml from "yaml-eslint-parser";
7
- import * as parserPlain from "eslint-parser-plain";
8
- import * as parserJsonc from "jsonc-eslint-parser";
9
- import * as pluginRegexp from "eslint-plugin-regexp";
10
- import pluginNode from "eslint-plugin-n";
11
- import pluginVue from "eslint-plugin-vue";
12
- import pluginYml from "eslint-plugin-yml";
13
- import pluginSvgo from "eslint-plugin-svgo";
14
- import pluginToml from "eslint-plugin-toml";
15
- import pluginMarkdown from "@eslint/markdown";
16
- import pluginAntfu from "eslint-plugin-antfu";
17
- import pluginJsdoc from "eslint-plugin-jsdoc";
18
- import pluginJsonc from "eslint-plugin-jsonc";
19
- import pluginNtnyq from "eslint-plugin-ntnyq";
20
- import pluginPinia from "eslint-plugin-pinia";
21
- import pluginDepend from "eslint-plugin-depend";
22
- import pluginUnoCSS from "@unocss/eslint-plugin";
23
- import pluginVitest from "@vitest/eslint-plugin";
24
- import pluginUnicorn from "eslint-plugin-unicorn";
25
- import pluginImportX from "eslint-plugin-import-x";
26
- import pluginPrettier from "eslint-plugin-prettier";
27
- import pluginDeMorgan from "eslint-plugin-de-morgan";
28
- import pluginNoOnlyTests from "eslint-plugin-no-only-tests";
29
- import pluginGitHubAction from "eslint-plugin-github-action";
30
- import pluginPerfectionist from "eslint-plugin-perfectionist";
31
- import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
32
- import processorVueBlocks from "eslint-processor-vue-blocks";
33
- import { resolve } from "node:path";
34
- import process from "node:process";
35
- import { isPackageExists } from "local-pkg";
36
- import { builtinCommands, defineCommand } from "eslint-plugin-command/commands";
37
- import createCommandConfig from "eslint-plugin-command/config";
38
- import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
39
- import globals from "globals";
40
- import createGitIgnoreConfig from "eslint-config-flat-gitignore";
41
- import jsConfig from "@eslint/js";
42
-
43
- //#region src/globs.ts
44
- /**
45
- * @file globs constants
46
- */
47
- const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
48
- const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
49
- const GLOB_JS = "**/*.?([cm])js";
50
- const GLOB_JSX = `${GLOB_JS}x`;
51
- const GLOB_JSX_ONLY = "**/*.jsx";
52
- const GLOB_TS = "**/*.?([cm])ts";
53
- const GLOB_TSX = `${GLOB_TS}x`;
54
- const GLOB_TSX_ONLY = "**/*.tsx";
55
- const GLOB_DTS = "**/*.d.?([cm])ts";
56
- const GLOB_TYPES = [
57
- GLOB_DTS,
58
- `**/types/${GLOB_TS}`,
59
- `**/types.ts`
60
- ];
61
- const GLOB_TYPE_TEST = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
62
- const GLOB_TEST = [
63
- `**/*.test.${GLOB_SRC_EXT}`,
64
- `**/*.spec.${GLOB_SRC_EXT}`,
65
- `**/*.bench.${GLOB_SRC_EXT}`,
66
- `**/*.benchmark.${GLOB_SRC_EXT}`,
67
- ...GLOB_TYPE_TEST
68
- ];
69
- const GLOB_STYLE = "**/*.{c,le,sc}ss";
70
- const GLOB_CSS = "**/*.css";
71
- const GLOB_LESS = "**/*.less";
72
- const GLOB_SCSS = "**/*.scss";
73
- const GLOB_POSTCSS = "**/*.{p,post}css";
74
- const GLOB_JSON = "**/*.json";
75
- const GLOB_JSON5 = "**/*.json5";
76
- const GLOB_JSONC = "**/*.jsonc";
77
- const GLOB_PACKAGE_JSON = "**/package.json";
78
- const GLOB_JSON_SCHEMA = ["**/*.schema.json", "**/schemas/*.json"];
79
- const GLOB_TSCONFIG_JSON = ["**/tsconfig.json", "**/tsconfig.*.json"];
80
- const GLOB_YAML = "**/*.y?(a)ml";
81
- const GLOB_PNPM_WORKSPACE_YAML = "**/pnpm-workspace.yaml";
82
- const GLOB_SVG = "**/*.svg";
83
- const GLOB_VUE = "**/*.vue";
84
- const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
85
- const GLOB_TOML = "**/*.toml";
86
- const GLOB_HTML = "**/*.htm?(l)";
87
- const GLOB_ASTRO = "**/*.astro";
88
- const GLOB_ASTRO_TS = "**/*.astro/*.ts";
89
- const GLOB_MARKDOWN = "**/*.md";
90
- const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
91
- const GLOB_MARKDOWN_NESTED = `${GLOB_MARKDOWN}/*.md`;
92
- const GLOB_ALL_SRC = [
93
- GLOB_SRC,
94
- GLOB_STYLE,
95
- GLOB_JSON,
96
- GLOB_JSON5,
97
- GLOB_VUE,
98
- GLOB_YAML,
99
- GLOB_TOML,
100
- GLOB_HTML,
101
- GLOB_MARKDOWN
102
- ];
103
- const GLOB_PINIA_STORE = `**/store?(s)/*.${GLOB_SRC_EXT}`;
104
- const GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
105
- const GLOB_NODE_MODULES = "**/node_modules/**";
106
- const GLOB_DIST = "**/dist/**";
107
- const GLOB_LOCKFILE = [
108
- "**/package-lock.json",
109
- "**/yarn.lock",
110
- "**/pnpm-lock.yaml",
111
- "**/bun.lock?(b)",
112
- "**/deno.lock"
113
- ];
114
- const GLOB_EXCLUDE = [
115
- GLOB_NODE_MODULES,
116
- GLOB_DIST,
117
- ...GLOB_LOCKFILE,
118
- "**/.pnpm-store/**",
119
- "!.github",
120
- "!.vitepress",
121
- "!.vuepress",
122
- "!.vscode",
123
- "**/CHANGELOG*.md",
124
- "**/*.min.*",
125
- "**/LICENSE*",
126
- "**/__snapshots__",
127
- "**/auto-import?(s).d.ts",
128
- "**/components.d.ts",
129
- "**/typed-router.d.ts",
130
- "**/uni-pages.d.ts",
131
- "**/coverage",
132
- "**/fixtures",
133
- "**/output",
134
- "**/public",
135
- "**/static",
136
- "**/?(.)temp",
137
- "**/?(.)cache",
138
- "**/.eslintcache",
139
- "**/.stylelintcache",
140
- "**/.eslint-config-inspector",
141
- "**/.vite-inspect",
142
- "**/.nuxt",
143
- "**/.wxt",
144
- "**/.output",
145
- "**/.tsup",
146
- "**/.nitro",
147
- "**/.vercel",
148
- "**/.wrangler",
149
- "**/.changeset",
150
- "**/.npmrc",
151
- "**/.yarnrc",
152
- "**/.husky",
153
- "**/src-tauri/gen",
154
- "**/src-tauri/target"
155
- ];
156
-
157
- //#endregion
158
- //#region src/configs/vue.ts
159
- const sharedRules = {
160
- ...pluginVue.configs.base.rules,
161
- ...pluginVue.configs.essential.rules,
162
- ...pluginVue.configs["strongly-recommended"].rules,
163
- ...pluginVue.configs.recommended.rules
164
- };
165
- const disabledRules$1 = {
166
- "vue/multi-word-component-names": "off",
167
- "vue/no-setup-props-reactivity-loss": "off",
168
- "vue/no-v-html": "off",
169
- "vue/no-v-text-v-html-on-component": "off",
170
- "vue/require-default-prop": "off",
171
- "vue/require-prop-types": "off"
172
- };
173
- const extensionRules = {
174
- "vue/array-bracket-spacing": ["error", "never"],
175
- "vue/arrow-spacing": ["error", {
176
- after: true,
177
- before: true
178
- }],
179
- "vue/block-spacing": ["error", "always"],
180
- "vue/brace-style": [
181
- "error",
182
- "stroustrup",
183
- { allowSingleLine: true }
184
- ],
185
- "vue/comma-dangle": ["error", "always-multiline"],
186
- "vue/comma-spacing": ["error", {
187
- after: true,
188
- before: false
189
- }],
190
- "vue/comma-style": ["error", "last"],
191
- "vue/dot-location": ["error", "property"],
192
- "vue/dot-notation": ["error", { allowKeywords: true }],
193
- "vue/eqeqeq": ["error", "smart"],
194
- "vue/key-spacing": ["error", {
195
- afterColon: true,
196
- beforeColon: false
197
- }],
198
- "vue/keyword-spacing": ["error", {
199
- after: true,
200
- before: true
201
- }],
202
- "vue/no-constant-condition": "error",
203
- "vue/no-empty-pattern": "error",
204
- "vue/no-extra-parens": ["error", "functions"],
205
- "vue/no-loss-of-precision": "error",
206
- "vue/no-negated-condition": "error",
207
- "vue/no-restricted-syntax": [
208
- "error",
209
- "DebuggerStatement",
210
- "LabeledStatement",
211
- "WithStatement"
212
- ],
213
- "vue/no-sparse-arrays": "error",
214
- "vue/object-curly-newline": ["error", {
215
- consistent: true,
216
- multiline: true
217
- }],
218
- "vue/object-curly-spacing": ["error", "always"],
219
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
220
- "vue/object-shorthand": [
221
- "error",
222
- "always",
223
- {
224
- avoidQuotes: true,
225
- ignoreConstructors: false
226
- }
227
- ],
228
- "vue/operator-linebreak": ["error", "before"],
229
- "vue/prefer-template": "error",
230
- "vue/quote-props": ["error", "consistent-as-needed"],
231
- "vue/space-in-parens": ["error", "never"],
232
- "vue/space-infix-ops": "error",
233
- "vue/space-unary-ops": ["error", {
234
- nonwords: false,
235
- words: true
236
- }],
237
- "vue/template-curly-spacing": "error"
238
- };
239
- const unCategorizedRules = {
240
- "vue/block-order": ["error", { order: [
241
- "script",
242
- "template",
243
- "style"
244
- ] }],
245
- "vue/block-tag-newline": ["error", {
246
- multiline: "always",
247
- singleline: "always"
248
- }],
249
- "vue/component-api-style": ["error", ["script-setup", "composition"]],
250
- "vue/component-name-in-template-casing": [
251
- "error",
252
- "PascalCase",
253
- {
254
- ignores: ["slot", "component"],
255
- registeredComponentsOnly: false
256
- }
257
- ],
258
- "vue/component-options-name-casing": ["error", "PascalCase"],
259
- "vue/custom-event-name-casing": ["error", "camelCase"],
260
- "vue/define-emits-declaration": ["error", "type-literal"],
261
- "vue/define-macros-order": ["error", {
262
- defineExposeLast: true,
263
- order: [
264
- "defineProps",
265
- "defineEmits",
266
- "defineOptions",
267
- "defineSlots",
268
- "defineModel"
269
- ]
270
- }],
271
- "vue/define-props-declaration": ["error", "type-based"],
272
- "vue/define-props-destructuring": ["error", { destructure: "never" }],
273
- "vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
274
- "vue/html-button-has-type": ["error", {
275
- button: true,
276
- reset: true,
277
- submit: true
278
- }],
279
- "vue/html-comment-content-newline": [
280
- "error",
281
- {
282
- multiline: "always",
283
- singleline: "ignore"
284
- },
285
- { exceptions: ["*"] }
286
- ],
287
- "vue/html-comment-content-spacing": [
288
- "error",
289
- "always",
290
- { exceptions: ["-"] }
291
- ],
292
- "vue/html-comment-indent": ["error", 2],
293
- "vue/next-tick-style": ["error", "promise"],
294
- "vue/no-deprecated-delete-set": "error",
295
- "vue/no-deprecated-model-definition": ["error", { allowVue3Compat: true }],
296
- "vue/no-duplicate-attr-inheritance": ["error", { checkMultiRootNodes: true }],
297
- "vue/no-empty-component-block": "error",
298
- "vue/no-irregular-whitespace": "error",
299
- "vue/no-multiple-objects-in-class": "error",
300
- "vue/no-negated-v-if-condition": "error",
301
- "vue/no-ref-object-reactivity-loss": "error",
302
- "vue/no-required-prop-with-default": ["error", { autofix: true }],
303
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
304
- "vue/no-static-inline-styles": ["error", { allowBinding: true }],
305
- "vue/no-unused-emit-declarations": "error",
306
- "vue/no-use-v-else-with-v-for": "error",
307
- "vue/no-useless-v-bind": "error",
308
- "vue/no-v-text": "error",
309
- "vue/padding-line-between-blocks": "error",
310
- "vue/prefer-define-options": "error",
311
- "vue/prefer-prop-type-boolean-first": "error",
312
- "vue/prefer-separate-static-class": "error",
313
- "vue/prefer-true-attribute-shorthand": ["error", "always"],
314
- "vue/prefer-use-template-ref": "error",
315
- "vue/require-macro-variable-name": ["error", {
316
- defineEmits: "emits",
317
- defineProps: "props",
318
- defineSlots: "slots",
319
- useAttrs: "attrs",
320
- useSlots: "slots"
321
- }],
322
- "vue/require-typed-object-prop": "error",
323
- "vue/slot-name-casing": ["error", "kebab-case"],
324
- "vue/v-for-delimiter-style": ["error", "in"],
325
- "vue/valid-define-options": "error"
326
- };
327
- /**
328
- * Config for vue files
329
- *
330
- * @see {@link https://github.com/vuejs/eslint-plugin-vue}
331
- *
332
- * @param options - {@link ConfigVueOptions}
333
- * @returns ESLint configs
334
- */
335
- const configVue = (options = {}) => {
336
- const { files = [GLOB_VUE], extraFileExtensions = [] } = options;
337
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
338
- function getVueProcessor() {
339
- const processorVueSFC = pluginVue.processors[".vue"];
340
- if (!sfcBlocks) return processorVueSFC;
341
- return mergeProcessors$1([processorVueSFC, processorVueBlocks({
342
- ...sfcBlocks,
343
- blocks: {
344
- styles: true,
345
- ...sfcBlocks.blocks
346
- }
347
- })]);
348
- }
349
- return [{
350
- name: "ntnyq/vue/setup",
351
- plugins: {
352
- "@typescript-eslint": pluginTypeScript,
353
- vue: pluginVue
354
- }
355
- }, {
356
- name: "ntnyq/vue/rules",
357
- files,
358
- processor: getVueProcessor(),
359
- languageOptions: {
360
- parser: parserVue,
361
- parserOptions: {
362
- ecmaVersion: "latest",
363
- extraFileExtensions,
364
- parser: parserTypeScript,
365
- sourceType: "module",
366
- ecmaFeatures: { jsx: true }
367
- }
368
- },
369
- rules: {
370
- ...sharedRules,
371
- "vue/attributes-order": ["error", {
372
- alphabetical: false,
373
- order: [
374
- "EVENTS",
375
- "TWO_WAY_BINDING",
376
- "OTHER_DIRECTIVES",
377
- "LIST_RENDERING",
378
- "CONDITIONALS",
379
- "CONTENT",
380
- "SLOT",
381
- "UNIQUE",
382
- "DEFINITION",
383
- "ATTR_DYNAMIC",
384
- "RENDER_MODIFIERS",
385
- "GLOBAL",
386
- "ATTR_STATIC",
387
- "ATTR_SHORTHAND_BOOL"
388
- ]
389
- }],
390
- "vue/html-self-closing": ["error", {
391
- math: "always",
392
- svg: "always",
393
- html: {
394
- component: "always",
395
- normal: "always",
396
- void: "always"
397
- }
398
- }],
399
- "vue/max-attributes-per-line": ["error", {
400
- multiline: 1,
401
- singleline: 1
402
- }],
403
- "vue/order-in-components": ["error", { order: [
404
- "el",
405
- "name",
406
- "key",
407
- "parent",
408
- "functional",
409
- ["provide", "inject"],
410
- ["delimiters", "comments"],
411
- [
412
- "components",
413
- "directives",
414
- "filters"
415
- ],
416
- "extends",
417
- "mixins",
418
- "layout",
419
- "middleware",
420
- "validate",
421
- "scrollToTop",
422
- "transition",
423
- "loading",
424
- "inheritAttrs",
425
- "model",
426
- ["props", "propsData"],
427
- "slots",
428
- "expose",
429
- "emits",
430
- "setup",
431
- "asyncData",
432
- "computed",
433
- "data",
434
- "fetch",
435
- "head",
436
- "methods",
437
- ["template", "render"],
438
- "watch",
439
- "watchQuery",
440
- "LIFECYCLE_HOOKS",
441
- "renderError",
442
- "ROUTER_GUARDS"
443
- ] }],
444
- "vue/prop-name-casing": ["error", "camelCase"],
445
- "vue/this-in-template": ["error", "never"],
446
- ...disabledRules$1,
447
- ...extensionRules,
448
- ...unCategorizedRules,
449
- ...options.overrides
450
- }
451
- }];
452
- };
453
-
454
- //#endregion
455
- //#region src/configs/yml.ts
456
- /**
457
- * @see {@link https://github.com/ota-meshi/eslint-plugin-yml/blob/master/src/configs/base.ts}
458
- */
459
- const disabledCoreRules$1 = {
460
- "no-irregular-whitespace": "off",
461
- "no-unused-vars": "off",
462
- "spaced-comment": "off"
463
- };
464
- /**
465
- * Config for yml, yaml files
466
- *
467
- * @see {@link https://ota-meshi.github.io/eslint-plugin-yml}
468
- *
469
- * @param options - {@link ConfigYmlOptions}
470
- * @returns ESLint configs
471
- */
472
- const configYml = (options = {}) => {
473
- const { files = [GLOB_YAML] } = options;
474
- return [{
475
- name: "ntnyq/yml",
476
- files,
477
- plugins: { yml: pluginYml },
478
- languageOptions: { parser: parserYaml },
479
- rules: {
480
- "yml/no-empty-mapping-value": "off",
481
- "yml/block-mapping": "error",
482
- "yml/block-mapping-question-indicator-newline": "error",
483
- "yml/block-sequence": "error",
484
- "yml/block-sequence-hyphen-indicator-newline": "error",
485
- "yml/flow-mapping-curly-newline": "error",
486
- "yml/flow-mapping-curly-spacing": "error",
487
- "yml/flow-sequence-bracket-newline": "error",
488
- "yml/flow-sequence-bracket-spacing": "error",
489
- "yml/indent": "error",
490
- "yml/key-spacing": "error",
491
- "yml/no-empty-document": "error",
492
- "yml/no-empty-key": "error",
493
- "yml/no-empty-sequence-entry": "error",
494
- "yml/no-irregular-whitespace": "error",
495
- "yml/no-tab-indent": "error",
496
- "yml/plain-scalar": "error",
497
- "yml/quotes": ["error", {
498
- avoidEscape: false,
499
- prefer: "single"
500
- }],
501
- "yml/spaced-comment": "error",
502
- "yml/vue-custom-block/no-parsing-error": "error",
503
- ...disabledCoreRules$1,
504
- ...options.prettier ? {
505
- "yml/block-mapping-colon-indicator-newline": "off",
506
- "yml/block-mapping-question-indicator-newline": "off",
507
- "yml/block-sequence-hyphen-indicator-newline": "off",
508
- "yml/flow-mapping-curly-newline": "off",
509
- "yml/flow-mapping-curly-spacing": "off",
510
- "yml/flow-sequence-bracket-newline": "off",
511
- "yml/flow-sequence-bracket-spacing": "off",
512
- "yml/indent": "off",
513
- "yml/key-spacing": "off",
514
- "yml/no-multiple-empty-lines": "off",
515
- "yml/no-trailing-zeros": "off",
516
- "yml/quotes": "off"
517
- } : {},
518
- ...options.overrides
519
- }
520
- }];
521
- };
522
-
523
- //#endregion
524
- //#region src/utils/env.ts
525
- const hasPinia = () => isPackageExists("pinia");
526
- const hasVitest = () => isPackageExists("vitest");
527
- const hasTypeScript = () => isPackageExists("typescript");
528
- const hasShadcnVue = () => (isPackageExists("radix-vue") || isPackageExists("reka-ui")) && isPackageExists("class-variance-authority") && isPackageExists("clsx");
529
- const hasUnoCSS = () => isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
530
- const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", { paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")] });
531
-
532
- //#endregion
533
- //#region src/utils/resolveSubOptions.ts
534
- function resolveSubOptions(options, key) {
535
- return typeof options[key] === "boolean" ? {} : options[key] || {};
536
- }
537
-
538
- //#endregion
539
- //#region src/utils/getOverrides.ts
540
- function getOverrides(options, key) {
541
- const subOptions = resolveSubOptions(options, key);
542
- return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
543
- }
544
-
545
- //#endregion
546
- //#region src/utils/combineConfigs.ts
547
- async function combineConfigs(...configs) {
548
- const resolved = await Promise.all(configs);
549
- return resolved.flat();
550
- }
551
-
552
- //#endregion
553
- //#region src/utils/isInGitHooksOrRunBySpecifyPackages.ts
554
- const CHECKED_RUNNER_PACKAGES = [
555
- "nano-staged",
556
- "lint-staged",
557
- "lefthook",
558
- "tsx"
559
- ];
560
- function isInGitHooksOrRunBySpecifyPackages() {
561
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || CHECKED_RUNNER_PACKAGES.some((packageName) => process.env.npm_lifecycle_script?.startsWith(packageName)));
562
- }
563
-
564
- //#endregion
565
- //#region src/utils/ensurePackages.ts
566
- const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
567
- function isPackageInScope(name) {
568
- return isPackageExists(name, { paths: [import.meta.dirname] });
569
- }
570
- async function ensurePackages(packages) {
571
- if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope) return;
572
- const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
573
- if (nonExistingPackages.length === 0) return;
574
- const { confirm } = await import("@clack/prompts");
575
- const confirmInstall = await confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
576
- if (confirmInstall) try {
577
- const { installPackage } = await import("@antfu/install-pkg");
578
- await installPackage(nonExistingPackages, { dev: true });
579
- } catch (err) {
580
- console.log(err);
581
- }
582
- }
583
-
584
- //#endregion
585
- //#region src/utils/interopDefault.ts
586
- /**
587
- * Interop default export from a module
588
- * @param mod - The module
589
- * @returns The default export
590
- */
591
- async function interopDefault(mod) {
592
- const resolved = await mod;
593
- return resolved.default || resolved;
594
- }
595
-
596
- //#endregion
597
- //#region src/utils/mergePrettierOptions.ts
598
- function mergePrettierOptions(options = {}, overrides = {}) {
599
- const result = {
600
- ...options,
601
- ...overrides,
602
- plugins: [...options.plugins || [], ...overrides.plugins || []]
603
- };
604
- return result;
605
- }
606
-
607
- //#endregion
608
- //#region src/configs/html.ts
609
- /**
610
- * Config for html files
611
- *
612
- * @see {@link https://github.com/yeonjuan/html-eslint}
613
- *
614
- * @param options - {@link ConfigHtmlOptions}
615
- * @returns ESLint configs
616
- */
617
- const configHtml = async (options = {}) => {
618
- await ensurePackages(["@html-eslint/parser", "@html-eslint/eslint-plugin"]);
619
- const [parserHtml, pluginHtml] = await Promise.all([interopDefault(import("@html-eslint/parser")), interopDefault(import("@html-eslint/eslint-plugin"))]);
620
- const { files = [GLOB_HTML] } = options;
621
- return [{
622
- name: "ntnyq/html",
623
- files,
624
- plugins: { "@html-eslint": pluginHtml },
625
- languageOptions: { parser: parserHtml },
626
- rules: {
627
- "@html-eslint/attrs-newline": "error",
628
- "@html-eslint/element-newline": ["error", { inline: [`$inline`] }],
629
- "@html-eslint/indent": "error",
630
- "@html-eslint/no-duplicate-attrs": "error",
631
- "@html-eslint/no-duplicate-id": "error",
632
- "@html-eslint/no-extra-spacing-attrs": "error",
633
- "@html-eslint/no-multiple-h1": "error",
634
- "@html-eslint/no-obsolete-tags": "error",
635
- "@html-eslint/quotes": "error",
636
- "@html-eslint/require-closing-tags": "error",
637
- "@html-eslint/require-doctype": "error",
638
- "@html-eslint/require-img-alt": "error",
639
- "@html-eslint/require-lang": "error",
640
- "@html-eslint/require-li-container": "error",
641
- "@html-eslint/require-title": "error",
642
- "@html-eslint/use-baseline": "error",
643
- ...options.overrides
644
- }
645
- }];
646
- };
647
-
648
- //#endregion
649
- //#region src/configs/node.ts
650
- /**
651
- * Config for common files
652
- *
653
- * @see {@link https://github.com/eslint-community/eslint-plugin-n}
654
- *
655
- * @param options - {@link ConfigNodeOptions}
656
- * @returns ESLint configs
657
- */
658
- const configNode = (options = {}) => [{
659
- name: "ntnyq/node",
660
- plugins: { node: pluginNode },
661
- rules: {
662
- "node/handle-callback-err": ["error", "^(err|error)$"],
663
- "node/no-deprecated-api": "error",
664
- "node/no-exports-assign": "error",
665
- "node/no-new-require": "error",
666
- "node/no-path-concat": "error",
667
- "node/prefer-global/buffer": ["error", "never"],
668
- "node/prefer-global/process": ["error", "never"],
669
- "node/process-exit-as-throw": "error",
670
- ...options.overrides
671
- }
672
- }];
673
-
674
- //#endregion
675
- //#region src/configs/pnpm.ts
676
- /**
677
- * Config for pnpm package manager
678
- *
679
- * @see {@link https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm}
680
- *
681
- * @param options - {@link ConfigPnpmOptions}
682
- * @returns ESLint configs
683
- */
684
- const configPnpm = async (options = {}) => {
685
- await ensurePackages(["eslint-plugin-pnpm"]);
686
- const pluginPnpm = await interopDefault(import("eslint-plugin-pnpm"));
687
- const { filesJson = [GLOB_PACKAGE_JSON], filesYaml = [GLOB_PNPM_WORKSPACE_YAML] } = options;
688
- return [{
689
- name: "ntnyq/pnpm/package-json",
690
- files: filesJson,
691
- plugins: { pnpm: pluginPnpm },
692
- languageOptions: { parser: parserJsonc },
693
- rules: {
694
- "pnpm/json-enforce-catalog": ["error", { autofix: true }],
695
- "pnpm/json-valid-catalog": "error",
696
- ...options.overridesJsonRules
697
- }
698
- }, {
699
- name: "ntnyq/pnpm/pnpm-workspace-yaml",
700
- files: filesYaml,
701
- plugins: { pnpm: pluginPnpm },
702
- languageOptions: { parser: parserYaml },
703
- rules: {
704
- "pnpm/yaml-no-duplicate-catalog-item": "error",
705
- "pnpm/yaml-no-unused-catalog-item": "error",
706
- ...options.overridesYamlRules
707
- }
708
- }];
709
- };
710
-
711
- //#endregion
712
- //#region src/configs/sort.ts
713
- /**
714
- * Config for sort keys and values
715
- *
716
- * @param options - {@link ConfigSortOptions}
717
- * @returns ESLint configs
718
- */
719
- const configSort = (options = {}) => {
720
- const configs = [];
721
- const { additionalJsonFiles = [], additionalYamlFiles = [], i18nLocale: enableSortI18nLocale = true, jsonSchema: enableSortJsonSchema = true, packageJson: enableSortPackageJson = true, pnpmWorkspace: enableSortPnpmWorkspace = true, tsconfig: enableSortTsconfig = true } = options;
722
- if (enableSortTsconfig) configs.push({
723
- name: "ntnyq/sort/tsconfig",
724
- files: [...GLOB_TSCONFIG_JSON],
725
- rules: { "jsonc/sort-keys": [
726
- "error",
727
- {
728
- pathPattern: "^$",
729
- order: [
730
- "extends",
731
- "compilerOptions",
732
- "references",
733
- "files",
734
- "include",
735
- "exclude",
736
- "vueCompilerOptions",
737
- { order: { type: "asc" } }
738
- ]
739
- },
740
- {
741
- pathPattern: "^compilerOptions$",
742
- order: [
743
- "incremental",
744
- "composite",
745
- "tsBuildInfoFile",
746
- "disableSourceOfProjectReferenceRedirect",
747
- "disableSolutionSearching",
748
- "disableReferencedProjectLoad",
749
- "target",
750
- "lib",
751
- "jsx",
752
- "experimentalDecorators",
753
- "emitDecoratorMetadata",
754
- "jsxFactory",
755
- "jsxFragmentFactory",
756
- "jsxImportSource",
757
- "reactNamespace",
758
- "noLib",
759
- "useDefineForClassFields",
760
- "moduleDetection",
761
- "module",
762
- "rootDir",
763
- "moduleResolution",
764
- "baseUrl",
765
- "paths",
766
- "rootDirs",
767
- "typeRoots",
768
- "types",
769
- "allowUmdGlobalAccess",
770
- "moduleSuffixes",
771
- "allowImportingTsExtensions",
772
- "resolvePackageJsonExports",
773
- "resolvePackageJsonImports",
774
- "customConditions",
775
- "resolveJsonModule",
776
- "allowArbitraryExtensions",
777
- "noResolve",
778
- "erasableSyntaxOnly",
779
- "libReplacement",
780
- "allowJs",
781
- "checkJs",
782
- "maxNodeModuleJsDepth",
783
- "declaration",
784
- "declarationMap",
785
- "emitDeclarationOnly",
786
- "sourceMap",
787
- "inlineSourceMap",
788
- "outFile",
789
- "outDir",
790
- "removeComments",
791
- "noEmit",
792
- "importHelpers",
793
- "importsNotUsedAsValues",
794
- "downlevelIteration",
795
- "sourceRoot",
796
- "mapRoot",
797
- "inlineSources",
798
- "emitBOM",
799
- "newLine",
800
- "stripInternal",
801
- "noEmitHelpers",
802
- "noEmitOnError",
803
- "preserveConstEnums",
804
- "declarationDir",
805
- "preserveValueImports",
806
- "isolatedDeclarations",
807
- "isolatedModules",
808
- "verbatimModuleSyntax",
809
- "allowSyntheticDefaultImports",
810
- "esModuleInterop",
811
- "preserveSymlinks",
812
- "forceConsistentCasingInFileNames",
813
- "strict",
814
- "strictBindCallApply",
815
- "strictFunctionTypes",
816
- "strictNullChecks",
817
- "strictPropertyInitialization",
818
- "allowUnreachableCode",
819
- "allowUnusedLabels",
820
- "alwaysStrict",
821
- "exactOptionalPropertyTypes",
822
- "noFallthroughCasesInSwitch",
823
- "noImplicitAny",
824
- "noImplicitOverride",
825
- "noImplicitReturns",
826
- "noImplicitThis",
827
- "noPropertyAccessFromIndexSignature",
828
- "noUncheckedIndexedAccess",
829
- "noUnusedLocals",
830
- "noUnusedParameters",
831
- "useUnknownInCatchVariables",
832
- "skipDefaultLibCheck",
833
- "skipLibCheck",
834
- { order: { type: "asc" } }
835
- ]
836
- },
837
- {
838
- order: { type: "asc" },
839
- pathPattern: "^vueCompilerOptions$"
840
- }
841
- ] }
842
- });
843
- if (enableSortPackageJson) configs.push({
844
- name: "ntnyq/sort/package-json",
845
- files: [GLOB_PACKAGE_JSON],
846
- rules: {
847
- "jsonc/sort-array-values": ["error", {
848
- order: { type: "asc" },
849
- pathPattern: "^(?:files|keywords|activationEvents|contributes.*)$"
850
- }],
851
- "jsonc/sort-keys": [
852
- "error",
853
- {
854
- pathPattern: "^$",
855
- order: [
856
- "publisher",
857
- "name",
858
- "displayName",
859
- "preview",
860
- "type",
861
- "config",
862
- "version",
863
- "private",
864
- "packageManager",
865
- "workspaces",
866
- "description",
867
- "keywords",
868
- "license",
869
- "licenses",
870
- "author",
871
- "contributors",
872
- "maintainers",
873
- "homepage",
874
- "repository",
875
- "bugs",
876
- "funding",
877
- "exports",
878
- "imports",
879
- "main",
880
- "module",
881
- "unpkg",
882
- "jsdelivr",
883
- "types",
884
- "typesVersions",
885
- "bin",
886
- "icon",
887
- "files",
888
- "directories",
889
- "publishConfig",
890
- "sideEffects",
891
- "scripts",
892
- "peerDependencies",
893
- "peerDependenciesMeta",
894
- "bundledDependencies",
895
- "bundleDependencies",
896
- "dependencies",
897
- "optionalDependencies",
898
- "devDependencies",
899
- "activationEvents",
900
- "contributes",
901
- "categories",
902
- "galleryBanner",
903
- "badges",
904
- "markdown",
905
- "qna",
906
- "sponsor",
907
- "extensionPack",
908
- "extensionDependencies",
909
- "extensionKind",
910
- "pricing",
911
- "capabilities",
912
- "engines",
913
- "pnpm",
914
- "overrides",
915
- "resolutions",
916
- "husky",
917
- "prettier",
918
- "nano-staged",
919
- "lint-staged",
920
- "eslintConfig",
921
- { order: { type: "asc" } }
922
- ]
923
- },
924
- {
925
- order: { type: "asc" },
926
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
927
- },
928
- {
929
- order: { type: "asc" },
930
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
931
- },
932
- {
933
- pathPattern: "^exports.*$",
934
- order: [
935
- "./package.json",
936
- "types",
937
- "import",
938
- "require",
939
- "default",
940
- { order: { type: "asc" } }
941
- ]
942
- },
943
- {
944
- order: { type: "asc" },
945
- pathPattern: "^contributes.*$"
946
- },
947
- (
948
- /**
949
- * pnpm publish config
950
- * @see {@link https://pnpm.io/package_json#publishconfig}
951
- */
952
- {
953
- pathPattern: "^publishConfig.*$",
954
- order: [
955
- "./package.json",
956
- "types",
957
- "import",
958
- "require",
959
- "default",
960
- { order: { type: "asc" } }
961
- ]
962
- }),
963
- {
964
- order: { type: "asc" },
965
- pathPattern: "^scripts$"
966
- },
967
- {
968
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
969
- order: [
970
- "pre-commit",
971
- "prepare-commit-msg",
972
- "commit-msg",
973
- "post-commit",
974
- "pre-rebase",
975
- "post-rewrite",
976
- "post-checkout",
977
- "post-merge",
978
- "pre-push",
979
- "pre-auto-gc",
980
- { order: { type: "asc" } }
981
- ]
982
- }
983
- ]
984
- }
985
- });
986
- if (enableSortI18nLocale) configs.push({
987
- name: "ntnyq/sort/i18n-locale/json",
988
- files: ["**/{i18n,langs,locales}/*.json"],
989
- rules: { "jsonc/sort-keys": ["error", {
990
- order: { type: "asc" },
991
- pathPattern: ".*"
992
- }] }
993
- }, {
994
- name: "ntnyq/sort/i18n-locale/yaml",
995
- files: ["**/{i18n,langs,locales}/*.y?(a)ml"],
996
- rules: { "yml/sort-keys": ["error", {
997
- order: { type: "asc" },
998
- pathPattern: ".*"
999
- }] }
1000
- });
1001
- /**
1002
- * @see {@link https://json-schema.org/draft-07/schema}
1003
- */
1004
- if (enableSortJsonSchema) configs.push({
1005
- name: "ntnyq/sort/json-schema",
1006
- files: [...GLOB_JSON_SCHEMA],
1007
- ignores: [GLOB_PACKAGE_JSON],
1008
- rules: {
1009
- "jsonc/sort-array-values": ["error", {
1010
- order: { type: "asc" },
1011
- pathPattern: "^(?:required)$"
1012
- }],
1013
- "jsonc/sort-keys": [
1014
- "error",
1015
- {
1016
- pathPattern: "^$",
1017
- order: [
1018
- "$schema",
1019
- "$comment",
1020
- "$id",
1021
- "$ref",
1022
- "title",
1023
- "description",
1024
- "version",
1025
- "type",
1026
- "definitions",
1027
- "properties",
1028
- "required",
1029
- "additionalProperties",
1030
- { order: { type: "asc" } }
1031
- ]
1032
- },
1033
- {
1034
- order: { type: "asc" },
1035
- pathPattern: "^(?:definitions|properties)$"
1036
- }
1037
- ]
1038
- }
1039
- });
1040
- if (enableSortPnpmWorkspace) configs.push({
1041
- name: "ntnyq/sort/pnpm-workspace",
1042
- files: [GLOB_PNPM_WORKSPACE_YAML],
1043
- rules: {
1044
- "yml/sort-keys": [
1045
- "error",
1046
- {
1047
- pathPattern: "^$",
1048
- order: [
1049
- "packages",
1050
- "catalog",
1051
- "catalogs",
1052
- "allowedDeprecatedVersions",
1053
- "overrides",
1054
- "onlyBuiltDependencies",
1055
- "patchedDependencies",
1056
- "peerDependencyRules",
1057
- "allowNonAppliedPatches",
1058
- "auditConfig",
1059
- "configDependencies",
1060
- "executionEnv",
1061
- "ignoredBuiltDependencies",
1062
- "ignoredOptionalDependencies",
1063
- "neverBuiltDependencies",
1064
- "onlyBuiltDependenciesFile",
1065
- "packageExtensions",
1066
- "requiredScripts",
1067
- "supportedArchitectures",
1068
- "updateConfig",
1069
- { order: { type: "asc" } }
1070
- ]
1071
- },
1072
- {
1073
- order: { type: "asc" },
1074
- pathPattern: "^(?:catalog|overrides|patchedDependencies|peerDependencyRules)$"
1075
- },
1076
- {
1077
- allowLineSeparatedGroups: true,
1078
- order: { type: "asc" },
1079
- pathPattern: "^catalogs$"
1080
- }
1081
- ],
1082
- "yml/sort-sequence-values": ["error", {
1083
- order: [".", { order: { type: "asc" } }],
1084
- pathPattern: "^(?:packages|onlyBuiltDependencies|peerDependencyRules.ignoreMissing)$"
1085
- }]
1086
- }
1087
- });
1088
- if (additionalJsonFiles.length) configs.push({
1089
- name: "ntnyq/sort/additional-json",
1090
- files: additionalJsonFiles,
1091
- rules: { "jsonc/sort-keys": ["error", {
1092
- pathPattern: ".*",
1093
- order: ["$schema", { order: { type: "asc" } }]
1094
- }] }
1095
- });
1096
- if (additionalYamlFiles.length) configs.push({
1097
- name: "ntnyq/sort/additional-yaml",
1098
- files: additionalYamlFiles,
1099
- rules: { "yml/sort-keys": ["error", {
1100
- order: { type: "asc" },
1101
- pathPattern: ".*"
1102
- }] }
1103
- });
1104
- return configs;
1105
- };
1106
-
1107
- //#endregion
1108
- //#region src/configs/svgo.ts
1109
- /**
1110
- * Config for svg files
1111
- *
1112
- * @see {@link https://github.com/ntnyq/eslint-plugin-svgo}
1113
- *
1114
- * @param options - {@link ConfigSVGOOptions}
1115
- * @returns ESLint configs
1116
- */
1117
- const configSVGO = (options = {}) => {
1118
- const { files = [GLOB_SVG], ignores = [] } = options;
1119
- return [{
1120
- name: "ntnyq/svgo",
1121
- files,
1122
- ignores,
1123
- plugins: { svgo: pluginSvgo },
1124
- languageOptions: { parser: parserPlain },
1125
- rules: {
1126
- "svgo/svgo": ["error", {
1127
- plugins: ["preset-default"],
1128
- js2svg: {
1129
- indent: 2,
1130
- pretty: true
1131
- }
1132
- }],
1133
- ...options.overrides
1134
- }
1135
- }];
1136
- };
1137
-
1138
- //#endregion
1139
- //#region src/configs/test.ts
1140
- /**
1141
- * Config for test files
1142
- *
1143
- * @see {@link https://github.com/vitest-dev/eslint-plugin-vitest}
1144
- *
1145
- * @param options - {@link ConfigTestOptions}
1146
- * @returns ESLint configs
1147
- */
1148
- const configTest = (options = {}) => {
1149
- const { files = [...GLOB_TEST], vitest: enableVitest = hasVitest() } = options;
1150
- const configs = [{
1151
- name: "ntnyq/test/setup",
1152
- plugins: { "no-only-tests": pluginNoOnlyTests }
1153
- }, {
1154
- name: "ntnyq/test/base",
1155
- files,
1156
- rules: {
1157
- "max-lines-per-function": "off",
1158
- "no-unused-expressions": "off",
1159
- "no-only-tests/no-only-tests": "error",
1160
- ...options.overrides
1161
- }
1162
- }];
1163
- if (enableVitest) configs.push({
1164
- name: "ntnyq/test/vitest",
1165
- files,
1166
- plugins: { vitest: pluginVitest },
1167
- settings: {},
1168
- rules: {
1169
- ...pluginVitest.configs.recommended.rules,
1170
- "vitest/expect-expect": ["error", { assertFunctionNames: [
1171
- "expect",
1172
- "assert",
1173
- "expectTypeOf",
1174
- "assertType"
1175
- ] }],
1176
- ...options.overridesVitestRules
1177
- }
1178
- });
1179
- return configs;
1180
- };
1181
-
1182
- //#endregion
1183
- //#region src/configs/toml.ts
1184
- /**
1185
- * Config for toml files
1186
- *
1187
- * @see {@link https://ota-meshi.github.io/eslint-plugin-toml}
1188
- *
1189
- * @param options - {@link ConfigTomlOptions}
1190
- * @returns ESLint configs
1191
- */
1192
- const configToml = (options = {}) => {
1193
- const { files = [GLOB_TOML] } = options;
1194
- return [{
1195
- name: "ntnyq/toml",
1196
- files,
1197
- plugins: { toml: pluginToml },
1198
- languageOptions: { parser: parserToml },
1199
- rules: {
1200
- "toml/array-bracket-newline": "error",
1201
- "toml/array-bracket-spacing": ["error", "never"],
1202
- "toml/array-element-newline": ["error", "never"],
1203
- "toml/comma-style": "error",
1204
- "toml/indent": ["error", 2],
1205
- "toml/inline-table-curly-spacing": "error",
1206
- "toml/key-spacing": "error",
1207
- "toml/keys-order": "error",
1208
- "toml/no-space-dots": "error",
1209
- "toml/no-unreadable-number-separator": "error",
1210
- "toml/padding-line-between-pairs": "error",
1211
- "toml/padding-line-between-tables": "error",
1212
- "toml/precision-of-fractional-seconds": "error",
1213
- "toml/precision-of-integer": "error",
1214
- "toml/quoted-keys": "error",
1215
- "toml/spaced-comment": "error",
1216
- "toml/table-bracket-spacing": "error",
1217
- "toml/tables-order": "error",
1218
- "toml/vue-custom-block/no-parsing-error": "error",
1219
- ...options.overrides
1220
- }
1221
- }];
1222
- };
1223
-
1224
- //#endregion
1225
- //#region src/configs/antfu.ts
1226
- /**
1227
- * Config for common files
1228
- *
1229
- * @see {@link https://github.com/antfu/eslint-plugin-antfu}
1230
- *
1231
- * @param options - {@link ConfigAntfuOptions}
1232
- * @returns ESLint configs
1233
- */
1234
- const configAntfu = (options = {}) => [{
1235
- name: "ntnyq/antfu",
1236
- plugins: { antfu: pluginAntfu },
1237
- rules: {
1238
- "antfu/import-dedupe": "error",
1239
- "antfu/indent-unindent": "error",
1240
- "antfu/no-import-dist": "error",
1241
- "antfu/no-import-node-modules-by-path": "error",
1242
- ...options.overrides
1243
- }
1244
- }];
1245
-
1246
- //#endregion
1247
- //#region src/configs/astro.ts
1248
- /**
1249
- * Config for astro files
1250
- *
1251
- * @see {@link https://github.com/ota-meshi/eslint-plugin-astro}
1252
- *
1253
- * @param options - {@link ConfigAstroOptions}
1254
- * @returns ESLint configs
1255
- */
1256
- const configAstro = async (options = {}) => {
1257
- await ensurePackages(["astro-eslint-parser", "eslint-plugin-astro"]);
1258
- const [parserAstro, pluginAstro] = await Promise.all([interopDefault(import("astro-eslint-parser")), interopDefault(import("eslint-plugin-astro"))]);
1259
- const { files = [GLOB_ASTRO], extraFileExtensions = [] } = options;
1260
- return [{
1261
- name: "ntnyq/astro",
1262
- files,
1263
- plugins: { astro: pluginAstro },
1264
- processor: pluginAstro.processors["client-side-ts"],
1265
- languageOptions: {
1266
- parser: parserAstro,
1267
- sourceType: "module",
1268
- globals: { ...pluginAstro.environments.astro.globals },
1269
- parserOptions: {
1270
- extraFileExtensions,
1271
- parser: parserTypeScript
1272
- }
1273
- },
1274
- rules: {
1275
- "astro/missing-client-only-directive-value": "error",
1276
- "astro/no-conflict-set-directives": "error",
1277
- "astro/no-deprecated-astro-canonicalurl": "error",
1278
- "astro/no-deprecated-astro-fetchcontent": "error",
1279
- "astro/no-deprecated-astro-resolve": "error",
1280
- "astro/no-deprecated-getentrybyslug": "error",
1281
- "astro/no-unused-define-vars-in-style": "error",
1282
- "astro/valid-compile": "error",
1283
- ...options.overrides
1284
- }
1285
- }];
1286
- };
1287
-
1288
- //#endregion
1289
- //#region src/configs/jsdoc.ts
1290
- /**
1291
- * JavaScript specific rules
1292
- */
1293
- const javscriptRules = {
1294
- "jsdoc/no-types": "off",
1295
- "jsdoc/no-undefined-types": "error",
1296
- "jsdoc/require-param-type": "error",
1297
- "jsdoc/require-property-type": "error",
1298
- "jsdoc/require-returns-type": "error"
1299
- };
1300
- /**
1301
- * TypeScript specific rules
1302
- */
1303
- const typescriptRules = {
1304
- "jsdoc/no-undefined-types": "off",
1305
- "jsdoc/require-param-type": "off",
1306
- "jsdoc/require-property-type": "off",
1307
- "jsdoc/require-returns-type": "off",
1308
- "jsdoc/no-types": "error"
1309
- };
1310
- /**
1311
- * Config for jsdoc
1312
- *
1313
- * @see {@link https://github.com/gajus/eslint-plugin-jsdoc}
1314
- *
1315
- * @param options - {@link ConfigJsdocOptions}
1316
- * @returns ESLint configs
1317
- */
1318
- const configJsdoc = (options = {}) => [{
1319
- name: "ntnyq/jsdoc",
1320
- plugins: { jsdoc: pluginJsdoc },
1321
- rules: {
1322
- "jsdoc/tag-lines": "off",
1323
- "jsdoc/text-escaping": "off",
1324
- "jsdoc/check-access": "warn",
1325
- "jsdoc/implements-on-classes": "warn",
1326
- "jsdoc/require-param-name": "warn",
1327
- "jsdoc/require-property": "warn",
1328
- "jsdoc/require-property-description": "warn",
1329
- "jsdoc/require-property-name": "warn",
1330
- "jsdoc/require-returns-check": "warn",
1331
- "jsdoc/require-returns-description": "warn",
1332
- "jsdoc/require-yields-check": "warn",
1333
- "jsdoc/check-alignment": "error",
1334
- "jsdoc/check-line-alignment": "error",
1335
- "jsdoc/check-param-names": "error",
1336
- "jsdoc/check-property-names": "error",
1337
- "jsdoc/check-tag-names": ["error", { definedTags: [
1338
- "vite-ignore",
1339
- "unocss-include",
1340
- "pg",
1341
- "perfectionist-group",
1342
- "regex101",
1343
- "compatibility",
1344
- "category",
1345
- "experimental",
1346
- "internal"
1347
- ] }],
1348
- "jsdoc/check-types": "error",
1349
- "jsdoc/empty-tags": "error",
1350
- "jsdoc/multiline-blocks": "error",
1351
- "jsdoc/no-bad-blocks": ["error", { ignore: [
1352
- "ts-check",
1353
- "ts-expect-error",
1354
- "ts-ignore",
1355
- "ts-nocheck",
1356
- "vite-ignore"
1357
- ] }],
1358
- "jsdoc/no-blank-block-descriptions": "error",
1359
- "jsdoc/no-blank-blocks": "error",
1360
- "jsdoc/no-defaults": "error",
1361
- "jsdoc/no-multi-asterisks": "error",
1362
- "jsdoc/require-asterisk-prefix": "error",
1363
- "jsdoc/require-hyphen-before-param-description": "error",
1364
- ...options.typescript ? typescriptRules : javscriptRules,
1365
- ...options.overrides
1366
- }
1367
- }];
1368
-
1369
- //#endregion
1370
- //#region src/configs/jsonc.ts
1371
- /**
1372
- * @see {@link https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/lib/configs/base.ts}
1373
- */
1374
- const disabledCoreRules = {
1375
- "no-unused-expressions": "off",
1376
- "no-unused-vars": "off",
1377
- strict: "off"
1378
- };
1379
- /**
1380
- * Config for json, jsonc and json5 files
1381
- *
1382
- * @see {@link https://ota-meshi.github.io/eslint-plugin-jsonc}
1383
- *
1384
- * @param options - {@link ConfigJsoncOptions}
1385
- * @returns ESLint configs
1386
- */
1387
- const configJsonc = (options = {}) => {
1388
- const { files = [
1389
- GLOB_JSON,
1390
- GLOB_JSON5,
1391
- GLOB_JSONC
1392
- ] } = options;
1393
- return [{
1394
- name: "ntnyq/jsonc",
1395
- files,
1396
- plugins: { jsonc: pluginJsonc },
1397
- languageOptions: { parser: parserJsonc },
1398
- rules: {
1399
- "jsonc/array-bracket-spacing": ["error", "never"],
1400
- "jsonc/comma-dangle": ["error", "never"],
1401
- "jsonc/comma-style": ["error", "last"],
1402
- "jsonc/indent": ["error", 2],
1403
- "jsonc/key-spacing": ["error", {
1404
- afterColon: true,
1405
- beforeColon: false
1406
- }],
1407
- "jsonc/no-bigint-literals": "error",
1408
- "jsonc/no-binary-expression": "error",
1409
- "jsonc/no-binary-numeric-literals": "error",
1410
- "jsonc/no-dupe-keys": "error",
1411
- "jsonc/no-escape-sequence-in-identifier": "error",
1412
- "jsonc/no-floating-decimal": "error",
1413
- "jsonc/no-hexadecimal-numeric-literals": "error",
1414
- "jsonc/no-infinity": "error",
1415
- "jsonc/no-multi-str": "error",
1416
- "jsonc/no-nan": "error",
1417
- "jsonc/no-number-props": "error",
1418
- "jsonc/no-numeric-separators": "error",
1419
- "jsonc/no-octal": "error",
1420
- "jsonc/no-octal-escape": "error",
1421
- "jsonc/no-octal-numeric-literals": "error",
1422
- "jsonc/no-parenthesized": "error",
1423
- "jsonc/no-plus-sign": "error",
1424
- "jsonc/no-regexp-literals": "error",
1425
- "jsonc/no-sparse-arrays": "error",
1426
- "jsonc/no-template-literals": "error",
1427
- "jsonc/no-undefined-value": "error",
1428
- "jsonc/no-unicode-codepoint-escapes": "error",
1429
- "jsonc/no-useless-escape": "error",
1430
- "jsonc/object-curly-newline": ["error", {
1431
- consistent: true,
1432
- multiline: true
1433
- }],
1434
- "jsonc/object-curly-spacing": ["error", "always"],
1435
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1436
- "jsonc/quote-props": "error",
1437
- "jsonc/quotes": "error",
1438
- "jsonc/space-unary-ops": "error",
1439
- "jsonc/valid-json-number": "error",
1440
- "jsonc/vue-custom-block/no-parsing-error": "error",
1441
- ...disabledCoreRules,
1442
- ...options.prettier ? {
1443
- "jsonc/array-bracket-newline": "off",
1444
- "jsonc/array-bracket-spacing": "off",
1445
- "jsonc/array-element-newline": "off",
1446
- "jsonc/comma-dangle": "off",
1447
- "jsonc/comma-style": "off",
1448
- "jsonc/indent": "off",
1449
- "jsonc/key-spacing": "off",
1450
- "jsonc/no-floating-decimal": "off",
1451
- "jsonc/object-curly-newline": "off",
1452
- "jsonc/object-curly-spacing": "off",
1453
- "jsonc/object-property-newline": "off",
1454
- "jsonc/quote-props": "off",
1455
- "jsonc/quotes": "off",
1456
- "jsonc/space-unary-ops": "off"
1457
- } : {},
1458
- ...options.overrides
1459
- }
1460
- }];
1461
- };
1462
-
1463
- //#endregion
1464
- //#region src/configs/ntnyq.ts
1465
- /**
1466
- * Config for common files
1467
- *
1468
- * @see {@link https://github.com/ntnyq/eslint-plugin-ntnyq}
1469
- *
1470
- * @param options - {@link ConfigNtnyqOptions}
1471
- * @returns ESLint configs
1472
- */
1473
- const configNtnyq = (options = {}) => [{
1474
- name: "ntnyq/ntnyq",
1475
- plugins: { ntnyq: pluginNtnyq },
1476
- rules: {
1477
- "ntnyq/no-duplicate-exports": "error",
1478
- "ntnyq/prefer-newline-after-file-header": "error",
1479
- ...options.overrides
1480
- }
1481
- }];
1482
-
1483
- //#endregion
1484
- //#region src/configs/pinia.ts
1485
- /**
1486
- * Config for pinia store
1487
- *
1488
- * @see {@link https://github.com/lisilinhart/eslint-plugin-pinia}
1489
- *
1490
- * @param options - {@link ConfigPiniaOptions}
1491
- * @returns ESLint configs
1492
- */
1493
- const configPinia = (options = {}) => {
1494
- const { files = [GLOB_PINIA_STORE] } = options;
1495
- return [{
1496
- name: "ntnyq/pinia",
1497
- files,
1498
- plugins: { pinia: pluginPinia },
1499
- rules: {
1500
- "pinia/never-export-initialized-store": "error",
1501
- "pinia/no-duplicate-store-ids": "error",
1502
- "pinia/no-return-global-properties": "error",
1503
- "pinia/no-store-to-refs-in-store": "error",
1504
- "pinia/prefer-single-store-per-file": "error",
1505
- "pinia/prefer-use-store-naming-convention": ["error", {
1506
- checkStoreNameMismatch: true,
1507
- storeSuffix: "Store"
1508
- }],
1509
- "pinia/require-setup-store-properties-export": "error",
1510
- ...options.overrides
1511
- }
1512
- }];
1513
- };
1514
-
1515
- //#endregion
1516
- //#region src/configs/depend.ts
1517
- /**
1518
- * Config for optimisations dependency
1519
- *
1520
- * @see {@link https://github.com/es-tooling/eslint-plugin-depend}
1521
- * @see {@link https://github.com/es-tooling/module-replacements}
1522
- *
1523
- * @param options - {@link ConfigDependOptions}
1524
- * @returns ESLint configs
1525
- */
1526
- const configDepend = (options = {}) => {
1527
- const { files = [GLOB_SRC], allowed = [], packageJson: enableCheckPackageJson = true } = options;
1528
- const configs = [{
1529
- name: "ntnyq/depend",
1530
- files,
1531
- plugins: { depend: pluginDepend },
1532
- rules: {
1533
- "depend/ban-dependencies": ["error", { allowed }],
1534
- ...options.overrides
1535
- }
1536
- }];
1537
- if (enableCheckPackageJson) configs.push({
1538
- name: "ntnyq/depend/package-json",
1539
- files: [GLOB_PACKAGE_JSON],
1540
- plugins: { depend: pluginDepend },
1541
- languageOptions: { parser: parserJsonc },
1542
- rules: {
1543
- "depend/ban-dependencies": ["error", { allowed }],
1544
- ...options.overrides
1545
- }
1546
- });
1547
- return configs;
1548
- };
1549
-
1550
- //#endregion
1551
- //#region src/constants/prettier.ts
1552
- /**
1553
- * Options from `@ntnyq/prettier-config`
1554
- *
1555
- * @see {@link https://github.com/ntnyq/configs/blob/main/packages/prettier-config/index.js}
1556
- */
1557
- const PRETTIER_DEFAULT_OPTIONS = {
1558
- arrowParens: "avoid",
1559
- bracketSameLine: false,
1560
- bracketSpacing: true,
1561
- embeddedLanguageFormatting: "auto",
1562
- endOfLine: "lf",
1563
- experimentalOperatorPosition: "start",
1564
- experimentalTernaries: false,
1565
- htmlWhitespaceSensitivity: "css",
1566
- insertPragma: false,
1567
- jsxSingleQuote: true,
1568
- objectWrap: "preserve",
1569
- printWidth: 80,
1570
- proseWrap: "preserve",
1571
- quoteProps: "as-needed",
1572
- rangeEnd: Number.POSITIVE_INFINITY,
1573
- rangeStart: 0,
1574
- requirePragma: false,
1575
- semi: false,
1576
- singleAttributePerLine: true,
1577
- singleQuote: true,
1578
- tabWidth: 2,
1579
- trailingComma: "all",
1580
- useTabs: false,
1581
- vueIndentScriptAndStyle: false
1582
- };
1583
-
1584
- //#endregion
1585
- //#region src/constants/perfectionist.ts
1586
- /**
1587
- * Shared perfectionist plugin settings
1588
- */
1589
- const pluginSettings = {
1590
- fallbackSort: {
1591
- order: "asc",
1592
- type: "alphabetical"
1593
- },
1594
- ignoreCase: true,
1595
- order: "asc",
1596
- partitionByNewLine: false,
1597
- specialCharacters: "keep",
1598
- type: "alphabetical"
1599
- };
1600
- /**
1601
- * Shared perfectionist rule options for some rules
1602
- */
1603
- const partialRuleOptions = {
1604
- newlinesBetween: "ignore",
1605
- partitionByComment: ["@pg", "@perfectionist-group"]
1606
- };
1607
- /**
1608
- * Shared option `groups` for rule `sort-objects`
1609
- *
1610
- * @see {@link https://perfectionist.dev/rules/sort-objects}
1611
- */
1612
- const sortObjectsGroups = [
1613
- "property",
1614
- "multiline-property",
1615
- "method",
1616
- "multiline-method",
1617
- "unknown"
1618
- ];
1619
- /**
1620
- * Shared option `groups` for rules
1621
- * - `sort-interfaces`
1622
- * - `sort-object-types`
1623
- *
1624
- * @see {@link https://perfectionist.dev/rules/sort-interfaces}
1625
- * @see {@link https://perfectionist.dev/rules/sort-object-types}
1626
- */
1627
- const sortInterfacesOrObjectTypesGroups = [
1628
- "required-property",
1629
- "optional-property",
1630
- "required-method",
1631
- "optional-method",
1632
- "required-multiline-property",
1633
- "optional-multiline-property",
1634
- "required-multiline-method",
1635
- "optional-multiline-method",
1636
- "unknown",
1637
- "index-signature",
1638
- "multiline-index-signature"
1639
- ];
1640
- /**
1641
- * Shared option `groups` for rules:
1642
- * - `sort-intersection-types`
1643
- * - `sort-union-types`
1644
- *
1645
- * Philosophy: keep simple thing first except null & undefined
1646
- *
1647
- * @see {@link https://perfectionist.dev/rules/sort-intersection-types}
1648
- * @see {@link https://perfectionist.dev/rules/sort-union-types}
1649
- */
1650
- const sortIntersectionTypesOrUnionTypesGroups = [
1651
- "literal",
1652
- "keyword",
1653
- "named",
1654
- "intersection",
1655
- "conditional",
1656
- "function",
1657
- "import",
1658
- "object",
1659
- "operator",
1660
- "tuple",
1661
- "union",
1662
- "nullish"
1663
- ];
1664
- /**
1665
- * Shared option `groups` for rule `sort-imports`
1666
- *
1667
- * @see {@link https://perfectionist.dev/rules/sort-imports}
1668
- */
1669
- const sortImportsTypes = [
1670
- "side-effect-style",
1671
- "value-style",
1672
- "value-builtin",
1673
- "value-external",
1674
- "value-subpath",
1675
- "value-internal",
1676
- "value-parent",
1677
- "value-sibling",
1678
- "value-index",
1679
- "ts-equals-import",
1680
- "side-effect",
1681
- "type-builtin",
1682
- "type-external",
1683
- "type-subpath",
1684
- "type-internal",
1685
- "type-parent",
1686
- "type-sibling",
1687
- "type-index",
1688
- "unknown"
1689
- ];
1690
- /**
1691
- * Shared option `groups` for rule `sort-exports`
1692
- *
1693
- * @see {@link https://perfectionist.dev/rules/sort-exports}
1694
- */
1695
- const sortExportsGroups = [
1696
- "value-export",
1697
- "type-export",
1698
- "unknown"
1699
- ];
1700
- /**
1701
- * Shared option `groups` for rule `sort-named-exports`
1702
- *
1703
- * @see {@link https://perfectionist.dev/rules/sort-named-exports}
1704
- */
1705
- const sortNamedExportsGroups = [
1706
- "value-export",
1707
- "type-export",
1708
- "unknown"
1709
- ];
1710
- /**
1711
- * Shared option `groups` for rule `sort-named-imports`
1712
- *
1713
- * @see {@link https://perfectionist.dev/rules/sort-named-imports}
1714
- */
1715
- const sortNamedImportsGroups = [
1716
- "value-import",
1717
- "type-import",
1718
- "unknown"
1719
- ];
1720
- /**
1721
- * Shared option `groups` for rule `sort-classes`
1722
- *
1723
- * // TODO: implement this
1724
- *
1725
- * @see {@link https://perfectionist.dev/rules/sort-classes}
1726
- */
1727
- const sortClassesGroups = ["unknown"];
1728
- /**
1729
- * Shared constants about eslint-plugin-perfectionist
1730
- */
1731
- const PERFECTIONIST = Object.freeze({
1732
- partialRuleOptions,
1733
- pluginSettings,
1734
- sortClassesGroups,
1735
- sortExportsGroups,
1736
- sortImportsTypes,
1737
- sortInterfacesOrObjectTypesGroups,
1738
- sortIntersectionTypesOrUnionTypesGroups,
1739
- sortNamedExportsGroups,
1740
- sortNamedImportsGroups,
1741
- sortObjectsGroups
1742
- });
1743
-
1744
- //#endregion
1745
- //#region src/configs/format.ts
1746
- /**
1747
- * Config to use a formatter
1748
- *
1749
- * @see {@link https://github.com/antfu/eslint-plugin-format}
1750
- *
1751
- * @param options - {@link ConfigFormatOptions}
1752
- * @returns ESLint configs
1753
- */
1754
- const configFormat = async (options = {}) => {
1755
- await ensurePackages(["eslint-plugin-format"]);
1756
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1757
- const { css: enableCSS = true, html: enableHTML = true, prettierOptions = {} } = options;
1758
- const sharedPrettierOptions = {
1759
- ...PRETTIER_DEFAULT_OPTIONS,
1760
- ...prettierOptions
1761
- };
1762
- const configs = [{
1763
- name: "ntnyq/format/setup",
1764
- plugins: { format: pluginFormat }
1765
- }];
1766
- if (enableCSS) configs.push({
1767
- name: "ntnyq/format/css",
1768
- files: [GLOB_CSS, GLOB_POSTCSS],
1769
- languageOptions: { parser: parserPlain },
1770
- rules: { "format/prettier": ["error", mergePrettierOptions(sharedPrettierOptions, { parser: "css" })] }
1771
- }, {
1772
- name: "ntnyq/format/scss",
1773
- files: [GLOB_SCSS],
1774
- languageOptions: { parser: parserPlain },
1775
- rules: { "format/prettier": ["error", mergePrettierOptions(sharedPrettierOptions, { parser: "scss" })] }
1776
- }, {
1777
- name: "ntnyq/format/less",
1778
- files: [GLOB_LESS],
1779
- languageOptions: { parser: parserPlain },
1780
- rules: { "format/prettier": ["error", mergePrettierOptions(sharedPrettierOptions, { parser: "less" })] }
1781
- });
1782
- if (enableHTML) configs.push({
1783
- name: "ntnyq/format/html",
1784
- files: [GLOB_HTML],
1785
- languageOptions: { parser: parserPlain },
1786
- rules: { "format/prettier": ["error", mergePrettierOptions(sharedPrettierOptions, { parser: "html" })] }
1787
- });
1788
- return configs;
1789
- };
1790
-
1791
- //#endregion
1792
- //#region src/configs/regexp.ts
1793
- /**
1794
- * Config for regexp
1795
- *
1796
- * @see {@link https://github.com/ota-meshi/eslint-plugin-regexp}
1797
- *
1798
- * @param options - {@link ConfigRegexpOptions}
1799
- * @returns ESLint configs
1800
- */
1801
- const configRegexp = (options = {}) => {
1802
- const recommendedConfig = pluginRegexp.configs["flat/recommended"];
1803
- const recommendedRules$1 = { ...recommendedConfig.rules };
1804
- if (options.severity === "warn") {
1805
- for (const key in recommendedRules$1) if (recommendedRules$1[key] === "error") recommendedRules$1[key] = "warn";
1806
- }
1807
- return [{
1808
- ...recommendedConfig,
1809
- name: "ntnyq/regexp",
1810
- rules: {
1811
- ...recommendedRules$1,
1812
- ...options.overrides
1813
- }
1814
- }];
1815
- };
1816
-
1817
- //#endregion
1818
- //#region src/configs/svelte.ts
1819
- /**
1820
- * Config for svelte files
1821
- *
1822
- * @see {@link https://github.com/ota-meshi/eslint-plugin-svelte}
1823
- *
1824
- * @param options - {@link ConfigSvelteOptions}
1825
- * @returns ESLint configs
1826
- */
1827
- const configSvelte = async (options = {}) => {
1828
- await ensurePackages(["svelte-eslint-parser", "eslint-plugin-svelte"]);
1829
- const [parserSvelte, pluginSvelte] = await Promise.all([interopDefault(import("svelte-eslint-parser")), interopDefault(import("eslint-plugin-svelte"))]);
1830
- const { files = [GLOB_SVELTE], extraFileExtensions = [] } = options;
1831
- return [{
1832
- name: "ntnyq/svelte",
1833
- files,
1834
- plugins: { svelte: pluginSvelte },
1835
- processor: pluginSvelte.processors[".svelte"],
1836
- languageOptions: {
1837
- parser: parserSvelte,
1838
- sourceType: "module",
1839
- parserOptions: {
1840
- extraFileExtensions,
1841
- parser: parserTypeScript
1842
- }
1843
- },
1844
- rules: {
1845
- "import-x/no-mutable-exports": "off",
1846
- "no-undef": "off",
1847
- "no-unused-vars": ["error", {
1848
- args: "none",
1849
- caughtErrors: "none",
1850
- ignoreRestSiblings: true,
1851
- vars: "all",
1852
- varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1853
- }],
1854
- "svelte/comment-directive": "error",
1855
- "svelte/derived-has-same-inputs-outputs": "error",
1856
- "svelte/html-closing-bracket-spacing": "error",
1857
- "svelte/html-quotes": ["error", {
1858
- prefer: "double",
1859
- dynamic: {
1860
- avoidInvalidUnquotedInHTML: false,
1861
- quoted: true
1862
- }
1863
- }],
1864
- "svelte/indent": ["error", {
1865
- alignAttributesVertically: true,
1866
- indent: 2,
1867
- indentScript: false
1868
- }],
1869
- "svelte/mustache-spacing": ["error", {
1870
- attributesAndProps: "never",
1871
- directiveExpressions: "always",
1872
- textExpressions: "always",
1873
- tags: {
1874
- closingBrace: "always",
1875
- openingBrace: "always"
1876
- }
1877
- }],
1878
- "svelte/no-at-debug-tags": "error",
1879
- "svelte/no-at-html-tags": "error",
1880
- "svelte/no-dupe-else-if-blocks": "error",
1881
- "svelte/no-dupe-style-properties": "error",
1882
- "svelte/no-dupe-use-directives": "error",
1883
- "svelte/no-dynamic-slot-name": "error",
1884
- "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1885
- "svelte/no-inner-declarations": "error",
1886
- "svelte/no-not-function-handler": "error",
1887
- "svelte/no-object-in-text-mustaches": "error",
1888
- "svelte/no-reactive-functions": "error",
1889
- "svelte/no-reactive-literals": "error",
1890
- "svelte/no-shorthand-style-property-overrides": "error",
1891
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1892
- "svelte/no-trailing-spaces": "error",
1893
- "svelte/no-unknown-style-directive-property": "error",
1894
- "svelte/no-unused-svelte-ignore": "error",
1895
- "svelte/no-useless-mustaches": "error",
1896
- "svelte/require-store-callbacks-use-set-param": "error",
1897
- "svelte/spaced-html-comment": "error",
1898
- "svelte/system": "error",
1899
- "svelte/valid-each-key": "error",
1900
- ...options.overrides
1901
- }
1902
- }];
1903
- };
1904
-
1905
- //#endregion
1906
- //#region src/configs/unocss.ts
1907
- /**
1908
- * Config for UnoCSS
1909
- *
1910
- * @see {@link https://github.com/unocss/unocss/tree/main/packages-integrations/eslint-plugin}
1911
- *
1912
- * @param options - {@link ConfigUnoCSSOptions}
1913
- * @returns ESLint configs
1914
- */
1915
- const configUnoCSS = (options = {}) => [{
1916
- name: "ntnyq/unocss",
1917
- plugins: { unocss: pluginUnoCSS },
1918
- rules: {
1919
- "unocss/order-attributify": options.attributify ? "error" : "off",
1920
- "unocss/order": "error",
1921
- ...options.overrides
1922
- }
1923
- }];
1924
-
1925
- //#endregion
1926
- //#region src/commands/regexper.ts
1927
- const regexper = defineCommand({
1928
- name: "regexper",
1929
- match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
1930
- action(ctx) {
1931
- const literal = ctx.findNodeBelow((node) => node.type === "Literal" && "regex" in node);
1932
- if (!literal) return ctx.reportError("Unable to find a regexp literal to generate");
1933
- const [_fullStr = "", spaceBefore = "", commandStr = "", existingUrl = "", _spaceAfter = ""] = ctx.matches;
1934
- const url = `https://regexper.com/#${encodeURIComponent(literal.raw)}`;
1935
- if (existingUrl.trim() === url.trim()) return;
1936
- const indexStart = ctx.comment.range[0] + ctx.matches.index + spaceBefore.length + 2;
1937
- const indexEnd = indexStart + commandStr.length + existingUrl.length;
1938
- ctx.report({
1939
- loc: {
1940
- start: ctx.source.getLocFromIndex(indexStart),
1941
- end: ctx.source.getLocFromIndex(indexEnd)
1942
- },
1943
- removeComment: false,
1944
- message: "Update the regexper link",
1945
- fix(fixer) {
1946
- return fixer.replaceTextRange([indexStart, indexEnd], `@regexper ${url}`);
1947
- }
1948
- });
1949
- }
1950
- });
1951
-
1952
- //#endregion
1953
- //#region src/commands/index.ts
1954
- const commands = [regexper];
1955
-
1956
- //#endregion
1957
- //#region src/configs/command.ts
1958
- /**
1959
- * Config for useing comments as codemod
1960
- *
1961
- * @see {@link https://github.com/antfu/eslint-plugin-command}
1962
- *
1963
- * @param options - {@link ConfigCommandOptions}
1964
- * @returns ESLint configs
1965
- */
1966
- const configCommand = (options = {}) => [{
1967
- ...createCommandConfig({
1968
- ...options,
1969
- commands: [
1970
- ...builtinCommands,
1971
- ...commands,
1972
- ...options.commands || []
1973
- ]
1974
- }),
1975
- name: "ntnyq/command"
1976
- }];
1977
-
1978
- //#endregion
1979
- //#region src/configs/ignores.ts
1980
- /**
1981
- * Config for ignore files from linting
1982
- *
1983
- * @see https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores
1984
- *
1985
- * @param customIgnores - {@link ConfigIgnoresOptions}
1986
- * @returns ESLint configs
1987
- */
1988
- const configIgnores = (customIgnores = []) => [{
1989
- name: "ntnyq/ignores",
1990
- ignores: [...GLOB_EXCLUDE, ...customIgnores]
1991
- }];
1992
-
1993
- //#endregion
1994
- //#region src/configs/importX.ts
1995
- /**
1996
- * Config for imports and exports
1997
- *
1998
- * @see {@link https://github.com/un-ts/eslint-plugin-import-x}
1999
- *
2000
- * @param options - {@link ConfigImportXOptions}
2001
- * @returns ESLint configs
2002
- */
2003
- const configImportX = (options = {}) => {
2004
- const { preferTypeScriptResolver = true, typescript: enableTypeScript } = options;
2005
- return [{
2006
- name: "ntnyq/import-x",
2007
- plugins: { "import-x": pluginImportX },
2008
- settings: { "import-x/resolver-next": [enableTypeScript && preferTypeScriptResolver ? createTypeScriptImportResolver({ extensions: [
2009
- ".ts",
2010
- ".tsx",
2011
- ".d.ts",
2012
- ".js",
2013
- ".jsx",
2014
- ".json",
2015
- ".node"
2016
- ] }) : pluginImportX.createNodeResolver({ extensions: [
2017
- ".js",
2018
- ".mjs",
2019
- ".ts",
2020
- ".mts",
2021
- ".d.ts",
2022
- ".json"
2023
- ] })] },
2024
- rules: {
2025
- "import-x/no-absolute-path": "off",
2026
- "import-x/no-named-as-default-member": "off",
2027
- "import-x/no-named-default": "off",
2028
- "import-x/no-unresolved": "off",
2029
- "import-x/order": "off",
2030
- "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
2031
- "import-x/export": "error",
2032
- "import-x/first": "error",
2033
- "import-x/newline-after-import": "error",
2034
- "import-x/no-duplicates": "error",
2035
- "import-x/no-mutable-exports": "error",
2036
- "import-x/no-self-import": "error",
2037
- ...options.overrides
2038
- }
2039
- }];
2040
- };
2041
-
2042
- //#endregion
2043
- //#region src/configs/unicorn.ts
2044
- const disabledRules = {
2045
- "unicorn/better-regex": "off",
2046
- "unicorn/explicit-length-check": "off",
2047
- "unicorn/no-array-callback-reference": "off",
2048
- "unicorn/no-array-reverse": "off",
2049
- "unicorn/prefer-global-this": "off",
2050
- "unicorn/prefer-top-level-await": "off",
2051
- "unicorn/require-module-specifiers": "off"
2052
- };
2053
- /**
2054
- * Config for powerful rules
2055
- *
2056
- * @see {@link https://github.com/sindresorhus/eslint-plugin-unicorn}
2057
- *
2058
- * @param options - {@link ConfigUnicornOptions}
2059
- * @returns ESLint configs
2060
- */
2061
- const configUnicorn = (options = {}) => [{
2062
- name: "ntnyq/unicorn",
2063
- plugins: { unicorn: pluginUnicorn },
2064
- rules: {
2065
- "unicorn/consistent-assert": "error",
2066
- "unicorn/consistent-existence-index-check": "error",
2067
- "unicorn/error-message": "error",
2068
- "unicorn/escape-case": "error",
2069
- "unicorn/new-for-builtins": "error",
2070
- "unicorn/no-accessor-recursion": "error",
2071
- "unicorn/no-console-spaces": "error",
2072
- "unicorn/no-for-loop": "error",
2073
- "unicorn/no-hex-escape": "error",
2074
- "unicorn/no-instanceof-builtins": "error",
2075
- "unicorn/no-lonely-if": "error",
2076
- "unicorn/no-new-buffer": "error",
2077
- "unicorn/no-static-only-class": "error",
2078
- "unicorn/no-typeof-undefined": "error",
2079
- "unicorn/no-unnecessary-await": "error",
2080
- "unicorn/prefer-class-fields": "error",
2081
- "unicorn/prefer-import-meta-properties": "error",
2082
- "unicorn/prefer-includes": "error",
2083
- "unicorn/prefer-keyboard-event-key": "error",
2084
- "unicorn/prefer-math-min-max": "error",
2085
- "unicorn/prefer-math-trunc": "error",
2086
- "unicorn/prefer-modern-math-apis": "error",
2087
- "unicorn/prefer-negative-index": "error",
2088
- "unicorn/prefer-node-protocol": "error",
2089
- "unicorn/prefer-optional-catch-binding": "error",
2090
- "unicorn/prefer-prototype-methods": "error",
2091
- "unicorn/prefer-reflect-apply": "error",
2092
- "unicorn/prefer-structured-clone": "error",
2093
- "unicorn/switch-case-braces": ["error", "avoid"],
2094
- "unicorn/catch-error-name": ["error", {
2095
- name: "err",
2096
- ignore: ["^_."]
2097
- }],
2098
- "unicorn/custom-error-definition": "error",
2099
- "unicorn/no-useless-error-capture-stack-trace": "error",
2100
- "unicorn/prefer-type-error": "error",
2101
- "unicorn/throw-new-error": "error",
2102
- "unicorn/no-zero-fractions": "error",
2103
- "unicorn/number-literal-case": "error",
2104
- "unicorn/prefer-number-properties": "error",
2105
- "unicorn/prefer-regexp-test": "error",
2106
- "unicorn/consistent-date-clone": "error",
2107
- "unicorn/prefer-date-now": "error",
2108
- "unicorn/prefer-code-point": "error",
2109
- "unicorn/prefer-string-slice": "error",
2110
- "unicorn/prefer-string-starts-ends-with": "error",
2111
- "unicorn/prefer-string-trim-start-end": "error",
2112
- "unicorn/no-invalid-remove-event-listener": "error",
2113
- "unicorn/prefer-add-event-listener": "error",
2114
- "unicorn/prefer-dom-node-append": "error",
2115
- "unicorn/prefer-dom-node-dataset": "error",
2116
- "unicorn/prefer-dom-node-remove": "error",
2117
- "unicorn/prefer-dom-node-text-content": "error",
2118
- "unicorn/prefer-modern-dom-apis": "error",
2119
- "unicorn/prefer-query-selector": "error",
2120
- "unicorn/no-array-method-this-argument": "error",
2121
- "unicorn/no-new-array": "error",
2122
- "unicorn/no-unnecessary-array-flat-depth": "error",
2123
- "unicorn/no-unnecessary-array-splice-count": "error",
2124
- "unicorn/no-unnecessary-slice-end": "error",
2125
- "unicorn/prefer-array-find": "error",
2126
- "unicorn/prefer-array-flat-map": "error",
2127
- "unicorn/prefer-array-index-of": "error",
2128
- "unicorn/prefer-array-some": "error",
2129
- "unicorn/prefer-single-call": "error",
2130
- "unicorn/require-array-join-separator": "error",
2131
- "unicorn/prefer-set-has": "error",
2132
- "unicorn/prefer-set-size": "error",
2133
- ...disabledRules,
2134
- ...options.overrides
2135
- }
2136
- }];
2137
-
2138
- //#endregion
2139
- //#region src/configs/deMorgan.ts
2140
- /**
2141
- * Config for optimize logic
2142
- *
2143
- * @see {@link https://github.com/azat-io/eslint-plugin-de-morgan}
2144
- *
2145
- * @param options - {@link ConfigDeMorganOptions}
2146
- * @returns ESLint configs
2147
- */
2148
- const configDeMorgan = (options = {}) => [{
2149
- ...pluginDeMorgan.configs.recommended,
2150
- name: "ntnyq/de-morgan",
2151
- rules: {
2152
- ...pluginDeMorgan.configs.recommended.rules,
2153
- ...options.overrides
2154
- }
2155
- }];
2156
-
2157
- //#endregion
2158
- //#region src/configs/markdown.ts
2159
- /**
2160
- * Config for markdown files
2161
- *
2162
- * @see {@link https://github.com/eslint/markdown}
2163
- *
2164
- * @param options - {@link ConfigMarkdownOptions}
2165
- * @returns ESLint configs
2166
- */
2167
- const configMarkdown = (options = {}) => {
2168
- const { files = [GLOB_MARKDOWN_CODE], extraFileExtensions = [] } = options;
2169
- const configs = [
2170
- ...pluginMarkdown.configs.processor.map((config) => ({
2171
- ...config,
2172
- name: `ntnyq/${config.name}`
2173
- })),
2174
- (
2175
- /**
2176
- * enhance `markdown/recommended/processor`
2177
- */
2178
- {
2179
- name: "ntnyq/markdown/processor",
2180
- files,
2181
- ignores: [GLOB_MARKDOWN_NESTED],
2182
- processor: mergeProcessors([pluginMarkdown.processors.markdown, processorPassThrough])
2183
- }),
2184
- {
2185
- name: "ntnyq/markdown/parser",
2186
- files,
2187
- languageOptions: { parser: parserPlain }
2188
- },
2189
- {
2190
- name: "ntnyq/markdown/disabled",
2191
- files: [...files, ...extraFileExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*${ext}`)],
2192
- languageOptions: { parserOptions: {
2193
- project: false,
2194
- projectService: false,
2195
- ecmaFeatures: { impliedStrict: true }
2196
- } },
2197
- rules: {
2198
- "@typescript-eslint/consistent-type-imports": "off",
2199
- "@typescript-eslint/no-extraneous-class": "off",
2200
- "@typescript-eslint/no-namespace": "off",
2201
- "@typescript-eslint/no-redeclare": "off",
2202
- "@typescript-eslint/no-require-imports": "off",
2203
- "@typescript-eslint/no-unused-expressions": "off",
2204
- "@typescript-eslint/no-unused-vars": "off",
2205
- "@typescript-eslint/no-use-before-define": "off",
2206
- "import-x/no-unresolved": "off",
2207
- "no-alert": "off",
2208
- "no-console": "off",
2209
- "no-restricted-imports": "off",
2210
- "no-undef": "off",
2211
- "no-unused-expressions": "off",
2212
- "no-unused-vars": "off",
2213
- "node/prefer-global/buffer": "off",
2214
- "node/prefer-global/process": "off",
2215
- "unused-imports/no-unused-imports": "off",
2216
- "unused-imports/no-unused-vars": "off",
2217
- ...configsTypeScript.disableTypeChecked.rules,
2218
- ...options.overrides
2219
- }
2220
- }
2221
- ];
2222
- return configs;
2223
- };
2224
-
2225
- //#endregion
2226
- //#region src/configs/prettier.ts
2227
- /**
2228
- * Config for using prettier
2229
- *
2230
- * @see {@link https://github.com/prettier/eslint-plugin-prettier}
2231
- *
2232
- * @param options - {@link ConfigPrettierOptions}
2233
- * @returns ESLint configs
2234
- */
2235
- const configPrettier = (options = {}) => {
2236
- const { disabledFiles = [
2237
- GLOB_SVG,
2238
- GLOB_TOML,
2239
- GLOB_ASTRO,
2240
- GLOB_SVELTE
2241
- ], userDisabledFiles = [] } = options;
2242
- return [{
2243
- name: "ntnyq/prettier",
2244
- plugins: { prettier: pluginPrettier },
2245
- rules: {
2246
- "vue/array-bracket-newline": "off",
2247
- "vue/array-bracket-spacing": "off",
2248
- "vue/array-element-newline": "off",
2249
- "vue/arrow-spacing": "off",
2250
- "vue/block-spacing": "off",
2251
- "vue/block-tag-newline": "off",
2252
- "vue/brace-style": "off",
2253
- "vue/comma-dangle": "off",
2254
- "vue/comma-spacing": "off",
2255
- "vue/comma-style": "off",
2256
- "vue/dot-location": "off",
2257
- "vue/func-call-spacing": "off",
2258
- "vue/html-closing-bracket-newline": "off",
2259
- "vue/html-closing-bracket-spacing": "off",
2260
- "vue/html-end-tags": "off",
2261
- "vue/html-indent": "off",
2262
- "vue/html-quotes": "off",
2263
- "vue/key-spacing": "off",
2264
- "vue/keyword-spacing": "off",
2265
- "vue/max-attributes-per-line": "off",
2266
- "vue/multiline-html-element-content-newline": "off",
2267
- "vue/multiline-ternary": "off",
2268
- "vue/mustache-interpolation-spacing": "off",
2269
- "vue/no-extra-parens": "off",
2270
- "vue/no-multi-spaces": "off",
2271
- "vue/no-spaces-around-equal-signs-in-attribute": "off",
2272
- "vue/object-curly-newline": "off",
2273
- "vue/object-curly-spacing": "off",
2274
- "vue/object-property-newline": "off",
2275
- "vue/operator-linebreak": "off",
2276
- "vue/quote-props": "off",
2277
- "vue/script-indent": "off",
2278
- "vue/singleline-html-element-content-newline": "off",
2279
- "vue/space-in-parens": "off",
2280
- "vue/space-infix-ops": "off",
2281
- "vue/space-unary-ops": "off",
2282
- "vue/template-curly-spacing": "off",
2283
- "arrow-body-style": "off",
2284
- "prefer-arrow-callback": "off",
2285
- "prettier/prettier": options.severity || "warn",
2286
- ...options.overrides
2287
- }
2288
- }, (
2289
- /**
2290
- * Languages that prettier currently does not support
2291
- */
2292
- {
2293
- name: "ntnyq/prettier/disabled",
2294
- files: [...disabledFiles, ...userDisabledFiles],
2295
- plugins: { prettier: pluginPrettier },
2296
- rules: { "prettier/prettier": "off" }
2297
- })];
2298
- };
2299
-
2300
- //#endregion
2301
- //#region src/configs/specials.ts
2302
- /**
2303
- * Config for special files
2304
- *
2305
- * @param options - {@link ConfigSpecialsOptions}
2306
- * @returns ESLint configs
2307
- */
2308
- const configSpecials = (options = {}) => {
2309
- const { shadcnVue: enableShadcnVue = hasShadcnVue() } = options;
2310
- const configs = [
2311
- {
2312
- name: "ntnyq/specials/scripts",
2313
- files: [`**/scripts/${GLOB_SRC}`],
2314
- rules: {
2315
- "@typescript-eslint/explicit-function-return-type": "off",
2316
- "no-console": "off",
2317
- ...options.overridesScriptsRules
2318
- }
2319
- },
2320
- {
2321
- name: "ntnyq/specials/cli",
2322
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
2323
- rules: {
2324
- "@typescript-eslint/explicit-function-return-type": "off",
2325
- "no-console": "off",
2326
- ...options.overridesCliRules
2327
- }
2328
- },
2329
- {
2330
- name: "ntnyq/specials/bin",
2331
- files: [`**/bin/${GLOB_SRC}`, `**/bin.${GLOB_SRC_EXT}`],
2332
- rules: {
2333
- "@typescript-eslint/explicit-function-return-type": "off",
2334
- "antfu/no-import-dist": "off",
2335
- "no-console": "off",
2336
- ...options.overridesBinRules
2337
- }
2338
- },
2339
- {
2340
- name: "ntnyq/specials/userscript",
2341
- files: [`**/*.user.${GLOB_SRC_EXT}`],
2342
- languageOptions: { globals: { ...globals.greasemonkey } },
2343
- rules: {
2344
- camelcase: ["error", { allow: ["^GM_.+"] }],
2345
- ...options.overridesUserScriptsRules
2346
- }
2347
- },
2348
- {
2349
- name: "ntnyq/specials/config-file",
2350
- files: [`**/*.config*.${GLOB_SRC_EXT}`],
2351
- plugins: {
2352
- "import-x": pluginImportX,
2353
- perfectionist: pluginPerfectionist
2354
- },
2355
- settings: { perfectionist: PERFECTIONIST.pluginSettings },
2356
- rules: {
2357
- "@typescript-eslint/explicit-function-return-type": "off",
2358
- "import-x/no-default-export": "off",
2359
- "no-console": "off",
2360
- "perfectionist/sort-objects": ["error", {
2361
- ...PERFECTIONIST.partialRuleOptions,
2362
- groups: PERFECTIONIST.sortObjectsGroups
2363
- }],
2364
- ...options.overridesConfigFileRules
2365
- }
2366
- }
2367
- ];
2368
- if (enableShadcnVue) {
2369
- const shadcnOptions = resolveSubOptions(options, "shadcnVue");
2370
- configs.push({
2371
- name: "ntnyq/specials/shadcn-vue",
2372
- files: shadcnOptions.files || ["**/components/ui/**/*.ts", "**/components/ui/**/*.vue"],
2373
- rules: {
2374
- "@typescript-eslint/consistent-type-imports": "off",
2375
- "@typescript-eslint/no-unused-vars": "off",
2376
- "import-x/consistent-type-specifier-style": "off",
2377
- "vue/define-emits-declaration": "off",
2378
- "vue/html-button-has-type": "off",
2379
- "vue/no-duplicate-attr-inheritance": "off",
2380
- "vue/prefer-use-template-ref": "off",
2381
- ...shadcnOptions.overridesRules
2382
- }
2383
- });
2384
- }
2385
- if (options.specialCaseConfigs) configs.push(...options.specialCaseConfigs);
2386
- return configs;
2387
- };
2388
-
2389
- //#endregion
2390
- //#region src/configs/gitignore.ts
2391
- /**
2392
- * Config for respect `.gitignore`
2393
- *
2394
- * @see {@link https://github.com/antfu/eslint-config-flat-gitignore}
2395
- *
2396
- * @param options - {@link ConfigGitIgnoreOptions}
2397
- * @returns ESLint configs
2398
- */
2399
- const configGitIgnore = (options = {}) => {
2400
- options.strict ??= false;
2401
- return [{
2402
- ...createGitIgnoreConfig(options),
2403
- name: "ntnyq/gitignore"
2404
- }];
2405
- };
2406
-
2407
- //#endregion
2408
- //#region src/configs/javascript.ts
2409
- const strictRules = {
2410
- complexity: ["error", { max: 30 }],
2411
- "max-depth": ["error", { max: 5 }],
2412
- "max-lines": ["error", {
2413
- max: 1e3,
2414
- skipBlankLines: true,
2415
- skipComments: true
2416
- }],
2417
- "max-lines-per-function": ["error", {
2418
- max: 200,
2419
- skipBlankLines: true,
2420
- skipComments: true
2421
- }],
2422
- "max-nested-callbacks": ["error", { max: 10 }],
2423
- "max-params": ["error", { max: 5 }]
2424
- };
2425
- /**
2426
- * Config for JavaScript
2427
- *
2428
- * @see {@link https://github.com/eslint/eslint/tree/main/packages/js}
2429
- *
2430
- * @param options - {@link ConfigJavaScriptOptions}
2431
- * @returns ESLint configs
2432
- */
2433
- const configJavaScript = (options = {}) => [{
2434
- ...jsConfig.configs.recommended,
2435
- name: "ntnyq/js/recommended"
2436
- }, {
2437
- name: "ntnyq/js/core",
2438
- languageOptions: {
2439
- sourceType: "module",
2440
- globals: {
2441
- ...globals.browser,
2442
- ...globals.es2021,
2443
- ...globals.node
2444
- }
2445
- },
2446
- rules: {
2447
- "consistent-return": "off",
2448
- "no-return-assign": "off",
2449
- "no-useless-escape": "off",
2450
- "require-await": "off",
2451
- "sort-imports": "off",
2452
- "accessor-pairs": ["error", {
2453
- enforceForClassMembers: true,
2454
- setWithoutGet: true
2455
- }],
2456
- "array-callback-return": "error",
2457
- "block-scoped-var": "error",
2458
- camelcase: ["error", {
2459
- allow: ["^UNSAFE_"],
2460
- ignoreGlobals: true,
2461
- properties: "never"
2462
- }],
2463
- "constructor-super": "error",
2464
- curly: ["error", "all"],
2465
- "default-case-last": "error",
2466
- "dot-notation": ["error", { allowKeywords: true }],
2467
- eqeqeq: ["error", "smart"],
2468
- "new-cap": ["error", {
2469
- capIsNew: false,
2470
- newIsCap: true,
2471
- properties: true
2472
- }],
2473
- "no-alert": "error",
2474
- "no-array-constructor": "error",
2475
- "no-async-promise-executor": "error",
2476
- "no-caller": "error",
2477
- "no-case-declarations": "error",
2478
- "no-class-assign": "error",
2479
- "no-compare-neg-zero": "error",
2480
- "no-cond-assign": "error",
2481
- "no-const-assign": "error",
2482
- "no-constant-condition": ["error", { checkLoops: false }],
2483
- "no-control-regex": "error",
2484
- "no-debugger": "error",
2485
- "no-delete-var": "error",
2486
- "no-dupe-args": "error",
2487
- "no-dupe-class-members": "error",
2488
- "no-dupe-keys": "error",
2489
- "no-duplicate-case": "error",
2490
- "no-empty": ["error", { allowEmptyCatch: true }],
2491
- "no-empty-character-class": "error",
2492
- "no-empty-pattern": "error",
2493
- "no-empty-static-block": "error",
2494
- "no-eval": "error",
2495
- "no-ex-assign": "error",
2496
- "no-extend-native": "error",
2497
- "no-extra-bind": "error",
2498
- "no-extra-boolean-cast": "error",
2499
- "no-fallthrough": "error",
2500
- "no-func-assign": "error",
2501
- "no-global-assign": "error",
2502
- "no-implied-eval": "error",
2503
- "no-import-assign": "error",
2504
- "no-invalid-regexp": "error",
2505
- "no-irregular-whitespace": "error",
2506
- "no-iterator": "error",
2507
- "no-labels": ["error", {
2508
- allowLoop: false,
2509
- allowSwitch: false
2510
- }],
2511
- "no-lone-blocks": "error",
2512
- "no-loss-of-precision": "error",
2513
- "no-misleading-character-class": "error",
2514
- "no-multi-str": "error",
2515
- "no-negated-condition": "error",
2516
- "no-new": "error",
2517
- "no-new-func": "error",
2518
- "no-new-native-nonconstructor": "error",
2519
- "no-new-wrappers": "error",
2520
- "no-obj-calls": "error",
2521
- "no-octal": "error",
2522
- "no-octal-escape": "error",
2523
- "no-proto": "error",
2524
- "no-prototype-builtins": "error",
2525
- "no-redeclare": ["error", { builtinGlobals: false }],
2526
- "no-regex-spaces": "error",
2527
- "no-self-assign": ["error", { props: true }],
2528
- "no-self-compare": "error",
2529
- "no-sequences": "error",
2530
- "no-shadow-restricted-names": "error",
2531
- "no-sparse-arrays": "error",
2532
- "no-template-curly-in-string": "error",
2533
- "no-this-before-super": "error",
2534
- "no-throw-literal": "error",
2535
- "no-undef": "error",
2536
- "no-undef-init": "error",
2537
- "no-unexpected-multiline": "error",
2538
- "no-unmodified-loop-condition": "error",
2539
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
2540
- "no-unreachable": "error",
2541
- "no-unreachable-loop": "error",
2542
- "no-unsafe-finally": "error",
2543
- "no-unsafe-negation": "error",
2544
- "no-unused-expressions": ["error", {
2545
- allowShortCircuit: true,
2546
- allowTaggedTemplates: true,
2547
- allowTernary: true
2548
- }],
2549
- "no-unused-vars": ["error", {
2550
- args: "none",
2551
- caughtErrors: "none",
2552
- ignoreRestSiblings: true,
2553
- vars: "all"
2554
- }],
2555
- "no-use-before-define": ["error", {
2556
- allowNamedExports: false,
2557
- classes: false,
2558
- functions: false,
2559
- variables: true
2560
- }],
2561
- "no-useless-backreference": "error",
2562
- "no-useless-call": "error",
2563
- "no-useless-catch": "error",
2564
- "no-useless-computed-key": "error",
2565
- "no-useless-constructor": "error",
2566
- "no-useless-rename": "error",
2567
- "no-useless-return": "error",
2568
- "no-var": "error",
2569
- "no-void": "error",
2570
- "no-with": "error",
2571
- "object-shorthand": [
2572
- "error",
2573
- "always",
2574
- {
2575
- avoidQuotes: true,
2576
- ignoreConstructors: false
2577
- }
2578
- ],
2579
- "one-var": ["error", "never"],
2580
- "prefer-arrow-callback": ["error", {
2581
- allowNamedFunctions: false,
2582
- allowUnboundThis: true
2583
- }],
2584
- "prefer-const": ["error", {
2585
- destructuring: "all",
2586
- ignoreReadBeforeAssign: true
2587
- }],
2588
- "prefer-promise-reject-errors": "error",
2589
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
2590
- "prefer-rest-params": "error",
2591
- "prefer-spread": "error",
2592
- "prefer-template": "error",
2593
- "symbol-description": "error",
2594
- "unicode-bom": ["error", "never"],
2595
- "use-isnan": ["error", {
2596
- enforceForIndexOf: true,
2597
- enforceForSwitchCase: true
2598
- }],
2599
- "valid-typeof": ["error", { requireStringLiterals: true }],
2600
- "vars-on-top": "error",
2601
- yoda: ["error", "never"],
2602
- ...options.strict ? strictRules : {},
2603
- ...options.overrides
2604
- }
2605
- }];
2606
- const configJSX = () => [{
2607
- name: "ntnyq/jsx",
2608
- files: [GLOB_JSX_ONLY],
2609
- languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
2610
- }];
2611
-
2612
- //#endregion
2613
- //#region src/configs/typescript.ts
2614
- /**
2615
- * @see {@link https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts}
2616
- */
2617
- const typeAwareRules = {
2618
- "@typescript-eslint/strict-boolean-expressions": "off",
2619
- "dot-notation": "off",
2620
- "no-implied-eval": "off",
2621
- "no-throw-literal": "off",
2622
- "require-await": "off",
2623
- "@typescript-eslint/await-thenable": "error",
2624
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
2625
- "@typescript-eslint/no-duplicate-type-constituents": "error",
2626
- "@typescript-eslint/no-floating-promises": "error",
2627
- "@typescript-eslint/no-for-in-array": "error",
2628
- "@typescript-eslint/no-implied-eval": "error",
2629
- "@typescript-eslint/no-misused-promises": "error",
2630
- "@typescript-eslint/no-misused-spread": "error",
2631
- "@typescript-eslint/no-redundant-type-constituents": "error",
2632
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
2633
- "@typescript-eslint/no-unsafe-argument": "error",
2634
- "@typescript-eslint/no-unsafe-assignment": "error",
2635
- "@typescript-eslint/no-unsafe-call": "error",
2636
- "@typescript-eslint/no-unsafe-member-access": "error",
2637
- "@typescript-eslint/no-unsafe-return": "error",
2638
- "@typescript-eslint/only-throw-error": "error",
2639
- "@typescript-eslint/promise-function-async": "error",
2640
- "@typescript-eslint/require-await": "error",
2641
- "@typescript-eslint/restrict-plus-operands": "error",
2642
- "@typescript-eslint/restrict-template-expressions": "error",
2643
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
2644
- "@typescript-eslint/switch-exhaustiveness-check": "error",
2645
- "@typescript-eslint/triple-slash-reference": "error",
2646
- "@typescript-eslint/unbound-method": "error"
2647
- };
2648
- /**
2649
- * typescript-eslint recommended rules
2650
- */
2651
- const recommendedRules = configsTypeScript.recommended.reduce((rules, config) => {
2652
- return {
2653
- ...rules,
2654
- ...config.rules || {}
2655
- };
2656
- }, {});
2657
- /**
2658
- * Config for TypeScript files
2659
- *
2660
- * @see {@link https://github.com/typescript-eslint/typescript-eslint}
2661
- *
2662
- * @param options - {@link ConfigTypeScriptOptions}
2663
- * @returns ESLint configs
2664
- */
2665
- const configTypeScript = (options = {}) => {
2666
- /**
2667
- * @see {@link https://typescript-eslint.io/troubleshooting/typed-linting}
2668
- */
2669
- const enableTypeAwareLint = !!options?.tsconfigPath;
2670
- const { allowDefaultProject = [], extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
2671
- const files = options.files ?? [
2672
- GLOB_TS,
2673
- GLOB_TSX,
2674
- ...extraFileExtensions.map((ext) => `**/*${ext}`)
2675
- ];
2676
- function createParserConfig(enableTypeAware = false, files$1 = [], ignores = []) {
2677
- const typescriptParserOptions = {
2678
- extraFileExtensions,
2679
- sourceType: "module",
2680
- ...enableTypeAware ? {
2681
- tsconfigRootDir: process.cwd(),
2682
- projectService: {
2683
- allowDefaultProject: ["./*.js", ...allowDefaultProject],
2684
- defaultProject: options.tsconfigPath
2685
- }
2686
- } : {},
2687
- ...parserOptions
2688
- };
2689
- const parserConfig = {
2690
- name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
2691
- files: files$1,
2692
- ignores: [...ignores],
2693
- languageOptions: {
2694
- parser: parserTypeScript,
2695
- parserOptions: typescriptParserOptions
2696
- }
2697
- };
2698
- return parserConfig;
2699
- }
2700
- return [
2701
- {
2702
- name: "ntnyq/ts/setup",
2703
- plugins: {
2704
- "@typescript-eslint": pluginTypeScript,
2705
- antfu: pluginAntfu
2706
- }
2707
- },
2708
- ...enableTypeAwareLint ? [createParserConfig(false, files), createParserConfig(true, filesTypeAware, ignoresTypeAware)] : [createParserConfig(false, files)],
2709
- {
2710
- name: "ntnyq/ts/rules",
2711
- files,
2712
- rules: {
2713
- ...recommendedRules,
2714
- "@typescript-eslint/consistent-indexed-object-style": "off",
2715
- "@typescript-eslint/explicit-function-return-type": "off",
2716
- "@typescript-eslint/explicit-member-accessibility": "off",
2717
- "@typescript-eslint/explicit-module-boundary-types": "off",
2718
- "@typescript-eslint/naming-convention": "off",
2719
- "@typescript-eslint/no-empty-function": "off",
2720
- "@typescript-eslint/no-explicit-any": "off",
2721
- "@typescript-eslint/no-namespace": "off",
2722
- "@typescript-eslint/no-non-null-assertion": "off",
2723
- "@typescript-eslint/triple-slash-reference": "off",
2724
- "default-param-last": "off",
2725
- "no-redeclare": "off",
2726
- "no-unused-vars": "off",
2727
- "no-use-before-define": "off",
2728
- "no-useless-constructor": "off",
2729
- "@typescript-eslint/prefer-as-const": "warn",
2730
- "@typescript-eslint/ban-ts-comment": ["error", {
2731
- minimumDescriptionLength: 1,
2732
- "ts-check": false,
2733
- "ts-expect-error": "allow-with-description",
2734
- "ts-ignore": "allow-with-description",
2735
- "ts-nocheck": "allow-with-description"
2736
- }],
2737
- "@typescript-eslint/ban-tslint-comment": "error",
2738
- "@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
2739
- "@typescript-eslint/consistent-type-assertions": ["error", {
2740
- assertionStyle: "as",
2741
- objectLiteralTypeAssertions: "allow-as-parameter"
2742
- }],
2743
- "@typescript-eslint/consistent-type-imports": ["error", {
2744
- disallowTypeAnnotations: false,
2745
- fixStyle: "separate-type-imports",
2746
- prefer: "type-imports"
2747
- }],
2748
- "@typescript-eslint/default-param-last": "error",
2749
- "@typescript-eslint/no-empty-object-type": ["error", {
2750
- allowInterfaces: "always",
2751
- allowObjectTypes: "always"
2752
- }],
2753
- "@typescript-eslint/no-redeclare": ["error", {
2754
- builtinGlobals: false,
2755
- ignoreDeclarationMerge: true
2756
- }],
2757
- "@typescript-eslint/no-unused-expressions": ["error", {
2758
- allowShortCircuit: true,
2759
- allowTaggedTemplates: true,
2760
- allowTernary: true
2761
- }],
2762
- "@typescript-eslint/no-unused-vars": ["error", {
2763
- args: "after-used",
2764
- argsIgnorePattern: "^_",
2765
- caughtErrors: "all",
2766
- caughtErrorsIgnorePattern: "^_",
2767
- destructuredArrayIgnorePattern: "^_",
2768
- ignoreRestSiblings: true,
2769
- varsIgnorePattern: "^_"
2770
- }],
2771
- "@typescript-eslint/no-use-before-define": ["error", {
2772
- allowNamedExports: false,
2773
- classes: false,
2774
- enums: true,
2775
- functions: false,
2776
- ignoreTypeReferences: false,
2777
- typedefs: false,
2778
- variables: true
2779
- }],
2780
- "@typescript-eslint/no-useless-constructor": "error",
2781
- ...options.overrides
2782
- }
2783
- },
2784
- ...enableTypeAwareLint ? [{
2785
- name: "ntnyq/ts/rules/type-aware",
2786
- files: [...filesTypeAware],
2787
- ignores: [...ignoresTypeAware],
2788
- rules: {
2789
- ...typeAwareRules,
2790
- ...overridesTypeAwareRules
2791
- }
2792
- }] : [],
2793
- {
2794
- name: "ntnyq/ts/types",
2795
- files: [...GLOB_TYPES],
2796
- rules: {
2797
- "@typescript-eslint/no-use-before-define": "off",
2798
- "import-x/newline-after-import": "off",
2799
- "import-x/no-duplicates": "off",
2800
- "no-restricted-syntax": "off",
2801
- "no-use-before-define": "off",
2802
- "no-var": "off",
2803
- "vars-on-top": "off"
2804
- }
2805
- }
2806
- ];
2807
- };
2808
-
2809
- //#endregion
2810
- //#region src/configs/eslintPlugin.ts
2811
- /**
2812
- * Config for eslint plugin
2813
- *
2814
- * @see {@link https://github.com/eslint-community/eslint-plugin-eslint-plugin}
2815
- *
2816
- * @param options - {@link ConfigESLintPluginOptions}
2817
- * @returns ESLint configs
2818
- */
2819
- const configESLintPlugin = async (options = {}) => {
2820
- await ensurePackages(["eslint-plugin-eslint-plugin"]);
2821
- const pluginESLintPlugin = await interopDefault(import("eslint-plugin-eslint-plugin"));
2822
- return [{
2823
- ...pluginESLintPlugin.configs.all,
2824
- name: "ntnyq/eslint-plugin",
2825
- rules: {
2826
- ...pluginESLintPlugin.configs.all.rules,
2827
- "eslint-plugin/require-meta-docs-url": "off",
2828
- ...options.overrides
2829
- }
2830
- }];
2831
- };
2832
-
2833
- //#endregion
2834
- //#region src/configs/githubAction.ts
2835
- /**
2836
- * Config for github action files
2837
- *
2838
- * @see {@link https://github.com/ntnyq/eslint-plugin-github-action}
2839
- *
2840
- * @param options - {@link ConfigGitHubActionOptions}
2841
- * @returns ESLint configs
2842
- */
2843
- const configGitHubAction = (options = {}) => {
2844
- const { files = [GLOB_GITHUB_ACTION] } = options;
2845
- return [{
2846
- name: "ntnyq/github-action",
2847
- files,
2848
- plugins: { "github-action": pluginGitHubAction },
2849
- languageOptions: { parser: parserYaml },
2850
- rules: {
2851
- "github-action/no-invalid-key": "error",
2852
- "github-action/prefer-file-extension": "error",
2853
- "github-action/require-action-name": "error",
2854
- "github-action/valid-timeout-minutes": "error",
2855
- "github-action/valid-trigger-events": "error",
2856
- ...options.overrides
2857
- }
2858
- }];
2859
- };
2860
-
2861
- //#endregion
2862
- //#region src/configs/perfectionist.ts
2863
- /**
2864
- * Config for sorting imports, exports, objects and etc
2865
- *
2866
- * @see {@link https://github.com/azat-io/eslint-plugin-perfectionist}
2867
- *
2868
- * @param options - {@link ConfigPerfectionistOptions}
2869
- * @returns ESLint configs
2870
- */
2871
- const configPerfectionist = (options = {}) => {
2872
- const { filesEnums = [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`], filesTypes = [...GLOB_TYPES], partitionByComment = PERFECTIONIST.partialRuleOptions.partitionByComment, sortConstants: enableSortConstants = true, sortEnums: enableSortEnums = true, sortTypes: enableSortTypes = true, filesConstants = [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`] } = options;
2873
- const sharedOptionsWithNewlinesBetween = {
2874
- newlinesBetween: "ignore",
2875
- partitionByComment
2876
- };
2877
- const commonRules = {
2878
- "perfectionist/sort-exports": ["error", {
2879
- ...sharedOptionsWithNewlinesBetween,
2880
- groups: PERFECTIONIST.sortExportsGroups,
2881
- type: "line-length"
2882
- }],
2883
- "perfectionist/sort-imports": ["error", {
2884
- ...sharedOptionsWithNewlinesBetween,
2885
- groups: PERFECTIONIST.sortImportsTypes,
2886
- internalPattern: [
2887
- "^~/.+",
2888
- "^@/.+",
2889
- "^#.+"
2890
- ]
2891
- }],
2892
- "perfectionist/sort-named-exports": ["error", {
2893
- ...sharedOptionsWithNewlinesBetween,
2894
- groups: PERFECTIONIST.sortNamedExportsGroups,
2895
- ignoreAlias: false
2896
- }],
2897
- "perfectionist/sort-named-imports": ["error", {
2898
- ...sharedOptionsWithNewlinesBetween,
2899
- groups: PERFECTIONIST.sortNamedImportsGroups,
2900
- ignoreAlias: false
2901
- }]
2902
- };
2903
- const sharedRules$1 = { "perfectionist/sort-enums": ["error", { ...sharedOptionsWithNewlinesBetween }] };
2904
- const sortEnumsRules = { "perfectionist/sort-modules": ["error", { ...sharedOptionsWithNewlinesBetween }] };
2905
- const sortTypesRules = {
2906
- "perfectionist/sort-heritage-clauses": "error",
2907
- "perfectionist/sort-interfaces": ["error", {
2908
- ...sharedOptionsWithNewlinesBetween,
2909
- groups: PERFECTIONIST.sortInterfacesOrObjectTypesGroups
2910
- }],
2911
- "perfectionist/sort-intersection-types": ["error", {
2912
- ...sharedOptionsWithNewlinesBetween,
2913
- groups: PERFECTIONIST.sortIntersectionTypesOrUnionTypesGroups
2914
- }],
2915
- "perfectionist/sort-object-types": ["error", {
2916
- ...sharedOptionsWithNewlinesBetween,
2917
- groups: PERFECTIONIST.sortInterfacesOrObjectTypesGroups
2918
- }],
2919
- "perfectionist/sort-union-types": ["error", {
2920
- ...sharedOptionsWithNewlinesBetween,
2921
- groups: PERFECTIONIST.sortIntersectionTypesOrUnionTypesGroups
2922
- }]
2923
- };
2924
- const sortConstantsRules = {
2925
- "perfectionist/sort-maps": ["error", { ...sharedOptionsWithNewlinesBetween }],
2926
- "perfectionist/sort-objects": ["error", {
2927
- ...sharedOptionsWithNewlinesBetween,
2928
- groups: PERFECTIONIST.sortObjectsGroups
2929
- }],
2930
- "perfectionist/sort-sets": ["error", { ...sharedOptionsWithNewlinesBetween }]
2931
- };
2932
- const extraRules = {
2933
- "perfectionist/sort-array-includes": ["error", {
2934
- ...sharedOptionsWithNewlinesBetween,
2935
- groups: ["literal", "spread"]
2936
- }],
2937
- "perfectionist/sort-classes": ["error", {
2938
- ...sharedOptionsWithNewlinesBetween,
2939
- groups: PERFECTIONIST.sortClassesGroups
2940
- }],
2941
- "perfectionist/sort-decorators": ["error", { partitionByComment }],
2942
- "perfectionist/sort-jsx-props": ["error", { groups: [
2943
- "shorthand",
2944
- "multiline",
2945
- "unknown"
2946
- ] }],
2947
- "perfectionist/sort-switch-case": "error",
2948
- "perfectionist/sort-variable-declarations": ["error", { partitionByComment }]
2949
- };
2950
- const configs = [{
2951
- name: options.all ? "ntnyq/perfectionist/all" : "ntnyq/perfectionist/common",
2952
- plugins: { perfectionist: pluginPerfectionist },
2953
- settings: { perfectionist: PERFECTIONIST.pluginSettings },
2954
- rules: {
2955
- ...commonRules,
2956
- ...options.all ? {
2957
- ...sharedRules$1,
2958
- ...sortEnumsRules,
2959
- ...sortTypesRules,
2960
- ...sortConstantsRules,
2961
- ...extraRules
2962
- } : {},
2963
- ...options.overrides
2964
- }
2965
- }];
2966
- if (options.all) return configs;
2967
- if (enableSortEnums) configs.push({
2968
- name: "ntnyq/perfectionist/enums",
2969
- files: filesEnums,
2970
- plugins: { perfectionist: pluginPerfectionist },
2971
- settings: { perfectionist: PERFECTIONIST.pluginSettings },
2972
- rules: {
2973
- ...sharedRules$1,
2974
- ...sortEnumsRules,
2975
- ...options.overridesEnumsRules
2976
- }
2977
- });
2978
- if (enableSortTypes) configs.push({
2979
- name: "ntnyq/perfectionist/types",
2980
- files: filesTypes,
2981
- plugins: { perfectionist: pluginPerfectionist },
2982
- settings: { perfectionist: PERFECTIONIST.pluginSettings },
2983
- rules: {
2984
- ...sharedRules$1,
2985
- ...sortTypesRules,
2986
- ...options.overridesTypesRules
2987
- }
2988
- });
2989
- if (enableSortConstants) configs.push({
2990
- name: "ntnyq/perfectionist/constants",
2991
- files: filesConstants,
2992
- plugins: { perfectionist: pluginPerfectionist },
2993
- settings: { perfectionist: PERFECTIONIST.pluginSettings },
2994
- rules: {
2995
- ...sharedRules$1,
2996
- ...sortConstantsRules,
2997
- ...options.overridesConstantsRules
2998
- }
2999
- });
3000
- return configs;
3001
- };
3002
-
3003
- //#endregion
3004
- //#region src/configs/unusedImports.ts
3005
- /**
3006
- * Config for remove unused imports
3007
- *
3008
- * @see {@link https://github.com/sweepline/eslint-plugin-unused-imports}
3009
- *
3010
- * @param options - {@link ConfigUnusedImportsOptions}
3011
- * @returns ESLint configs
3012
- */
3013
- const configUnusedImports = async (options = {}) => {
3014
- await ensurePackages(["eslint-plugin-unused-imports"]);
3015
- const pluginUnusedImports = await interopDefault(import("eslint-plugin-unused-imports"));
3016
- return [{
3017
- name: "ntnyq/unused-imports",
3018
- plugins: { "unused-imports": pluginUnusedImports },
3019
- rules: {
3020
- "@typescript-eslint/no-unused-vars": "off",
3021
- "unused-imports/no-unused-imports": "error",
3022
- "unused-imports/no-unused-vars": ["error", {
3023
- args: "after-used",
3024
- argsIgnorePattern: "^_",
3025
- caughtErrors: "all",
3026
- caughtErrorsIgnorePattern: "^_",
3027
- destructuredArrayIgnorePattern: "^_",
3028
- ignoreRestSiblings: true,
3029
- vars: "all",
3030
- varsIgnorePattern: "^_"
3031
- }],
3032
- ...options.overrides
3033
- }
3034
- }];
3035
- };
3036
-
3037
- //#endregion
3038
- //#region src/configs/eslintComments.ts
3039
- /**
3040
- * Config for eslint comments
3041
- *
3042
- * @see {@link https://github.com/eslint-community/eslint-plugin-eslint-comments}
3043
- *
3044
- * @param options - {@link ConfigESLintCommentsOptions}
3045
- * @returns ESLint configs
3046
- */
3047
- const configESLintComments = (options = {}) => [{
3048
- name: "ntnyq/eslint-comments",
3049
- plugins: { "@eslint-community/eslint-comments": pluginComments },
3050
- rules: {
3051
- ...pluginComments.configs.recommended.rules,
3052
- "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
3053
- ...options.overrides
3054
- }
3055
- }];
3056
-
3057
- //#endregion
3058
- //#region src/core.ts
3059
- /**
3060
- * Config factory
3061
- */
3062
- function defineESLintConfig(options = {}, ...userConfigs) {
3063
- const { shareable = {}, vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = hasTypeScript(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, prettier: enablePrettier = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, jsdoc: enableJsdoc = true, importX: enableImportX = true, specials: enableSpecials = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false } = options;
3064
- const configs = [];
3065
- const { extraFileExtensions = [] } = shareable;
3066
- if (enableVue) extraFileExtensions.push(".vue");
3067
- if (enableAstro) extraFileExtensions.push(".astro");
3068
- if (enableSvelte) extraFileExtensions.push(".svelte");
3069
- if (enableGitIgnore) configs.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
3070
- configs.push(configIgnores(options.ignores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")), configESLintComments({ overrides: getOverrides(options, "eslintComments") }), configJavaScript({
3071
- ...resolveSubOptions(options, "javascript"),
3072
- overrides: getOverrides(options, "javascript")
3073
- }));
3074
- if (enableImportX) configs.push(configImportX({
3075
- typescript: !!enableTypeScript,
3076
- ...resolveSubOptions(options, "importX"),
3077
- overrides: getOverrides(options, "importX")
3078
- }));
3079
- if (enableJsdoc) configs.push(configJsdoc({
3080
- typescript: !!enableTypeScript,
3081
- overrides: getOverrides(options, "jsdoc"),
3082
- ...resolveSubOptions(options, "jsdoc")
3083
- }));
3084
- if (enablePerfectionist) configs.push(configPerfectionist({
3085
- ...resolveSubOptions(options, "perfectionist"),
3086
- overrides: getOverrides(options, "perfectionist")
3087
- }));
3088
- if (enableUnicorn) configs.push(configUnicorn({ overrides: getOverrides(options, "unicorn") }));
3089
- if (enablePinia) configs.push(configPinia({
3090
- ...resolveSubOptions(options, "pinia"),
3091
- overrides: getOverrides(options, "pinia")
3092
- }));
3093
- if (enableDeMorgan) configs.push(configDeMorgan({ overrides: getOverrides(options, "deMorgan") }));
3094
- if (enableRegexp) configs.push(configRegexp({
3095
- ...resolveSubOptions(options, "regexp"),
3096
- overrides: getOverrides(options, "regexp")
3097
- }));
3098
- if (enableTypeScript) configs.push(configTypeScript({
3099
- ...resolveSubOptions(options, "typescript"),
3100
- overrides: getOverrides(options, "typescript"),
3101
- extraFileExtensions
3102
- }));
3103
- if (enableVue) configs.push(configVue({
3104
- ...resolveSubOptions(options, "vue"),
3105
- typescript: !!enableTypeScript,
3106
- overrides: getOverrides(options, "vue"),
3107
- extraFileExtensions
3108
- }));
3109
- if (enableYML) configs.push(configYml({
3110
- prettier: !!enablePrettier,
3111
- ...resolveSubOptions(options, "yml"),
3112
- overrides: getOverrides(options, "yml")
3113
- }));
3114
- if (enableTOML) configs.push(configToml({
3115
- ...resolveSubOptions(options, "toml"),
3116
- overrides: getOverrides(options, "toml")
3117
- }));
3118
- if (enableJSONC) configs.push(configJsonc({
3119
- prettier: !!enablePrettier,
3120
- ...resolveSubOptions(options, "jsonc"),
3121
- overrides: getOverrides(options, "jsonc")
3122
- }));
3123
- if (enableAstro) configs.push(configAstro({
3124
- ...resolveSubOptions(options, "astro"),
3125
- typescript: !!enableTypeScript,
3126
- overrides: getOverrides(options, "astro"),
3127
- extraFileExtensions
3128
- }));
3129
- if (enableSvelte) configs.push(configSvelte({
3130
- ...resolveSubOptions(options, "svelte"),
3131
- typescript: !!enableTypeScript,
3132
- overrides: getOverrides(options, "svelte"),
3133
- extraFileExtensions
3134
- }));
3135
- if (enableSort) configs.push(configSort(resolveSubOptions(options, "sort")));
3136
- if (enableTest) configs.push(configTest({
3137
- ...resolveSubOptions(options, "test"),
3138
- overrides: getOverrides(options, "test")
3139
- }));
3140
- if (enableUnoCSS) configs.push(configUnoCSS({ overrides: getOverrides(options, "unocss") }));
3141
- if (enableMarkdown) configs.push(configMarkdown({
3142
- ...resolveSubOptions(options, "markdown"),
3143
- overrides: getOverrides(options, "markdown"),
3144
- extraFileExtensions
3145
- }));
3146
- if (enableAntfu) configs.push(configAntfu({ overrides: getOverrides(options, "antfu") }));
3147
- if (enableDepend) configs.push(configDepend({
3148
- ...resolveSubOptions(options, "depend"),
3149
- overrides: getOverrides(options, "depend")
3150
- }));
3151
- if (enableNtnyq) configs.push(configNtnyq({ overrides: getOverrides(options, "ntnyq") }));
3152
- if (enableGitHubAction) configs.push(configGitHubAction({ overrides: getOverrides(options, "githubAction") }));
3153
- if (enableESLintPlugin) configs.push(configESLintPlugin({ overrides: getOverrides(options, "eslintPlugin") }));
3154
- if (enablePnpm) configs.push(configPnpm(resolveSubOptions(options, "pnpm")));
3155
- if (enableSVGO) configs.push(configSVGO(resolveSubOptions(options, "svgo")));
3156
- if (enableHTML) configs.push(configHtml({
3157
- ...resolveSubOptions(options, "html"),
3158
- overrides: getOverrides(options, "html")
3159
- }));
3160
- if (enableSpecials) configs.push(configSpecials(resolveSubOptions(options, "specials")));
3161
- const prettierConfigs = enablePrettier ? configPrettier({
3162
- ...resolveSubOptions(options, "prettier"),
3163
- overrides: getOverrides(options, "prettier")
3164
- }) : [];
3165
- const composer = new FlatConfigComposer(...configs, ...userConfigs, ...prettierConfigs);
3166
- return composer;
3167
- }
3168
-
3169
- //#endregion
3170
- export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_YAML, PERFECTIONIST, PRETTIER_DEFAULT_OPTIONS, combineConfigs, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configFormat, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasPinia, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergePrettierOptions, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginComments, pluginDeMorgan, pluginDepend, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNoOnlyTests, pluginNode, pluginNtnyq, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };