@ntnyq/eslint-config 4.3.0 → 5.0.0-beta.2

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