@ntnyq/eslint-config 5.0.0-beta.1 → 5.0.0-beta.3

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