@ntnyq/eslint-config 2.8.2 → 3.0.0-beta.10

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.js CHANGED
@@ -1,43 +1,15 @@
1
- // src/utils/env.ts
2
- import process from "node:process";
3
- import { resolve } from "node:path";
4
- import { isPackageExists } from "local-pkg";
5
- var hasTypeScript = isPackageExists("typescript");
6
- var hasVitest = isPackageExists("vitest");
7
- var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
8
- paths: [resolve(process.cwd(), "playground")]
9
- });
10
- var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
11
-
12
- // src/utils/interopDefault.ts
13
- async function interopDefault(mod) {
14
- const resolved = await mod;
15
- return resolved.default || resolved;
16
- }
17
-
18
- // src/utils/loadPlugin.ts
19
- async function loadPlugin(name) {
20
- const mod = await import(name).catch((err) => {
21
- console.error(err);
22
- throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
23
- });
24
- return interopDefault(mod);
25
- }
26
-
27
- // src/utils/defineConfig.ts
28
- function defineConfig(configs = []) {
29
- return configs;
30
- }
1
+ // src/core.ts
2
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
31
3
 
32
4
  // src/globs.ts
33
5
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
34
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
6
+ var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
35
7
  var GLOB_JS = "**/*.?([cm])js";
36
8
  var GLOB_JSX = "**/*.?([cm])jsx";
37
9
  var GLOB_TS = "**/*.?([cm])ts";
38
10
  var GLOB_TSX = "**/*.?([cm])tsx";
39
11
  var GLOB_DTS = "**/*.d.?([cm])ts";
40
- var GLOB_TEST = "**/*.{test,spec}.?([cm])[jt]s?(x)";
12
+ var GLOB_TEST = `**/*.{test,spec,bench,benchmark}.${GLOB_SRC_EXT}`;
41
13
  var GLOB_STYLE = "**/*.{c,le,sc}ss";
42
14
  var GLOB_CSS = "**/*.css";
43
15
  var GLOB_LESS = "**/*.less";
@@ -46,20 +18,22 @@ var GLOB_JSON = "**/*.json";
46
18
  var GLOB_JSON5 = "**/*.json5";
47
19
  var GLOB_JSONC = "**/*.jsonc";
48
20
  var GLOB_VUE = "**/*.vue";
49
- var GLOB_MARKDOWN = "**/*.md";
50
21
  var GLOB_YAML = "**/*.y?(a)ml";
51
22
  var GLOB_TOML = "**/*.toml";
52
23
  var GLOB_HTML = "**/*.htm?(l)";
24
+ var GLOB_MARKDOWN = "**/*.md";
25
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
26
+ var GLOB_MARKDOWN_NESTED = `${GLOB_MARKDOWN}/*.md`;
53
27
  var GLOB_ALL_SRC = [
54
28
  GLOB_SRC,
55
29
  GLOB_STYLE,
56
30
  GLOB_JSON,
57
31
  GLOB_JSON5,
58
- GLOB_MARKDOWN,
59
32
  GLOB_VUE,
60
33
  GLOB_YAML,
61
34
  GLOB_TOML,
62
- GLOB_HTML
35
+ GLOB_HTML,
36
+ GLOB_MARKDOWN
63
37
  ];
64
38
  var GLOB_NODE_MODULES = "**/node_modules/**";
65
39
  var GLOB_DIST = "**/dist/**";
@@ -115,1357 +89,1669 @@ var GLOB_EXCLUDE = [
115
89
  "**/.yarnrc"
116
90
  ];
117
91
 
118
- // src/configs/ignores.ts
119
- var ignores = defineConfig([
120
- {
121
- name: "ntnyq/ignores",
122
- ignores: GLOB_EXCLUDE
123
- }
124
- ]);
125
-
126
92
  // src/plugins.ts
127
93
  import tseslint from "typescript-eslint";
94
+ import * as parserVue from "vue-eslint-parser";
95
+ import * as parserToml from "toml-eslint-parser";
96
+ import * as parserYaml from "yaml-eslint-parser";
97
+ import * as parserJsonc from "jsonc-eslint-parser";
128
98
  import * as pluginRegexp from "eslint-plugin-regexp";
129
99
  import { default as default2 } from "eslint-plugin-n";
130
100
  import { default as default3 } from "eslint-plugin-vue";
131
101
  import { default as default4 } from "eslint-plugin-yml";
132
102
  import { default as default5 } from "eslint-plugin-toml";
133
- import { default as default6 } from "eslint-plugin-jsonc";
134
- import { default as default7 } from "eslint-plugin-jsdoc";
135
- import { default as default8 } from "@unocss/eslint-plugin";
136
- import { default as default9 } from "@vitest/eslint-plugin";
137
- import { default as default10 } from "eslint-plugin-unicorn";
138
- import { default as default11 } from "eslint-plugin-import-x";
139
- import { default as default12 } from "eslint-plugin-prettier";
140
- import { default as default13 } from "eslint-plugin-markdown";
141
- import { default as default14 } from "eslint-plugin-perfectionist";
142
- import { default as default15 } from "eslint-plugin-unused-imports";
143
- import { default as default16 } from "@eslint-community/eslint-plugin-eslint-comments";
144
- import * as parserToml from "toml-eslint-parser";
145
- import * as parserYaml from "yaml-eslint-parser";
146
- import * as parserVue from "vue-eslint-parser";
147
- import * as parserJsonc from "jsonc-eslint-parser";
103
+ import { default as default6 } from "@eslint/markdown";
104
+ import { default as default7 } from "eslint-plugin-antfu";
105
+ import { default as default8 } from "eslint-plugin-jsdoc";
106
+ import { default as default9 } from "eslint-plugin-jsonc";
107
+ import { default as default10 } from "@unocss/eslint-plugin";
108
+ import { default as default11 } from "@vitest/eslint-plugin";
109
+ import { default as default12 } from "eslint-plugin-import-x";
110
+ import { default as default13 } from "eslint-plugin-unicorn";
111
+ import { default as default14 } from "eslint-plugin-prettier";
112
+ import { default as default15 } from "eslint-plugin-perfectionist";
113
+ import { default as default16 } from "eslint-plugin-unused-imports";
114
+ import { default as default17 } from "@eslint-community/eslint-plugin-eslint-comments";
148
115
 
149
- // src/configs/node.ts
150
- var node = defineConfig([
151
- {
152
- name: "ntnyq/node",
153
- plugins: {
154
- node: default2
116
+ // src/configs/typescript.ts
117
+ import process from "node:process";
118
+ var typescriptCore = (options = {}) => {
119
+ const isTypeAware = !!options.tsconfigPath;
120
+ const configs = tseslint.config({
121
+ name: "ntnyq/ts/core",
122
+ extends: [...tseslint.configs.recommended],
123
+ files: [GLOB_TS, GLOB_TSX],
124
+ languageOptions: {
125
+ parser: tseslint.parser,
126
+ parserOptions: {
127
+ sourceType: "module",
128
+ ...isTypeAware ? {
129
+ projectService: {
130
+ defaultProject: options.tsconfigPath
131
+ },
132
+ tsconfigRootDir: process.cwd()
133
+ } : {}
134
+ }
155
135
  },
156
136
  rules: {
157
- "node/handle-callback-err": ["error", "^(err|error)$"],
158
- "node/no-deprecated-api": "error",
159
- "node/no-exports-assign": "error",
160
- "node/no-new-require": "error",
161
- "node/no-path-concat": "error",
162
- "node/prefer-global/buffer": ["error", "never"],
163
- "node/prefer-global/process": ["error", "never"],
164
- "node/process-exit-as-throw": "error"
137
+ "@typescript-eslint/no-unused-vars": [
138
+ "error",
139
+ {
140
+ // Args after the last used will be reported
141
+ args: "after-used",
142
+ argsIgnorePattern: "^_",
143
+ caughtErrors: "all",
144
+ caughtErrorsIgnorePattern: "^_",
145
+ destructuredArrayIgnorePattern: "^_",
146
+ varsIgnorePattern: "^_",
147
+ ignoreRestSiblings: true
148
+ }
149
+ ],
150
+ "@typescript-eslint/no-redeclare": "error",
151
+ "@typescript-eslint/consistent-type-imports": [
152
+ "error",
153
+ {
154
+ prefer: "type-imports",
155
+ fixStyle: "separate-type-imports",
156
+ disallowTypeAnnotations: false
157
+ }
158
+ ],
159
+ "@typescript-eslint/no-empty-object-type": [
160
+ "error",
161
+ {
162
+ allowInterfaces: "always",
163
+ allowObjectTypes: "always"
164
+ }
165
+ ],
166
+ "@typescript-eslint/consistent-type-assertions": [
167
+ "error",
168
+ {
169
+ assertionStyle: "as",
170
+ objectLiteralTypeAssertions: "allow-as-parameter"
171
+ }
172
+ ],
173
+ "@typescript-eslint/prefer-as-const": "warn",
174
+ "@typescript-eslint/ban-types": "off",
175
+ "@typescript-eslint/camelcase": "off",
176
+ "@typescript-eslint/no-namespace": "off",
177
+ "@typescript-eslint/ban-ts-ignore": "off",
178
+ "@typescript-eslint/ban-ts-comment": "off",
179
+ "@typescript-eslint/no-explicit-any": "off",
180
+ "@typescript-eslint/no-empty-function": "off",
181
+ "@typescript-eslint/naming-convention": "off",
182
+ "@typescript-eslint/no-non-null-assertion": "off",
183
+ "@typescript-eslint/triple-slash-reference": "off",
184
+ "@typescript-eslint/no-parameter-properties": "off",
185
+ "@typescript-eslint/explicit-member-accessibility": "off",
186
+ "@typescript-eslint/explicit-function-return-type": "off",
187
+ "@typescript-eslint/explicit-module-boundary-types": "off",
188
+ "@typescript-eslint/consistent-indexed-object-style": "off"
189
+ },
190
+ // Overrides built-in rules
191
+ ...options.overrides
192
+ });
193
+ return configs;
194
+ };
195
+ var typescript = (options = {}) => [
196
+ ...typescriptCore(options),
197
+ {
198
+ name: "ntnyq/ts/dts",
199
+ files: [GLOB_DTS],
200
+ rules: {
201
+ "no-use-before-define": "off",
202
+ "no-restricted-syntax": "off",
203
+ "import/no-duplicates": "off",
204
+ "import/newline-after-import": "off"
205
+ }
206
+ },
207
+ {
208
+ name: "ntnyq/ts/test",
209
+ files: ["**/*.{spec,test}.ts?(x)"],
210
+ rules: {
211
+ "no-unused-expressions": "off",
212
+ "max-lines-per-function": "off"
165
213
  }
214
+ },
215
+ {
216
+ name: "ntnyq/ts/cjs",
217
+ files: [GLOB_JS],
218
+ rules: {}
166
219
  }
167
- ]);
220
+ ];
168
221
 
169
- // src/configs/jsdoc.ts
170
- var jsdoc = defineConfig([
222
+ // src/configs/vue.ts
223
+ var vue2Rules = {
224
+ ...default3.configs.base.rules,
225
+ ...default3.configs.essential.rules,
226
+ ...default3.configs["strongly-recommended"].rules,
227
+ ...default3.configs.recommended.rules
228
+ };
229
+ var vue3Rules = {
230
+ ...default3.configs.base.rules,
231
+ ...default3.configs["vue3-essential"].rules,
232
+ ...default3.configs["vue3-strongly-recommended"].rules,
233
+ ...default3.configs["vue3-recommended"].rules
234
+ };
235
+ var vue = (options = {}) => {
236
+ const isVue3 = options.vueVersion !== 2;
237
+ return [
238
+ ...tseslint.config({
239
+ name: "ntnyq/vue/ts",
240
+ files: [GLOB_VUE],
241
+ extends: typescriptCore()
242
+ }),
243
+ {
244
+ name: "ntnyq/vue/core",
245
+ files: [GLOB_VUE],
246
+ plugins: {
247
+ vue: default3,
248
+ "@typescript-eslint": tseslint.plugin
249
+ },
250
+ languageOptions: {
251
+ parser: parserVue,
252
+ parserOptions: {
253
+ parser: "@typescript-eslint/parser",
254
+ sourceType: "module",
255
+ extraFileExtensions: [".vue"],
256
+ ecmaFeatures: {
257
+ jsx: true
258
+ }
259
+ }
260
+ },
261
+ processor: default3.processors[".vue"],
262
+ rules: {
263
+ ...isVue3 ? vue3Rules : vue2Rules,
264
+ // OFF
265
+ "vue/no-v-html": "off",
266
+ "vue/require-prop-types": "off",
267
+ "vue/require-default-prop": "off",
268
+ "vue/multi-word-component-names": "off",
269
+ "vue/no-v-text-v-html-on-component": "off",
270
+ "vue/no-setup-props-reactivity-loss": "off",
271
+ "vue/html-self-closing": [
272
+ "error",
273
+ {
274
+ html: {
275
+ void: "always",
276
+ normal: "always",
277
+ component: "always"
278
+ },
279
+ svg: "always",
280
+ math: "always"
281
+ }
282
+ ],
283
+ "vue/block-tag-newline": [
284
+ "error",
285
+ {
286
+ singleline: "always",
287
+ multiline: "always"
288
+ }
289
+ ],
290
+ "vue/component-name-in-template-casing": [
291
+ "error",
292
+ "PascalCase",
293
+ {
294
+ // Force auto-import components to be PascalCase
295
+ registeredComponentsOnly: false,
296
+ ignores: ["slot", "component"]
297
+ }
298
+ ],
299
+ "vue/component-options-name-casing": ["error", "PascalCase"],
300
+ "vue/custom-event-name-casing": ["error", "camelCase"],
301
+ "vue/define-macros-order": [
302
+ "error",
303
+ {
304
+ order: ["defineProps", "defineEmits", "defineOptions", "defineSlots"]
305
+ }
306
+ ],
307
+ "vue/html-comment-content-spacing": [
308
+ "error",
309
+ "always",
310
+ {
311
+ exceptions: ["-"]
312
+ }
313
+ ],
314
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
315
+ "vue/no-useless-v-bind": "error",
316
+ "vue/padding-line-between-blocks": "error",
317
+ "vue/next-tick-style": ["error", "promise"],
318
+ "vue/array-bracket-spacing": ["error", "never"],
319
+ "vue/prefer-separate-static-class": "error",
320
+ "vue/no-constant-condition": "error",
321
+ "vue/prefer-true-attribute-shorthand": ["error", "always"],
322
+ "vue/prefer-define-options": "error",
323
+ "vue/valid-define-options": "error",
324
+ // TypeScript enhancements
325
+ "vue/define-emits-declaration": ["error", "type-literal"],
326
+ "vue/no-unused-emit-declarations": "error",
327
+ "vue/this-in-template": ["error", "never"],
328
+ "vue/arrow-spacing": ["error", { before: true, after: true }],
329
+ "vue/block-spacing": ["error", "always"],
330
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
331
+ "vue/comma-dangle": ["error", "always-multiline"],
332
+ "vue/comma-spacing": ["error", { before: false, after: true }],
333
+ "vue/comma-style": ["error", "last"],
334
+ "vue/dot-location": ["error", "property"],
335
+ "vue/dot-notation": ["error", { allowKeywords: true }],
336
+ "vue/eqeqeq": ["error", "smart"],
337
+ "vue/key-spacing": ["error", { beforeColon: false, afterColon: true }],
338
+ "vue/keyword-spacing": ["error", { before: true, after: true }],
339
+ "vue/no-empty-pattern": "error",
340
+ "vue/no-loss-of-precision": "error",
341
+ "vue/no-irregular-whitespace": "error",
342
+ "vue/no-use-v-else-with-v-for": "error",
343
+ "vue/require-typed-object-prop": "error",
344
+ "vue/no-extra-parens": ["error", "functions"],
345
+ "vue/no-restricted-syntax": [
346
+ "error",
347
+ "DebuggerStatement",
348
+ "LabeledStatement",
349
+ "WithStatement"
350
+ ],
351
+ "vue/no-sparse-arrays": "error",
352
+ "vue/no-deprecated-model-definition": [
353
+ "error",
354
+ {
355
+ allowVue3Compat: true
356
+ }
357
+ ],
358
+ "vue/object-curly-newline": [
359
+ "error",
360
+ {
361
+ multiline: true,
362
+ consistent: true
363
+ }
364
+ ],
365
+ "vue/no-static-inline-styles": [
366
+ "error",
367
+ {
368
+ allowBinding: true
369
+ }
370
+ ],
371
+ "vue/object-curly-spacing": ["error", "always"],
372
+ "vue/object-property-newline": [
373
+ "error",
374
+ {
375
+ allowMultiplePropertiesPerLine: true
376
+ }
377
+ ],
378
+ "vue/object-shorthand": [
379
+ "error",
380
+ "always",
381
+ {
382
+ ignoreConstructors: false,
383
+ avoidQuotes: true
384
+ }
385
+ ],
386
+ "vue/operator-linebreak": ["error", "before"],
387
+ "vue/prefer-template": "error",
388
+ "vue/prop-name-casing": ["error", "camelCase"],
389
+ "vue/quote-props": ["error", "consistent-as-needed"],
390
+ "vue/space-in-parens": ["error", "never"],
391
+ "vue/space-infix-ops": "error",
392
+ "vue/space-unary-ops": [
393
+ "error",
394
+ {
395
+ words: true,
396
+ nonwords: false
397
+ }
398
+ ],
399
+ "vue/template-curly-spacing": "error",
400
+ "vue/block-order": [
401
+ "error",
402
+ {
403
+ order: ["script", "template", "style"]
404
+ }
405
+ ],
406
+ "vue/attributes-order": [
407
+ "error",
408
+ {
409
+ order: [
410
+ "EVENTS",
411
+ // `@click="functionCall"`, `v-on="event"`
412
+ "TWO_WAY_BINDING",
413
+ // `v-model`
414
+ "OTHER_DIRECTIVES",
415
+ // `v-custom-directive`
416
+ "LIST_RENDERING",
417
+ // `v-for item in items`
418
+ "CONDITIONALS",
419
+ // `v-if`, `v-show`, `v-cloak`
420
+ "CONTENT",
421
+ // `v-text`, `v-html`
422
+ "SLOT",
423
+ // `v-slot`, `slot`
424
+ "UNIQUE",
425
+ // `ref`, `key`
426
+ "DEFINITION",
427
+ // `is`, `v-is`
428
+ "ATTR_DYNAMIC",
429
+ // `v-bind:prop="foo"`, `:prop="foo"`
430
+ // `OTHER_ATTR`, // `custom-prop="foo"`, `:prop="foo"`, `disabled`
431
+ "RENDER_MODIFIERS",
432
+ // `v-once`, `v-pre`
433
+ "GLOBAL",
434
+ // `id`
435
+ "ATTR_STATIC",
436
+ // `prop="foo", `static attributes
437
+ "ATTR_SHORTHAND_BOOL"
438
+ // `disabled`, prop shorthand
439
+ ],
440
+ alphabetical: false
441
+ }
442
+ ],
443
+ "vue/order-in-components": [
444
+ "error",
445
+ {
446
+ order: [
447
+ "el",
448
+ "name",
449
+ "key",
450
+ "parent",
451
+ "functional",
452
+ ["provide", "inject"],
453
+ ["delimiters", "comments"],
454
+ ["components", "directives", "filters"],
455
+ "extends",
456
+ "mixins",
457
+ "layout",
458
+ "middleware",
459
+ "validate",
460
+ "scrollToTop",
461
+ "transition",
462
+ "loading",
463
+ "inheritAttrs",
464
+ "model",
465
+ ["props", "propsData"],
466
+ "emits",
467
+ "setup",
468
+ "asyncData",
469
+ "computed",
470
+ "data",
471
+ "fetch",
472
+ "head",
473
+ "methods",
474
+ ["template", "render"],
475
+ "watch",
476
+ "watchQuery",
477
+ "LIFECYCLE_HOOKS",
478
+ "renderError",
479
+ "ROUTER_GUARDS"
480
+ ]
481
+ }
482
+ ],
483
+ "vue/max-attributes-per-line": [
484
+ "error",
485
+ {
486
+ singleline: 1,
487
+ multiline: 1
488
+ }
489
+ ],
490
+ // Overrides built-in rules
491
+ ...options.overrides
492
+ }
493
+ }
494
+ ];
495
+ };
496
+
497
+ // src/configs/yml.ts
498
+ var yml = (options = {}) => [
171
499
  {
172
- name: "ntnyq/jsdoc",
500
+ name: "ntnyq/yaml",
501
+ files: [GLOB_YAML],
502
+ languageOptions: {
503
+ parser: parserYaml
504
+ },
173
505
  plugins: {
174
- jsdoc: default7
506
+ yml: default4
175
507
  },
176
508
  rules: {
177
- "jsdoc/check-access": "warn",
178
- "jsdoc/check-param-names": "warn",
179
- "jsdoc/check-property-names": "warn",
180
- "jsdoc/check-types": "warn",
181
- "jsdoc/empty-tags": "warn",
182
- "jsdoc/implements-on-classes": "warn",
183
- "jsdoc/no-defaults": "warn",
184
- "jsdoc/no-multi-asterisks": "warn",
185
- "jsdoc/require-param-name": "warn",
186
- "jsdoc/require-property": "warn",
187
- "jsdoc/require-property-description": "warn",
188
- "jsdoc/require-property-name": "warn",
189
- "jsdoc/require-returns-check": "warn",
190
- "jsdoc/require-returns-description": "warn",
191
- "jsdoc/require-yields-check": "warn",
192
- "jsdoc/check-alignment": "warn",
193
- "jsdoc/multiline-blocks": "warn"
509
+ ...default4.configs.standard.rules,
510
+ ...default4.configs.prettier.rules,
511
+ "yml/no-empty-mapping-value": "off",
512
+ "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
513
+ // Overrides built-in rules
514
+ ...options.overrides
194
515
  }
195
516
  }
196
- ]);
517
+ ];
197
518
 
198
- // src/configs/imports.ts
199
- var imports = defineConfig([
519
+ // src/configs/node.ts
520
+ var node = (options = {}) => [
200
521
  {
201
- name: "ntnyq/imports",
522
+ name: "ntnyq/node",
202
523
  plugins: {
203
- import: default11
204
- },
205
- settings: {
206
- "import/resolver": {
207
- node: { extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts"] }
208
- }
524
+ node: default2
209
525
  },
210
526
  rules: {
211
- "import/no-unresolved": "off",
212
- "import/no-absolute-path": "off",
213
- "import/no-named-as-default-member": "off",
214
- "import/first": "error",
215
- "import/export": "error",
216
- "import/no-duplicates": "error",
217
- "import/no-mutable-exports": "error",
218
- "import/newline-after-import": "error",
219
- "import/order": [
220
- "error",
221
- {
222
- groups: [
223
- "builtin",
224
- "external",
225
- "internal",
226
- "parent",
227
- "sibling",
228
- "index",
229
- "object",
230
- "type"
231
- ],
232
- "newlines-between": "never",
233
- pathGroups: [{ pattern: "{{@,~}/,#}**", group: "internal" }],
234
- pathGroupsExcludedImportTypes: ["type"]
235
- }
236
- ]
527
+ "node/handle-callback-err": ["error", "^(err|error)$"],
528
+ "node/no-deprecated-api": "error",
529
+ "node/no-exports-assign": "error",
530
+ "node/no-new-require": "error",
531
+ "node/no-path-concat": "error",
532
+ "node/prefer-global/buffer": ["error", "never"],
533
+ "node/prefer-global/process": ["error", "never"],
534
+ "node/process-exit-as-throw": "error",
535
+ // Overrides built-in rules
536
+ ...options.overrides
237
537
  }
238
538
  }
239
- ]);
539
+ ];
240
540
 
241
- // src/configs/unicorn.ts
242
- var unicorn = defineConfig([
541
+ // src/configs/sort.ts
542
+ var sortPackageJson = () => [
243
543
  {
244
- name: "ntnyq/unicorn",
245
- plugins: {
246
- unicorn: default10
247
- },
544
+ name: "ntnyq/sort/package-json",
545
+ files: ["**/package.json"],
248
546
  rules: {
249
- // Disabled for now
250
- "unicorn/prefer-top-level-await": "off",
251
- "unicorn/explicit-length-check": "off",
252
- "unicorn/no-array-callback-reference": "off",
253
- "unicorn/error-message": "error",
254
- "unicorn/escape-case": "error",
255
- "unicorn/no-new-buffer": "error",
256
- "unicorn/number-literal-case": "error",
257
- "unicorn/prefer-includes": "error",
258
- "unicorn/prefer-type-error": "error",
259
- "unicorn/throw-new-error": "error",
260
- "unicorn/no-unnecessary-await": "error",
261
- "unicorn/switch-case-braces": ["error", "avoid"],
262
- "unicorn/no-typeof-undefined": "error",
263
- "unicorn/prefer-set-size": "error",
264
- "unicorn/better-regex": "error",
265
- "unicorn/prefer-regexp-test": "error",
266
- "unicorn/no-static-only-class": "error",
267
- "unicorn/no-zero-fractions": "error",
268
- "unicorn/custom-error-definition": "error",
269
- "unicorn/prefer-modern-math-apis": "error",
270
- "unicorn/new-for-builtins": "error",
271
- "unicorn/no-console-spaces": "error",
272
- "unicorn/no-for-loop": "error",
273
- "unicorn/no-hex-escape": "error",
274
- "unicorn/no-lonely-if": "error",
275
- "unicorn/prefer-keyboard-event-key": "error",
276
- "unicorn/prefer-math-trunc": "error",
277
- "unicorn/prefer-negative-index": "error",
278
- "unicorn/prefer-node-protocol": "error",
279
- "unicorn/prefer-number-properties": "error",
280
- "unicorn/prefer-optional-catch-binding": "error",
281
- "unicorn/prefer-prototype-methods": "error",
282
- "unicorn/prefer-reflect-apply": "error",
283
- "unicorn/catch-error-name": [
547
+ "jsonc/sort-keys": [
284
548
  "error",
285
549
  {
286
- name: "err",
287
- ignore: ["^_."]
288
- }
289
- ],
290
- "unicorn/prefer-date-now": "error",
291
- // String
292
- "unicorn/prefer-string-slice": "error",
293
- "unicorn/prefer-string-trim-start-end": "error",
294
- "unicorn/prefer-string-starts-ends-with": "error",
295
- // DOM
296
- "unicorn/prefer-add-event-listener": "error",
297
- "unicorn/no-invalid-remove-event-listener": "error",
298
- "unicorn/prefer-query-selector": "error",
299
- "unicorn/prefer-modern-dom-apis": "error",
300
- "unicorn/prefer-dom-node-append": "error",
301
- "unicorn/prefer-dom-node-dataset": "error",
302
- "unicorn/prefer-dom-node-remove": "error",
303
- "unicorn/prefer-dom-node-text-content": "error",
304
- // Array
305
- "unicorn/no-new-array": "error",
306
- "unicorn/no-instanceof-array": "error",
307
- "unicorn/no-array-push-push": "error",
308
- "unicorn/no-array-method-this-argument": "error",
309
- "unicorn/prefer-array-find": "error",
310
- "unicorn/prefer-array-some": "error",
311
- "unicorn/prefer-array-flat-map": "error",
312
- "unicorn/prefer-array-index-of": "error"
313
- }
314
- }
315
- ]);
316
-
317
- // src/configs/prettier.ts
318
- import prettierConfig from "eslint-config-prettier";
319
- var prettier = defineConfig([
320
- {
321
- name: "ntnyq/prettier",
322
- plugins: {
323
- prettier: default12
324
- },
325
- rules: {
326
- ...prettierConfig.rules,
327
- ...default12.configs.recommended.rules,
328
- "prettier/prettier": "warn"
329
- }
330
- },
331
- /**
332
- * Languages that prettier currently does not support
333
- */
334
- {
335
- name: "ntnyq/prettier/ignore",
336
- files: [GLOB_TOML],
337
- plugins: {
338
- prettier: default12
339
- },
340
- rules: {
341
- "prettier/prettier": "off"
342
- }
343
- }
344
- ]);
345
-
346
- // src/configs/comments.ts
347
- var comments = defineConfig([
348
- {
349
- name: "ntnyq/eslint-comments",
350
- plugins: {
351
- "@eslint-community/eslint-comments": default16
352
- },
353
- rules: {
354
- ...default16.configs.recommended.rules,
355
- "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }]
356
- }
357
- }
358
- ]);
359
-
360
- // src/configs/javascript.ts
361
- import globals from "globals";
362
- import jsConfig from "@eslint/js";
363
- var javascript = defineConfig([
364
- {
365
- name: "ntnyq/js/recommended",
366
- ...jsConfig.configs.recommended
367
- },
368
- {
369
- name: "ntnyq/js/core",
370
- languageOptions: {
371
- globals: {
372
- ...globals.browser,
373
- ...globals.es2021,
374
- ...globals.node
375
- },
376
- sourceType: "module"
377
- },
378
- rules: {
379
- // standard v17.0.0
380
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
381
- camelcase: [
382
- "error",
383
- {
384
- allow: ["^UNSAFE_"],
385
- properties: "never",
386
- ignoreGlobals: true
387
- }
388
- ],
389
- "constructor-super": "error",
390
- curly: ["error", "multi-line"],
391
- "default-case-last": "error",
392
- "dot-notation": ["error", { allowKeywords: true }],
393
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
394
- "no-array-constructor": "error",
395
- "no-async-promise-executor": "error",
396
- "no-caller": "error",
397
- "no-class-assign": "error",
398
- "no-compare-neg-zero": "error",
399
- "no-cond-assign": "error",
400
- "no-const-assign": "error",
401
- "no-constant-condition": ["error", { checkLoops: false }],
402
- "no-control-regex": "error",
403
- "no-debugger": "error",
404
- "no-delete-var": "error",
405
- "no-dupe-args": "error",
406
- "no-dupe-class-members": "error",
407
- "no-dupe-keys": "error",
408
- "no-duplicate-case": "error",
409
- "no-useless-backreference": "error",
410
- "no-empty": ["error", { allowEmptyCatch: true }],
411
- "no-empty-character-class": "error",
412
- "no-empty-pattern": "error",
413
- "no-eval": "error",
414
- "no-ex-assign": "error",
415
- "no-extend-native": "error",
416
- "no-extra-bind": "error",
417
- "no-extra-boolean-cast": "error",
418
- "no-fallthrough": "error",
419
- "no-func-assign": "error",
420
- "no-global-assign": "error",
421
- "no-implied-eval": "error",
422
- "no-import-assign": "error",
423
- "no-invalid-regexp": "error",
424
- "no-irregular-whitespace": "error",
425
- "no-iterator": "error",
426
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
427
- "no-lone-blocks": "error",
428
- "no-loss-of-precision": "error",
429
- "no-misleading-character-class": "error",
430
- "no-prototype-builtins": "error",
431
- "no-useless-catch": "error",
432
- "no-new": "error",
433
- "no-new-func": "error",
434
- "no-new-wrappers": "error",
435
- "no-obj-calls": "error",
436
- "no-octal": "error",
437
- "no-octal-escape": "error",
438
- "no-proto": "error",
439
- "no-redeclare": ["error", { builtinGlobals: false }],
440
- "no-regex-spaces": "error",
441
- "no-self-assign": ["error", { props: true }],
442
- "no-self-compare": "error",
443
- "no-sequences": "error",
444
- "no-shadow-restricted-names": "error",
445
- "no-sparse-arrays": "error",
446
- "no-template-curly-in-string": "error",
447
- "no-this-before-super": "error",
448
- "no-throw-literal": "error",
449
- "no-undef": "error",
450
- "no-undef-init": "error",
451
- "no-unexpected-multiline": "error",
452
- "no-unmodified-loop-condition": "error",
453
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
454
- "no-unreachable": "error",
455
- "no-unreachable-loop": "error",
456
- "no-unsafe-finally": "error",
457
- "no-unsafe-negation": "error",
458
- "no-unused-expressions": [
459
- "error",
460
- {
461
- allowShortCircuit: true,
462
- allowTernary: true,
463
- allowTaggedTemplates: true
464
- }
465
- ],
466
- "no-unused-vars": [
467
- "error",
468
- {
469
- args: "none",
470
- caughtErrors: "none",
471
- ignoreRestSiblings: true,
472
- vars: "all"
473
- }
474
- ],
475
- "no-useless-call": "error",
476
- "no-useless-computed-key": "error",
477
- "no-useless-constructor": "error",
478
- "no-useless-rename": "error",
479
- "no-useless-return": "error",
480
- "prefer-promise-reject-errors": "error",
481
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
482
- "symbol-description": "error",
483
- "unicode-bom": ["error", "never"],
484
- "use-isnan": [
485
- "error",
486
- {
487
- enforceForSwitchCase: true,
488
- enforceForIndexOf: true
489
- }
490
- ],
491
- "valid-typeof": ["error", { requireStringLiterals: true }],
492
- yoda: ["error", "never"],
493
- // es6+
494
- "no-var": "error",
495
- "prefer-rest-params": "error",
496
- "prefer-spread": "error",
497
- "prefer-template": "error",
498
- "no-empty-static-block": "error",
499
- "no-new-native-nonconstructor": "error",
500
- "prefer-const": [
501
- "error",
502
- {
503
- destructuring: "all",
504
- ignoreReadBeforeAssign: true
505
- }
506
- ],
507
- "prefer-arrow-callback": [
508
- "error",
550
+ pathPattern: "^$",
551
+ order: [
552
+ "publisher",
553
+ "name",
554
+ "displayName",
555
+ "preview",
556
+ "type",
557
+ "version",
558
+ "private",
559
+ "packageManager",
560
+ "description",
561
+ "keywords",
562
+ "license",
563
+ "author",
564
+ "homepage",
565
+ "repository",
566
+ "funding",
567
+ "exports",
568
+ "main",
569
+ "module",
570
+ "unpkg",
571
+ "jsdelivr",
572
+ // workaround for `type: "module"` with TS `moduleResolution: "node16"`
573
+ "types",
574
+ "typesVersions",
575
+ "bin",
576
+ "icon",
577
+ "files",
578
+ "sideEffects",
579
+ "scripts",
580
+ "peerDependencies",
581
+ "peerDependenciesMeta",
582
+ "dependencies",
583
+ "optionalDependencies",
584
+ "devDependencies",
585
+ "activationEvents",
586
+ "contributes",
587
+ "categories",
588
+ "engines",
589
+ "pnpm",
590
+ "overrides",
591
+ "resolutions",
592
+ "husky",
593
+ "prettier",
594
+ "nano-staged",
595
+ "lint-staged",
596
+ "eslintConfig"
597
+ ]
598
+ },
509
599
  {
510
- allowNamedFunctions: false,
511
- allowUnboundThis: true
512
- }
513
- ],
514
- "object-shorthand": [
515
- "error",
516
- "always",
600
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
601
+ order: { type: "asc" }
602
+ },
517
603
  {
518
- ignoreConstructors: false,
519
- avoidQuotes: true
520
- }
521
- ],
522
- // best-practice
523
- eqeqeq: ["error", "smart"],
524
- complexity: ["error", { max: 30 }],
525
- "array-callback-return": "error",
526
- "block-scoped-var": "error",
527
- "consistent-return": "off",
528
- "no-alert": "error",
529
- "no-case-declarations": "error",
530
- "no-multi-str": "error",
531
- "no-with": "error",
532
- "no-void": "error",
533
- "no-useless-escape": "off",
534
- "vars-on-top": "error",
535
- "require-await": "off",
536
- "no-return-assign": "off",
537
- "one-var": ["error", "never"],
538
- "max-params": ["error", { max: 5 }],
539
- "max-depth": ["error", { max: 5 }],
540
- "max-nested-callbacks": ["error", { max: 10 }],
541
- "max-lines": [
542
- "error",
604
+ order: { type: "asc" },
605
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
606
+ },
543
607
  {
544
- max: 1e3,
545
- skipComments: true,
546
- skipBlankLines: true
547
- }
548
- ],
549
- "max-lines-per-function": [
550
- "error",
608
+ pathPattern: "^exports.*$",
609
+ order: ["types", "import", "require", "default"]
610
+ },
551
611
  {
552
- max: 200,
553
- skipComments: true,
554
- skipBlankLines: true
555
- }
556
- ],
557
- "no-use-before-define": [
558
- "error",
612
+ pathPattern: "^scripts$",
613
+ order: { type: "asc" }
614
+ },
559
615
  {
560
- functions: false,
561
- classes: false,
562
- variables: true
616
+ order: [
617
+ // client hooks only
618
+ "pre-commit",
619
+ "prepare-commit-msg",
620
+ "commit-msg",
621
+ "post-commit",
622
+ "pre-rebase",
623
+ "post-rewrite",
624
+ "post-checkout",
625
+ "post-merge",
626
+ "pre-push",
627
+ "pre-auto-gc"
628
+ ],
629
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
563
630
  }
564
631
  ],
565
- "sort-imports": [
632
+ "jsonc/sort-array-values": [
566
633
  "error",
567
634
  {
568
- ignoreCase: false,
569
- ignoreDeclarationSort: true,
570
- ignoreMemberSort: false,
571
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
572
- allowSeparatedGroups: false
635
+ pathPattern: "^files$",
636
+ order: { type: "asc" }
573
637
  }
574
638
  ]
575
639
  }
576
- },
577
- {
578
- name: "ntnyq/js/script",
579
- files: ["**/scripts/*", "**/cli.*"],
580
- rules: {
581
- "no-console": "off"
582
- }
583
- },
584
- {
585
- name: "ntnyq/js/test",
586
- files: ["**/*.{test,spec}.js?(x)"],
587
- rules: {
588
- "no-unused-expressions": "off",
589
- "max-lines-per-function": "off"
590
- }
591
- }
592
- ]);
593
- var jsx = defineConfig([
594
- {
595
- name: "ntnyq/jsx",
596
- files: ["**/*.jsx"],
597
- languageOptions: {
598
- parserOptions: {
599
- ecmaFeatures: {
600
- jsx: true
601
- }
602
- }
603
- }
604
640
  }
605
- ]);
606
-
607
- // src/configs/typescript.ts
608
- var typescriptCore = tseslint.config({
609
- name: "ntnyq/ts/core",
610
- extends: [...tseslint.configs.recommended],
611
- files: [GLOB_TS, GLOB_TSX],
612
- languageOptions: {
613
- parser: tseslint.parser,
614
- parserOptions: {
615
- sourceType: "module"
616
- }
617
- },
618
- rules: {
619
- "@typescript-eslint/no-unused-vars": [
620
- "error",
621
- {
622
- // Args after the last used will be reported
623
- args: "after-used",
624
- argsIgnorePattern: "^_",
625
- caughtErrors: "all",
626
- caughtErrorsIgnorePattern: "^_",
627
- destructuredArrayIgnorePattern: "^_",
628
- varsIgnorePattern: "^_",
629
- ignoreRestSiblings: true
630
- }
631
- ],
632
- "@typescript-eslint/no-redeclare": "error",
633
- "@typescript-eslint/consistent-type-imports": [
634
- "error",
635
- {
636
- prefer: "type-imports",
637
- fixStyle: "separate-type-imports",
638
- disallowTypeAnnotations: false
639
- }
640
- ],
641
- "@typescript-eslint/no-empty-object-type": [
642
- "error",
643
- {
644
- allowInterfaces: "always",
645
- allowObjectTypes: "always"
646
- }
647
- ],
648
- "@typescript-eslint/consistent-type-assertions": [
649
- "error",
650
- {
651
- assertionStyle: "as",
652
- objectLiteralTypeAssertions: "allow-as-parameter"
653
- }
654
- ],
655
- "@typescript-eslint/prefer-as-const": "warn",
656
- "@typescript-eslint/ban-types": "off",
657
- "@typescript-eslint/camelcase": "off",
658
- "@typescript-eslint/no-namespace": "off",
659
- "@typescript-eslint/ban-ts-ignore": "off",
660
- "@typescript-eslint/ban-ts-comment": "off",
661
- "@typescript-eslint/no-explicit-any": "off",
662
- "@typescript-eslint/no-empty-function": "off",
663
- "@typescript-eslint/naming-convention": "off",
664
- "@typescript-eslint/no-non-null-assertion": "off",
665
- "@typescript-eslint/triple-slash-reference": "off",
666
- "@typescript-eslint/no-parameter-properties": "off",
667
- "@typescript-eslint/explicit-member-accessibility": "off",
668
- "@typescript-eslint/explicit-function-return-type": "off",
669
- "@typescript-eslint/explicit-module-boundary-types": "off",
670
- "@typescript-eslint/consistent-indexed-object-style": "off"
671
- }
672
- });
673
- var typescript = defineConfig([
674
- ...typescriptCore,
675
- {
676
- name: "ntnyq/ts/dts",
677
- files: [GLOB_DTS],
678
- rules: {
679
- "no-use-before-define": "off",
680
- "no-restricted-syntax": "off",
681
- "import/no-duplicates": "off",
682
- "import/newline-after-import": "off"
683
- }
684
- },
641
+ ];
642
+ var sortTsConfig = () => [
685
643
  {
686
- name: "ntnyq/ts/test",
687
- files: ["**/*.{spec,test}.ts?(x)"],
644
+ name: "ntnyq/sort/tsconfig",
645
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
688
646
  rules: {
689
- "no-unused-expressions": "off",
690
- "max-lines-per-function": "off"
647
+ "jsonc/sort-keys": [
648
+ "error",
649
+ {
650
+ order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
651
+ pathPattern: "^$"
652
+ },
653
+ {
654
+ order: [
655
+ /* Projects */
656
+ "incremental",
657
+ "composite",
658
+ "tsBuildInfoFile",
659
+ "disableSourceOfProjectReferenceRedirect",
660
+ "disableSolutionSearching",
661
+ "disableReferencedProjectLoad",
662
+ /* Language and Environment */
663
+ "target",
664
+ "lib",
665
+ "jsx",
666
+ "experimentalDecorators",
667
+ "emitDecoratorMetadata",
668
+ "jsxFactory",
669
+ "jsxFragmentFactory",
670
+ "jsxImportSource",
671
+ "reactNamespace",
672
+ "noLib",
673
+ "useDefineForClassFields",
674
+ "moduleDetection",
675
+ /* Modules */
676
+ "module",
677
+ "rootDir",
678
+ "moduleResolution",
679
+ "baseUrl",
680
+ "paths",
681
+ "rootDirs",
682
+ "typeRoots",
683
+ "types",
684
+ "allowUmdGlobalAccess",
685
+ "moduleSuffixes",
686
+ "allowImportingTsExtensions",
687
+ "resolvePackageJsonExports",
688
+ "resolvePackageJsonImports",
689
+ "customConditions",
690
+ "resolveJsonModule",
691
+ "allowArbitraryExtensions",
692
+ "noResolve",
693
+ /* JavaScript Support */
694
+ "allowJs",
695
+ "checkJs",
696
+ "maxNodeModuleJsDepth",
697
+ /* Emit */
698
+ "declaration",
699
+ "declarationMap",
700
+ "emitDeclarationOnly",
701
+ "sourceMap",
702
+ "inlineSourceMap",
703
+ "outFile",
704
+ "outDir",
705
+ "removeComments",
706
+ "noEmit",
707
+ "importHelpers",
708
+ "importsNotUsedAsValues",
709
+ "downlevelIteration",
710
+ "sourceRoot",
711
+ "mapRoot",
712
+ "inlineSources",
713
+ "emitBOM",
714
+ "newLine",
715
+ "stripInternal",
716
+ "noEmitHelpers",
717
+ "noEmitOnError",
718
+ "preserveConstEnums",
719
+ "declarationDir",
720
+ "preserveValueImports",
721
+ /* Interop Constraints */
722
+ "isolatedModules",
723
+ "verbatimModuleSyntax",
724
+ "allowSyntheticDefaultImports",
725
+ "esModuleInterop",
726
+ "preserveSymlinks",
727
+ "forceConsistentCasingInFileNames",
728
+ /* Type Checking */
729
+ "strict",
730
+ "strictBindCallApply",
731
+ "strictFunctionTypes",
732
+ "strictNullChecks",
733
+ "strictPropertyInitialization",
734
+ "allowUnreachableCode",
735
+ "allowUnusedLabels",
736
+ "alwaysStrict",
737
+ "exactOptionalPropertyTypes",
738
+ "noFallthroughCasesInSwitch",
739
+ "noImplicitAny",
740
+ "noImplicitOverride",
741
+ "noImplicitReturns",
742
+ "noImplicitThis",
743
+ "noPropertyAccessFromIndexSignature",
744
+ "noUncheckedIndexedAccess",
745
+ "noUnusedLocals",
746
+ "noUnusedParameters",
747
+ "useUnknownInCatchVariables",
748
+ /* Completeness */
749
+ "skipDefaultLibCheck",
750
+ "skipLibCheck"
751
+ ],
752
+ pathPattern: "^compilerOptions$"
753
+ }
754
+ ]
691
755
  }
692
- },
693
- {
694
- name: "ntnyq/ts/cjs",
695
- files: [GLOB_JS],
696
- rules: {}
697
756
  }
698
- ]);
699
-
700
- // src/configs/unusedImports.ts
701
- var unusedImports = defineConfig([
757
+ ];
758
+ var sortI18nLocale = () => [
702
759
  {
703
- name: "ntnyq/unused-imports",
704
- plugins: {
705
- "unused-imports": default15
706
- },
760
+ name: "ntnyq/sort/i18n-locale",
761
+ files: ["**/{locales,i18n}/*.json", "**/{locales,i18n}/*.y?(a)ml"],
707
762
  rules: {
708
- "@typescript-eslint/no-unused-vars": "off",
709
- "unused-imports/no-unused-imports": "error",
710
- "unused-imports/no-unused-vars": [
711
- "warn",
763
+ "jsonc/sort-keys": [
764
+ "error",
712
765
  {
713
- vars: "all",
714
- varsIgnorePattern: "^_",
715
- args: "after-used",
716
- argsIgnorePattern: "^_"
766
+ pathPattern: ".*",
767
+ order: { type: "asc" }
717
768
  }
718
769
  ]
719
770
  }
720
771
  }
721
- ]);
772
+ ];
722
773
 
723
- // src/configs/perfectionist.ts
724
- var perfectionist = defineConfig([
774
+ // src/configs/toml.ts
775
+ var toml = (options = {}) => [
725
776
  {
726
- name: "ntnyq/perfectionist",
777
+ name: "ntnyq/toml",
778
+ files: [GLOB_TOML],
779
+ languageOptions: {
780
+ parser: parserToml
781
+ },
727
782
  plugins: {
728
- perfectionist: default14
783
+ toml: default5
729
784
  },
730
785
  rules: {
731
- "perfectionist/sort-imports": [
732
- "error",
733
- {
734
- groups: [
735
- "builtin",
736
- "external",
737
- "internal",
738
- "internal-type",
739
- "parent",
740
- "parent-type",
741
- "sibling",
742
- "sibling-type",
743
- "index",
744
- "index-type",
745
- "object",
746
- "type",
747
- "side-effect",
748
- "side-effect-style"
749
- ],
750
- internalPattern: ["~/**", "@/**", "#**"],
751
- newlinesBetween: "ignore"
752
- }
753
- ],
754
- "perfectionist/sort-named-exports": ["warn", { groupKind: "values-first" }],
755
- "perfectionist/sort-named-imports": ["warn", { groupKind: "values-first" }]
786
+ "toml/comma-style": "error",
787
+ "toml/keys-order": "error",
788
+ "toml/no-space-dots": "error",
789
+ "toml/no-unreadable-number-separator": "error",
790
+ "toml/precision-of-fractional-seconds": "error",
791
+ "toml/precision-of-integer": "error",
792
+ "toml/tables-order": "error",
793
+ "toml/indent": ["error", 2],
794
+ "toml/vue-custom-block/no-parsing-error": "error",
795
+ "toml/array-bracket-newline": "error",
796
+ "toml/array-bracket-spacing": ["error", "never"],
797
+ "toml/array-element-newline": ["error", "never"],
798
+ "toml/inline-table-curly-spacing": "error",
799
+ "toml/key-spacing": "error",
800
+ "toml/padding-line-between-pairs": "error",
801
+ "toml/padding-line-between-tables": "error",
802
+ "toml/quoted-keys": "error",
803
+ "toml/spaced-comment": "error",
804
+ "toml/table-bracket-spacing": "error",
805
+ // Overrides built-in rules
806
+ ...options.overrides
756
807
  }
757
808
  }
758
- ]);
759
-
760
- // src/configs/regexp.ts
761
- var regexp = defineConfig([
762
- /**
763
- * https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/rules/recommended.ts
764
- */
765
- {
766
- name: "ntnyq/regexp",
767
- ...pluginRegexp.configs["flat/recommended"]
768
- }
769
- ]);
809
+ ];
770
810
 
771
- // src/configs/unocss.ts
772
- var unocss = defineConfig([
811
+ // src/configs/antfu.ts
812
+ var antfu = (options = {}) => [
773
813
  {
774
- name: "ntnyq/unocss",
814
+ name: "ntnyq/antfu",
775
815
  plugins: {
776
- unocss: default8
816
+ antfu: default7
777
817
  },
778
818
  rules: {
779
- "unocss/order": "error",
780
- // We don't use this
781
- "unocss/order-attributify": "off"
819
+ // required `object-curly-newline` to be disabled
820
+ // 'antfu/consistent-list-newline': 'error',
821
+ "antfu/import-dedupe": "error",
822
+ "antfu/top-level-function": "error",
823
+ ...options.overrides
782
824
  }
783
825
  }
784
- ]);
785
-
786
- // src/configs/command.ts
787
- import createCommandPlugin from "eslint-plugin-command/config";
788
- var command = defineConfig([createCommandPlugin()]);
826
+ ];
789
827
 
790
- // src/configs/vitest.ts
791
- var vitest = defineConfig([
828
+ // src/configs/jsdoc.ts
829
+ var jsdoc = (options = {}) => [
792
830
  {
793
- name: "ntnyq/test",
831
+ name: "ntnyq/jsdoc",
794
832
  plugins: {
795
- vitest: default9
833
+ jsdoc: default8
796
834
  },
797
- files: [GLOB_TEST],
798
835
  rules: {
799
- ...default9.configs.recommended.rules
836
+ "jsdoc/check-access": "warn",
837
+ "jsdoc/check-param-names": "warn",
838
+ "jsdoc/check-property-names": "warn",
839
+ "jsdoc/check-types": "warn",
840
+ "jsdoc/empty-tags": "warn",
841
+ "jsdoc/implements-on-classes": "warn",
842
+ "jsdoc/no-defaults": "warn",
843
+ "jsdoc/no-multi-asterisks": "warn",
844
+ "jsdoc/require-param-name": "warn",
845
+ "jsdoc/require-property": "warn",
846
+ "jsdoc/require-property-description": "warn",
847
+ "jsdoc/require-property-name": "warn",
848
+ "jsdoc/require-returns-check": "warn",
849
+ "jsdoc/require-returns-description": "warn",
850
+ "jsdoc/require-yields-check": "warn",
851
+ "jsdoc/check-alignment": "warn",
852
+ "jsdoc/multiline-blocks": "warn",
853
+ // Overrides built-in rules
854
+ ...options.overrides
800
855
  }
801
856
  }
802
- ]);
857
+ ];
803
858
 
804
- // src/configs/vue.ts
805
- import process2 from "node:process";
806
- import { getPackageInfoSync } from "local-pkg";
807
- function getVueVersion() {
808
- const pkg = getPackageInfoSync("vue", { paths: [process2.cwd()] });
809
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
810
- return +pkg.version[0];
811
- }
812
- return 3;
813
- }
814
- var isVue3 = getVueVersion() === 3;
815
- var vue2Rules = {
816
- ...default3.configs.base.rules,
817
- ...default3.configs.essential.rules,
818
- ...default3.configs["strongly-recommended"].rules,
819
- ...default3.configs.recommended.rules
820
- };
821
- var vue3Rules = {
822
- ...default3.configs.base.rules,
823
- ...default3.configs["vue3-essential"].rules,
824
- ...default3.configs["vue3-strongly-recommended"].rules,
825
- ...default3.configs["vue3-recommended"].rules
826
- };
827
- var vue = defineConfig([
828
- ...tseslint.config({
829
- name: "ntnyq/vue/ts",
830
- files: [GLOB_VUE],
831
- // TODO: Remove this when `typescript-eslint` is aligned with `eslint`
832
- // @ts-expect-error - `typescript-eslint` is not aligned with eslint
833
- extends: typescriptCore
834
- }),
859
+ // src/configs/jsonc.ts
860
+ var jsonc = (options = {}) => [
835
861
  {
836
- name: "ntnyq/vue/core",
837
- files: [GLOB_VUE],
862
+ name: "ntnyq/jsonc",
863
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
838
864
  plugins: {
839
- vue: default3,
840
- "@typescript-eslint": tseslint.plugin
865
+ jsonc: default9
841
866
  },
842
867
  languageOptions: {
843
- parser: parserVue,
844
- parserOptions: {
845
- parser: "@typescript-eslint/parser",
846
- sourceType: "module",
847
- extraFileExtensions: [".vue"],
848
- ecmaFeatures: {
849
- jsx: true
850
- }
851
- }
868
+ parser: parserJsonc
852
869
  },
853
- processor: default3.processors[".vue"],
854
870
  rules: {
855
- ...isVue3 ? vue3Rules : vue2Rules,
856
- // OFF
857
- "vue/no-v-html": "off",
858
- "vue/require-prop-types": "off",
859
- "vue/require-default-prop": "off",
860
- "vue/multi-word-component-names": "off",
861
- "vue/no-setup-props-reactivity-loss": "off",
862
- "vue/html-self-closing": [
863
- "error",
864
- {
865
- html: {
866
- void: "always",
867
- normal: "always",
868
- component: "always"
869
- },
870
- svg: "always",
871
- math: "always"
872
- }
873
- ],
874
- "vue/block-tag-newline": [
875
- "error",
876
- {
877
- singleline: "always",
878
- multiline: "always"
879
- }
880
- ],
881
- "vue/component-name-in-template-casing": [
882
- "error",
883
- "PascalCase",
884
- {
885
- // Force auto-import components to be PascalCase
886
- registeredComponentsOnly: false,
887
- ignores: ["slot", "component"]
888
- }
889
- ],
890
- "vue/component-options-name-casing": ["error", "PascalCase"],
891
- "vue/custom-event-name-casing": ["error", "camelCase"],
892
- "vue/define-macros-order": [
893
- "error",
894
- {
895
- order: ["defineProps", "defineEmits", "defineOptions", "defineSlots"]
896
- }
897
- ],
898
- "vue/html-comment-content-spacing": [
899
- "error",
900
- "always",
901
- {
902
- exceptions: ["-"]
903
- }
904
- ],
905
- "vue/array-bracket-spacing": ["error", "never"],
906
- "vue/arrow-spacing": ["error", { before: true, after: true }],
907
- "vue/block-spacing": ["error", "always"],
908
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
909
- "vue/comma-dangle": ["error", "always-multiline"],
910
- "vue/comma-spacing": ["error", { before: false, after: true }],
911
- "vue/comma-style": ["error", "last"],
912
- "vue/dot-location": ["error", "property"],
913
- "vue/dot-notation": ["error", { allowKeywords: true }],
914
- "vue/eqeqeq": ["error", "smart"],
915
- "vue/key-spacing": ["error", { beforeColon: false, afterColon: true }],
916
- "vue/keyword-spacing": ["error", { before: true, after: true }],
917
- "vue/no-empty-pattern": "error",
918
- "vue/no-loss-of-precision": "error",
919
- "vue/no-irregular-whitespace": "error",
920
- "vue/no-use-v-else-with-v-for": "error",
921
- "vue/require-typed-object-prop": "error",
922
- "vue/no-extra-parens": ["error", "functions"],
923
- "vue/no-restricted-syntax": [
924
- "error",
925
- "DebuggerStatement",
926
- "LabeledStatement",
927
- "WithStatement"
928
- ],
929
- "vue/no-sparse-arrays": "error",
930
- "vue/no-deprecated-model-definition": [
871
+ ...default9.configs["recommended-with-jsonc"].rules,
872
+ "jsonc/array-bracket-spacing": ["error", "never"],
873
+ "jsonc/comma-dangle": ["error", "never"],
874
+ "jsonc/comma-style": ["error", "last"],
875
+ "jsonc/indent": ["error", 2],
876
+ "jsonc/key-spacing": [
931
877
  "error",
932
878
  {
933
- allowVue3Compat: true
879
+ beforeColon: false,
880
+ afterColon: true
934
881
  }
935
882
  ],
936
- "vue/object-curly-newline": [
883
+ "jsonc/no-octal-escape": "error",
884
+ "jsonc/object-curly-newline": [
937
885
  "error",
938
886
  {
939
887
  multiline: true,
940
888
  consistent: true
941
889
  }
942
890
  ],
943
- "vue/no-static-inline-styles": [
944
- "error",
945
- {
946
- allowBinding: true
947
- }
948
- ],
949
- "vue/object-curly-spacing": ["error", "always"],
950
- "vue/object-property-newline": [
891
+ "jsonc/object-curly-spacing": ["error", "always"],
892
+ "jsonc/object-property-newline": [
951
893
  "error",
952
894
  {
953
895
  allowMultiplePropertiesPerLine: true
954
896
  }
955
897
  ],
956
- "vue/object-shorthand": [
957
- "error",
958
- "always",
959
- {
960
- ignoreConstructors: false,
961
- avoidQuotes: true
962
- }
963
- ],
964
- "vue/operator-linebreak": ["error", "before"],
965
- "vue/prefer-template": "error",
966
- "vue/prop-name-casing": ["error", "camelCase"],
967
- "vue/quote-props": ["error", "consistent-as-needed"],
968
- "vue/space-in-parens": ["error", "never"],
969
- "vue/space-infix-ops": "error",
970
- "vue/space-unary-ops": [
971
- "error",
972
- {
973
- words: true,
974
- nonwords: false
975
- }
976
- ],
977
- "vue/template-curly-spacing": "error",
978
- "vue/block-order": [
979
- "error",
980
- {
981
- order: ["script", "template", "style"]
982
- }
983
- ],
984
- "vue/attributes-order": [
985
- "error",
986
- {
987
- order: [
988
- "EVENTS",
989
- // `@click="functionCall"`, `v-on="event"`
990
- "TWO_WAY_BINDING",
991
- // `v-model`
992
- "OTHER_DIRECTIVES",
993
- // `v-custom-directive`
994
- "LIST_RENDERING",
995
- // `v-for item in items`
996
- "CONDITIONALS",
997
- // `v-if`, `v-show`, `v-cloak`
998
- "CONTENT",
999
- // `v-text`, `v-html`
1000
- "SLOT",
1001
- // `v-slot`, `slot`
1002
- "UNIQUE",
1003
- // `ref`, `key`
1004
- "DEFINITION",
1005
- // `is`, `v-is`
1006
- "ATTR_DYNAMIC",
1007
- // `v-bind:prop="foo"`, `:prop="foo"`
1008
- // `OTHER_ATTR`, // `custom-prop="foo"`, `:prop="foo"`, `disabled`
1009
- "RENDER_MODIFIERS",
1010
- // `v-once`, `v-pre`
1011
- "GLOBAL",
1012
- // `id`
1013
- "ATTR_STATIC",
1014
- // `prop="foo", `static attributes
1015
- "ATTR_SHORTHAND_BOOL"
1016
- // `disabled`, prop shorthand
1017
- ],
1018
- alphabetical: false
1019
- }
1020
- ],
1021
- "vue/order-in-components": [
1022
- "error",
1023
- {
1024
- order: [
1025
- "el",
1026
- "name",
1027
- "key",
1028
- "parent",
1029
- "functional",
1030
- ["provide", "inject"],
1031
- ["delimiters", "comments"],
1032
- ["components", "directives", "filters"],
1033
- "extends",
1034
- "mixins",
1035
- "layout",
1036
- "middleware",
1037
- "validate",
1038
- "scrollToTop",
1039
- "transition",
1040
- "loading",
1041
- "inheritAttrs",
1042
- "model",
1043
- ["props", "propsData"],
1044
- "emits",
1045
- "setup",
1046
- "asyncData",
1047
- "computed",
1048
- "data",
1049
- "fetch",
1050
- "head",
1051
- "methods",
1052
- ["template", "render"],
1053
- "watch",
1054
- "watchQuery",
1055
- "LIFECYCLE_HOOKS",
1056
- "renderError",
1057
- "ROUTER_GUARDS"
1058
- ]
1059
- }
1060
- ],
1061
- "vue/max-attributes-per-line": [
1062
- "error",
1063
- {
1064
- singleline: 1,
1065
- multiline: 1
1066
- }
1067
- ]
898
+ // Overrides built-in rules
899
+ ...options.overrides
900
+ }
901
+ }
902
+ ];
903
+
904
+ // src/configs/regexp.ts
905
+ var regexp = (options = {}) => [
906
+ /**
907
+ * https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/rules/recommended.ts
908
+ */
909
+ {
910
+ name: "ntnyq/regexp",
911
+ ...pluginRegexp.configs["flat/recommended"],
912
+ // Overrides built-in rules
913
+ ...options.overrides
914
+ }
915
+ ];
916
+
917
+ // src/configs/unocss.ts
918
+ var unocss = (options = {}) => [
919
+ {
920
+ name: "ntnyq/unocss",
921
+ plugins: {
922
+ unocss: default10
923
+ },
924
+ rules: {
925
+ "unocss/order": "error",
926
+ // We don't use this
927
+ "unocss/order-attributify": "off",
928
+ // Overrides built-in rules
929
+ ...options.overrides
1068
930
  }
1069
931
  }
1070
- ]);
932
+ ];
1071
933
 
1072
- // src/configs/yml.ts
1073
- var yml = defineConfig([
934
+ // src/configs/vitest.ts
935
+ var vitest = (options = {}) => [
1074
936
  {
1075
- name: "ntnyq/yaml",
1076
- files: [GLOB_YAML],
1077
- languageOptions: {
1078
- parser: parserYaml
1079
- },
937
+ name: "ntnyq/vitest",
1080
938
  plugins: {
1081
- yml: default4
939
+ vitest: default11
1082
940
  },
941
+ files: [GLOB_TEST],
1083
942
  rules: {
1084
- ...default4.configs.standard.rules,
1085
- ...default4.configs.prettier.rules,
1086
- "yml/no-empty-mapping-value": "off",
1087
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }]
943
+ ...default11.configs.recommended.rules,
944
+ // Overrides built-in rules
945
+ ...options.overrides
1088
946
  }
1089
947
  }
1090
- ]);
948
+ ];
1091
949
 
1092
- // src/configs/toml.ts
1093
- var toml = defineConfig([
950
+ // src/configs/command.ts
951
+ import createCommandPlugin from "eslint-plugin-command/config";
952
+ var command = (options = {}) => [
1094
953
  {
1095
- name: "ntnyq/toml",
1096
- files: [GLOB_TOML],
1097
- languageOptions: {
1098
- parser: parserToml
1099
- },
954
+ ...createCommandPlugin(options),
955
+ name: "ntnyq/command"
956
+ }
957
+ ];
958
+
959
+ // src/configs/ignores.ts
960
+ var ignores = (customIgnores = []) => [
961
+ {
962
+ name: "ntnyq/ignores",
963
+ ignores: [
964
+ ...GLOB_EXCLUDE,
965
+ // Overrides built-in ignores
966
+ ...customIgnores
967
+ ]
968
+ }
969
+ ];
970
+
971
+ // src/configs/imports.ts
972
+ var imports = (options = {}) => [
973
+ {
974
+ name: "ntnyq/imports",
1100
975
  plugins: {
1101
- toml: default5
976
+ import: default12
977
+ },
978
+ settings: {
979
+ "import/resolver": {
980
+ node: { extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts"] }
981
+ }
1102
982
  },
1103
983
  rules: {
1104
- "toml/comma-style": "error",
1105
- "toml/keys-order": "error",
1106
- "toml/no-space-dots": "error",
1107
- "toml/no-unreadable-number-separator": "error",
1108
- "toml/precision-of-fractional-seconds": "error",
1109
- "toml/precision-of-integer": "error",
1110
- "toml/tables-order": "error",
1111
- "toml/indent": ["error", 2],
1112
- "toml/vue-custom-block/no-parsing-error": "error",
1113
- "toml/array-bracket-newline": "error",
1114
- "toml/array-bracket-spacing": ["error", "never"],
1115
- "toml/array-element-newline": ["error", "never"],
1116
- "toml/inline-table-curly-spacing": "error",
1117
- "toml/key-spacing": "error",
1118
- "toml/padding-line-between-pairs": "error",
1119
- "toml/padding-line-between-tables": "error",
1120
- "toml/quoted-keys": "error",
1121
- "toml/spaced-comment": "error",
1122
- "toml/table-bracket-spacing": "error"
984
+ "import/no-unresolved": "off",
985
+ "import/no-absolute-path": "off",
986
+ "import/no-named-as-default-member": "off",
987
+ "import/no-named-default": "off",
988
+ // disabled in favor or `perfectionist/sort-imports`
989
+ "import/order": "off",
990
+ "import/first": "error",
991
+ "import/export": "error",
992
+ "import/no-self-import": "error",
993
+ "import/no-duplicates": "error",
994
+ "import/no-mutable-exports": "error",
995
+ "import/newline-after-import": "error",
996
+ // Overrides built-in rules
997
+ ...options.overrides
1123
998
  }
1124
999
  }
1125
- ]);
1000
+ ];
1126
1001
 
1127
- // src/configs/sort.ts
1128
- var sortPackageJson = defineConfig([
1002
+ // src/configs/unicorn.ts
1003
+ var unicorn = (options = {}) => [
1129
1004
  {
1130
- name: "ntnyq/sort/package-json",
1131
- files: ["**/package.json"],
1005
+ name: "ntnyq/unicorn",
1006
+ plugins: {
1007
+ unicorn: default13
1008
+ },
1132
1009
  rules: {
1133
- "jsonc/sort-keys": [
1010
+ // Disabled for now
1011
+ "unicorn/better-regex": "off",
1012
+ "unicorn/prefer-top-level-await": "off",
1013
+ "unicorn/explicit-length-check": "off",
1014
+ "unicorn/no-array-callback-reference": "off",
1015
+ "unicorn/error-message": "error",
1016
+ "unicorn/escape-case": "error",
1017
+ "unicorn/no-new-buffer": "error",
1018
+ "unicorn/number-literal-case": "error",
1019
+ "unicorn/prefer-includes": "error",
1020
+ "unicorn/prefer-type-error": "error",
1021
+ "unicorn/throw-new-error": "error",
1022
+ "unicorn/no-unnecessary-await": "error",
1023
+ "unicorn/switch-case-braces": ["error", "avoid"],
1024
+ "unicorn/no-typeof-undefined": "error",
1025
+ "unicorn/prefer-set-size": "error",
1026
+ "unicorn/prefer-regexp-test": "error",
1027
+ "unicorn/no-static-only-class": "error",
1028
+ "unicorn/no-zero-fractions": "error",
1029
+ "unicorn/custom-error-definition": "error",
1030
+ "unicorn/prefer-modern-math-apis": "error",
1031
+ "unicorn/new-for-builtins": "error",
1032
+ "unicorn/no-console-spaces": "error",
1033
+ "unicorn/no-for-loop": "error",
1034
+ "unicorn/no-hex-escape": "error",
1035
+ "unicorn/no-lonely-if": "error",
1036
+ "unicorn/prefer-keyboard-event-key": "error",
1037
+ "unicorn/prefer-math-trunc": "error",
1038
+ "unicorn/prefer-negative-index": "error",
1039
+ "unicorn/prefer-node-protocol": "error",
1040
+ "unicorn/prefer-number-properties": "error",
1041
+ "unicorn/prefer-optional-catch-binding": "error",
1042
+ "unicorn/prefer-prototype-methods": "error",
1043
+ "unicorn/prefer-reflect-apply": "error",
1044
+ "unicorn/catch-error-name": [
1134
1045
  "error",
1135
1046
  {
1136
- pathPattern: "^$",
1137
- order: [
1138
- "publisher",
1139
- "name",
1140
- "displayName",
1141
- "type",
1142
- "version",
1143
- "private",
1144
- "packageManager",
1145
- "description",
1146
- "keywords",
1147
- "license",
1148
- "author",
1149
- "homepage",
1150
- "repository",
1151
- "funding",
1152
- "exports",
1153
- "main",
1154
- "module",
1155
- "unpkg",
1156
- "jsdelivr",
1157
- // workaround for `type: "module"` with TS `moduleResolution: "node16"`
1158
- "types",
1159
- "typesVersions",
1160
- "bin",
1161
- "icon",
1162
- "files",
1163
- "sideEffects",
1164
- "scripts",
1165
- "peerDependencies",
1166
- "peerDependenciesMeta",
1167
- "dependencies",
1168
- "optionalDependencies",
1169
- "devDependencies",
1170
- "activationEvents",
1171
- "contributes",
1172
- "categories",
1173
- "engines",
1174
- "pnpm",
1175
- "overrides",
1176
- "resolutions",
1177
- "husky",
1178
- "prettier",
1179
- "nano-staged",
1180
- "lint-staged",
1181
- "eslintConfig"
1182
- ]
1183
- },
1184
- {
1185
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
1186
- order: { type: "asc" }
1187
- },
1188
- {
1189
- order: { type: "asc" },
1190
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1191
- },
1192
- {
1193
- pathPattern: "^exports.*$",
1194
- order: ["types", "import", "require", "default"]
1195
- },
1196
- {
1197
- pathPattern: "^scripts$",
1198
- order: { type: "asc" }
1199
- },
1200
- {
1201
- order: [
1202
- // client hooks only
1203
- "pre-commit",
1204
- "prepare-commit-msg",
1205
- "commit-msg",
1206
- "post-commit",
1207
- "pre-rebase",
1208
- "post-rewrite",
1209
- "post-checkout",
1210
- "post-merge",
1211
- "pre-push",
1212
- "pre-auto-gc"
1213
- ],
1214
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1047
+ name: "err",
1048
+ ignore: ["^_."]
1215
1049
  }
1216
1050
  ],
1217
- "jsonc/sort-array-values": [
1218
- "error",
1219
- {
1220
- pathPattern: "^files$",
1221
- order: { type: "asc" }
1222
- }
1223
- ]
1051
+ "unicorn/prefer-date-now": "error",
1052
+ // String
1053
+ "unicorn/prefer-string-slice": "error",
1054
+ "unicorn/prefer-string-trim-start-end": "error",
1055
+ "unicorn/prefer-string-starts-ends-with": "error",
1056
+ // DOM
1057
+ "unicorn/prefer-add-event-listener": "error",
1058
+ "unicorn/no-invalid-remove-event-listener": "error",
1059
+ "unicorn/prefer-query-selector": "error",
1060
+ "unicorn/prefer-modern-dom-apis": "error",
1061
+ "unicorn/prefer-dom-node-append": "error",
1062
+ "unicorn/prefer-dom-node-dataset": "error",
1063
+ "unicorn/prefer-dom-node-remove": "error",
1064
+ "unicorn/prefer-dom-node-text-content": "error",
1065
+ // Array
1066
+ "unicorn/no-new-array": "error",
1067
+ "unicorn/no-instanceof-array": "error",
1068
+ "unicorn/no-array-push-push": "error",
1069
+ "unicorn/no-array-method-this-argument": "error",
1070
+ "unicorn/prefer-array-find": "error",
1071
+ "unicorn/prefer-array-some": "error",
1072
+ "unicorn/prefer-array-flat-map": "error",
1073
+ "unicorn/prefer-array-index-of": "error",
1074
+ // Overrides built-in rules
1075
+ ...options.overrides
1076
+ }
1077
+ }
1078
+ ];
1079
+
1080
+ // src/configs/comments.ts
1081
+ var comments = (options = {}) => [
1082
+ {
1083
+ name: "ntnyq/eslint-comments",
1084
+ plugins: {
1085
+ "@eslint-community/eslint-comments": default17
1086
+ },
1087
+ rules: {
1088
+ ...default17.configs.recommended.rules,
1089
+ "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
1090
+ // Overrides built-in rules
1091
+ ...options.overrides
1092
+ }
1093
+ }
1094
+ ];
1095
+
1096
+ // src/configs/markdown.ts
1097
+ var markdown = (options = {}) => {
1098
+ if (!Array.isArray(default6.configs?.processor)) return [];
1099
+ return [
1100
+ ...default6.configs.processor.map((config) => ({
1101
+ ...config,
1102
+ name: `ntnyq/${config.name}`
1103
+ })),
1104
+ {
1105
+ name: "ntnyq/markdown/disabled/code-blocks",
1106
+ files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
1107
+ rules: {
1108
+ "no-undef": "off",
1109
+ "no-alert": "off",
1110
+ "no-console": "off",
1111
+ "no-unused-vars": "off",
1112
+ "no-unused-expressions": "off",
1113
+ "no-restricted-imports": "off",
1114
+ "node/prefer-global/buffer": "off",
1115
+ "node/prefer-global/process": "off",
1116
+ "import/no-unresolved": "off",
1117
+ "unused-imports/no-unused-imports": "off",
1118
+ "unused-imports/no-unused-vars": "off",
1119
+ "@typescript-eslint/comma-dangle": "off",
1120
+ "@typescript-eslint/no-redeclare": "off",
1121
+ "@typescript-eslint/no-namespace": "off",
1122
+ "@typescript-eslint/no-unused-vars": "off",
1123
+ "@typescript-eslint/no-require-imports": "off",
1124
+ "@typescript-eslint/no-extraneous-class": "off",
1125
+ "@typescript-eslint/no-use-before-define": "off",
1126
+ "@typescript-eslint/no-unused-expressions": "off",
1127
+ "@typescript-eslint/consistent-type-imports": "off",
1128
+ // Overrides built-in rules
1129
+ ...options.overrides
1130
+ }
1131
+ }
1132
+ ];
1133
+ };
1134
+
1135
+ // src/configs/prettier.ts
1136
+ var prettier = (options = {}) => [
1137
+ {
1138
+ name: "ntnyq/prettier",
1139
+ plugins: {
1140
+ prettier: default14
1141
+ },
1142
+ rules: {
1143
+ "vue/array-bracket-newline": "off",
1144
+ "vue/array-bracket-spacing": "off",
1145
+ "vue/array-element-newline": "off",
1146
+ "vue/arrow-spacing": "off",
1147
+ "vue/block-spacing": "off",
1148
+ "vue/block-tag-newline": "off",
1149
+ "vue/brace-style": "off",
1150
+ "vue/comma-dangle": "off",
1151
+ "vue/comma-spacing": "off",
1152
+ "vue/comma-style": "off",
1153
+ "vue/dot-location": "off",
1154
+ "vue/func-call-spacing": "off",
1155
+ "vue/html-closing-bracket-newline": "off",
1156
+ "vue/html-closing-bracket-spacing": "off",
1157
+ "vue/html-end-tags": "off",
1158
+ "vue/html-indent": "off",
1159
+ "vue/html-quotes": "off",
1160
+ "vue/key-spacing": "off",
1161
+ "vue/keyword-spacing": "off",
1162
+ "vue/max-attributes-per-line": "off",
1163
+ "vue/multiline-html-element-content-newline": "off",
1164
+ "vue/multiline-ternary": "off",
1165
+ "vue/mustache-interpolation-spacing": "off",
1166
+ "vue/no-extra-parens": "off",
1167
+ "vue/no-multi-spaces": "off",
1168
+ "vue/no-spaces-around-equal-signs-in-attribute": "off",
1169
+ "vue/object-curly-newline": "off",
1170
+ "vue/object-curly-spacing": "off",
1171
+ "vue/object-property-newline": "off",
1172
+ "vue/operator-linebreak": "off",
1173
+ "vue/quote-props": "off",
1174
+ "vue/script-indent": "off",
1175
+ "vue/singleline-html-element-content-newline": "off",
1176
+ "vue/space-in-parens": "off",
1177
+ "vue/space-infix-ops": "off",
1178
+ "vue/space-unary-ops": "off",
1179
+ "vue/template-curly-spacing": "off",
1180
+ ...default14.configs.recommended.rules,
1181
+ "prettier/prettier": options.level || "warn",
1182
+ // Overrides built-in rules
1183
+ ...options.overrides
1184
+ }
1185
+ },
1186
+ /**
1187
+ * Languages that prettier currently does not support
1188
+ */
1189
+ {
1190
+ name: "ntnyq/prettier/disabled",
1191
+ files: [GLOB_TOML],
1192
+ plugins: {
1193
+ prettier: default14
1194
+ },
1195
+ rules: {
1196
+ "prettier/prettier": "off"
1224
1197
  }
1225
1198
  }
1226
- ]);
1227
- var sortTsConfig = defineConfig([
1199
+ ];
1200
+
1201
+ // src/configs/gitignore.ts
1202
+ import createGitIgnore from "eslint-config-flat-gitignore";
1203
+ var gitignore = (options = {}) => [
1228
1204
  {
1229
- name: "ntnyq/sort/tsconfig",
1230
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1231
- rules: {
1232
- "jsonc/sort-keys": [
1233
- "error",
1234
- {
1235
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
1236
- pathPattern: "^$"
1205
+ ...createGitIgnore(options),
1206
+ name: "ntnyq/gitignore"
1207
+ }
1208
+ ];
1209
+
1210
+ // src/configs/javascript.ts
1211
+ import jsConfig from "@eslint/js";
1212
+ import globals from "globals";
1213
+ var javascript = (options = {}) => {
1214
+ const strictRules = {
1215
+ complexity: ["error", { max: 30 }],
1216
+ "max-params": ["error", { max: 5 }],
1217
+ "max-depth": ["error", { max: 5 }],
1218
+ "max-nested-callbacks": ["error", { max: 10 }],
1219
+ "max-lines": [
1220
+ "error",
1221
+ {
1222
+ max: 1e3,
1223
+ skipComments: true,
1224
+ skipBlankLines: true
1225
+ }
1226
+ ],
1227
+ "max-lines-per-function": [
1228
+ "error",
1229
+ {
1230
+ max: 200,
1231
+ skipComments: true,
1232
+ skipBlankLines: true
1233
+ }
1234
+ ]
1235
+ };
1236
+ return [
1237
+ {
1238
+ ...jsConfig.configs.recommended,
1239
+ name: "ntnyq/js/recommended"
1240
+ },
1241
+ {
1242
+ name: "ntnyq/js/core",
1243
+ languageOptions: {
1244
+ globals: {
1245
+ ...globals.browser,
1246
+ ...globals.es2021,
1247
+ ...globals.node
1237
1248
  },
1238
- {
1239
- order: [
1240
- /* Projects */
1241
- "incremental",
1242
- "composite",
1243
- "tsBuildInfoFile",
1244
- "disableSourceOfProjectReferenceRedirect",
1245
- "disableSolutionSearching",
1246
- "disableReferencedProjectLoad",
1247
- /* Language and Environment */
1248
- "target",
1249
- "lib",
1250
- "jsx",
1251
- "experimentalDecorators",
1252
- "emitDecoratorMetadata",
1253
- "jsxFactory",
1254
- "jsxFragmentFactory",
1255
- "jsxImportSource",
1256
- "reactNamespace",
1257
- "noLib",
1258
- "useDefineForClassFields",
1259
- "moduleDetection",
1260
- /* Modules */
1261
- "module",
1262
- "rootDir",
1263
- "moduleResolution",
1264
- "baseUrl",
1265
- "paths",
1266
- "rootDirs",
1267
- "typeRoots",
1268
- "types",
1269
- "allowUmdGlobalAccess",
1270
- "moduleSuffixes",
1271
- "allowImportingTsExtensions",
1272
- "resolvePackageJsonExports",
1273
- "resolvePackageJsonImports",
1274
- "customConditions",
1275
- "resolveJsonModule",
1276
- "allowArbitraryExtensions",
1277
- "noResolve",
1278
- /* JavaScript Support */
1279
- "allowJs",
1280
- "checkJs",
1281
- "maxNodeModuleJsDepth",
1282
- /* Emit */
1283
- "declaration",
1284
- "declarationMap",
1285
- "emitDeclarationOnly",
1286
- "sourceMap",
1287
- "inlineSourceMap",
1288
- "outFile",
1289
- "outDir",
1290
- "removeComments",
1291
- "noEmit",
1292
- "importHelpers",
1293
- "importsNotUsedAsValues",
1294
- "downlevelIteration",
1295
- "sourceRoot",
1296
- "mapRoot",
1297
- "inlineSources",
1298
- "emitBOM",
1299
- "newLine",
1300
- "stripInternal",
1301
- "noEmitHelpers",
1302
- "noEmitOnError",
1303
- "preserveConstEnums",
1304
- "declarationDir",
1305
- "preserveValueImports",
1306
- /* Interop Constraints */
1307
- "isolatedModules",
1308
- "verbatimModuleSyntax",
1309
- "allowSyntheticDefaultImports",
1310
- "esModuleInterop",
1311
- "preserveSymlinks",
1312
- "forceConsistentCasingInFileNames",
1313
- /* Type Checking */
1314
- "strict",
1315
- "strictBindCallApply",
1316
- "strictFunctionTypes",
1317
- "strictNullChecks",
1318
- "strictPropertyInitialization",
1319
- "allowUnreachableCode",
1320
- "allowUnusedLabels",
1321
- "alwaysStrict",
1322
- "exactOptionalPropertyTypes",
1323
- "noFallthroughCasesInSwitch",
1324
- "noImplicitAny",
1325
- "noImplicitOverride",
1326
- "noImplicitReturns",
1327
- "noImplicitThis",
1328
- "noPropertyAccessFromIndexSignature",
1329
- "noUncheckedIndexedAccess",
1330
- "noUnusedLocals",
1331
- "noUnusedParameters",
1332
- "useUnknownInCatchVariables",
1333
- /* Completeness */
1334
- "skipDefaultLibCheck",
1335
- "skipLibCheck"
1336
- ],
1337
- pathPattern: "^compilerOptions$"
1249
+ sourceType: "module"
1250
+ },
1251
+ rules: {
1252
+ "require-await": "off",
1253
+ "no-return-assign": "off",
1254
+ "no-useless-escape": "off",
1255
+ "consistent-return": "off",
1256
+ // disabled in favor of `perfectionist/sort-named-imports`
1257
+ "sort-imports": "off",
1258
+ // standard v17.0.0
1259
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
1260
+ camelcase: [
1261
+ "error",
1262
+ {
1263
+ allow: ["^UNSAFE_"],
1264
+ properties: "never",
1265
+ ignoreGlobals: true
1266
+ }
1267
+ ],
1268
+ "constructor-super": "error",
1269
+ curly: ["error", "multi-line"],
1270
+ "default-case-last": "error",
1271
+ "dot-notation": ["error", { allowKeywords: true }],
1272
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
1273
+ "no-array-constructor": "error",
1274
+ "no-async-promise-executor": "error",
1275
+ "no-caller": "error",
1276
+ "no-class-assign": "error",
1277
+ "no-compare-neg-zero": "error",
1278
+ "no-cond-assign": "error",
1279
+ "no-const-assign": "error",
1280
+ "no-constant-condition": ["error", { checkLoops: false }],
1281
+ "no-control-regex": "error",
1282
+ "no-debugger": "error",
1283
+ "no-delete-var": "error",
1284
+ "no-dupe-args": "error",
1285
+ "no-dupe-class-members": "error",
1286
+ "no-dupe-keys": "error",
1287
+ "no-duplicate-case": "error",
1288
+ "no-useless-backreference": "error",
1289
+ "no-empty": ["error", { allowEmptyCatch: true }],
1290
+ "no-empty-character-class": "error",
1291
+ "no-empty-pattern": "error",
1292
+ "no-eval": "error",
1293
+ "no-ex-assign": "error",
1294
+ "no-extend-native": "error",
1295
+ "no-extra-bind": "error",
1296
+ "no-extra-boolean-cast": "error",
1297
+ "no-fallthrough": "error",
1298
+ "no-func-assign": "error",
1299
+ "no-global-assign": "error",
1300
+ "no-implied-eval": "error",
1301
+ "no-import-assign": "error",
1302
+ "no-invalid-regexp": "error",
1303
+ "no-irregular-whitespace": "error",
1304
+ "no-iterator": "error",
1305
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
1306
+ "no-lone-blocks": "error",
1307
+ "no-loss-of-precision": "error",
1308
+ "no-misleading-character-class": "error",
1309
+ "no-prototype-builtins": "error",
1310
+ "no-useless-catch": "error",
1311
+ "no-new": "error",
1312
+ "no-new-func": "error",
1313
+ "no-new-wrappers": "error",
1314
+ "no-obj-calls": "error",
1315
+ "no-octal": "error",
1316
+ "no-octal-escape": "error",
1317
+ "no-proto": "error",
1318
+ "no-redeclare": ["error", { builtinGlobals: false }],
1319
+ "no-regex-spaces": "error",
1320
+ "no-self-assign": ["error", { props: true }],
1321
+ "no-self-compare": "error",
1322
+ "no-sequences": "error",
1323
+ "no-shadow-restricted-names": "error",
1324
+ "no-sparse-arrays": "error",
1325
+ "no-template-curly-in-string": "error",
1326
+ "no-this-before-super": "error",
1327
+ "no-throw-literal": "error",
1328
+ "no-undef": "error",
1329
+ "no-undef-init": "error",
1330
+ "no-unexpected-multiline": "error",
1331
+ "no-unmodified-loop-condition": "error",
1332
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1333
+ "no-unreachable": "error",
1334
+ "no-unreachable-loop": "error",
1335
+ "no-unsafe-finally": "error",
1336
+ "no-unsafe-negation": "error",
1337
+ "no-unused-expressions": [
1338
+ "error",
1339
+ {
1340
+ allowShortCircuit: true,
1341
+ allowTernary: true,
1342
+ allowTaggedTemplates: true
1343
+ }
1344
+ ],
1345
+ "no-unused-vars": [
1346
+ "error",
1347
+ {
1348
+ args: "none",
1349
+ caughtErrors: "none",
1350
+ ignoreRestSiblings: true,
1351
+ vars: "all"
1352
+ }
1353
+ ],
1354
+ "no-useless-call": "error",
1355
+ "no-useless-computed-key": "error",
1356
+ "no-useless-constructor": "error",
1357
+ "no-useless-rename": "error",
1358
+ "no-useless-return": "error",
1359
+ "prefer-promise-reject-errors": "error",
1360
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
1361
+ "symbol-description": "error",
1362
+ "unicode-bom": ["error", "never"],
1363
+ "use-isnan": [
1364
+ "error",
1365
+ {
1366
+ enforceForSwitchCase: true,
1367
+ enforceForIndexOf: true
1368
+ }
1369
+ ],
1370
+ "valid-typeof": ["error", { requireStringLiterals: true }],
1371
+ yoda: ["error", "never"],
1372
+ // es6+
1373
+ "no-var": "error",
1374
+ "prefer-rest-params": "error",
1375
+ "prefer-spread": "error",
1376
+ "prefer-template": "error",
1377
+ "no-empty-static-block": "error",
1378
+ "no-new-native-nonconstructor": "error",
1379
+ "prefer-const": [
1380
+ "error",
1381
+ {
1382
+ destructuring: "all",
1383
+ ignoreReadBeforeAssign: true
1384
+ }
1385
+ ],
1386
+ "prefer-arrow-callback": [
1387
+ "error",
1388
+ {
1389
+ allowNamedFunctions: false,
1390
+ allowUnboundThis: true
1391
+ }
1392
+ ],
1393
+ "object-shorthand": [
1394
+ "error",
1395
+ "always",
1396
+ {
1397
+ ignoreConstructors: false,
1398
+ avoidQuotes: true
1399
+ }
1400
+ ],
1401
+ // best-practice
1402
+ eqeqeq: ["error", "smart"],
1403
+ "array-callback-return": "error",
1404
+ "block-scoped-var": "error",
1405
+ "no-alert": "error",
1406
+ "no-case-declarations": "error",
1407
+ "no-multi-str": "error",
1408
+ "no-with": "error",
1409
+ "no-void": "error",
1410
+ "vars-on-top": "error",
1411
+ "one-var": ["error", "never"],
1412
+ "no-use-before-define": [
1413
+ "error",
1414
+ {
1415
+ functions: false,
1416
+ classes: false,
1417
+ variables: true
1418
+ }
1419
+ ],
1420
+ // Strict rules
1421
+ ...options.strict ? strictRules : {},
1422
+ // Overrides built-in rules
1423
+ ...options.overrides
1424
+ }
1425
+ },
1426
+ {
1427
+ name: "ntnyq/js/scripts",
1428
+ files: ["**/scripts/*", "**/cli.*"],
1429
+ rules: {
1430
+ "no-console": "off"
1431
+ }
1432
+ },
1433
+ {
1434
+ name: "ntnyq/js/test",
1435
+ files: ["**/*.{test,spec}.js?(x)"],
1436
+ rules: {
1437
+ "no-unused-expressions": "off",
1438
+ "max-lines-per-function": "off"
1439
+ }
1440
+ }
1441
+ ];
1442
+ };
1443
+ var jsx = () => [
1444
+ {
1445
+ name: "ntnyq/jsx",
1446
+ files: ["**/*.jsx"],
1447
+ languageOptions: {
1448
+ parserOptions: {
1449
+ ecmaFeatures: {
1450
+ jsx: true
1338
1451
  }
1339
- ]
1452
+ }
1340
1453
  }
1341
1454
  }
1342
- ]);
1455
+ ];
1343
1456
 
1344
- // src/configs/jsonc.ts
1345
- var jsonc = defineConfig([
1457
+ // src/configs/perfectionist.ts
1458
+ var perfectionist = (options = {}) => [
1346
1459
  {
1347
- name: "ntnyq/jsonc",
1348
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1460
+ name: "ntnyq/perfectionist",
1349
1461
  plugins: {
1350
- jsonc: default6
1351
- },
1352
- languageOptions: {
1353
- parser: parserJsonc
1462
+ perfectionist: default15
1354
1463
  },
1355
1464
  rules: {
1356
- ...default6.configs["recommended-with-jsonc"].rules,
1357
- "jsonc/array-bracket-spacing": ["error", "never"],
1358
- "jsonc/comma-dangle": ["error", "never"],
1359
- "jsonc/comma-style": ["error", "last"],
1360
- "jsonc/indent": ["error", 2],
1361
- "jsonc/key-spacing": [
1465
+ "perfectionist/sort-imports": [
1362
1466
  "error",
1363
1467
  {
1364
- beforeColon: false,
1365
- afterColon: true
1468
+ groups: [
1469
+ // Side effect style imports (e.g. 'normalize.css')
1470
+ "side-effect-style",
1471
+ // Styles (e.g. *.{css,scss,less})
1472
+ "style",
1473
+ // Node.js built-in modules. (e.g. fs, path)
1474
+ "builtin",
1475
+ // External modules installed in the project (e.g. vue, lodash)
1476
+ "external",
1477
+ // Internal modules (e.g. @/utils, @/components)
1478
+ "internal",
1479
+ // Modules from parent directory (e.g. ../utils)
1480
+ "parent",
1481
+ // Modules from the same directory (e.g. ./utils)
1482
+ "sibling",
1483
+ // Main file from the current directory (e.g. ./index)
1484
+ "index",
1485
+ // TypeScript object-imports (e.g. import log = console.log)
1486
+ "object",
1487
+ // Side effect imports (e.g. import 'babel-polyfill')
1488
+ "side-effect",
1489
+ /**
1490
+ * Type import at the end
1491
+ */
1492
+ "builtin-type",
1493
+ "external-type",
1494
+ "internal-type",
1495
+ "parent-type",
1496
+ "sibling-type",
1497
+ "index-type",
1498
+ "type",
1499
+ /**
1500
+ * Imports that don’t fit into any other group
1501
+ */
1502
+ "unknown"
1503
+ ],
1504
+ order: "asc",
1505
+ type: "natural",
1506
+ ignoreCase: true,
1507
+ internalPattern: ["~/**", "@/**", "#**"],
1508
+ newlinesBetween: "ignore"
1366
1509
  }
1367
1510
  ],
1368
- "jsonc/no-octal-escape": "error",
1369
- "jsonc/object-curly-newline": [
1511
+ "perfectionist/sort-exports": [
1370
1512
  "error",
1371
1513
  {
1372
- multiline: true,
1373
- consistent: true
1514
+ order: "asc",
1515
+ type: "line-length"
1374
1516
  }
1375
1517
  ],
1376
- "jsonc/object-curly-spacing": ["error", "always"],
1377
- "jsonc/object-property-newline": [
1518
+ "perfectionist/sort-named-exports": [
1378
1519
  "error",
1379
1520
  {
1380
- allowMultiplePropertiesPerLine: true
1521
+ type: "alphabetical",
1522
+ order: "asc",
1523
+ ignoreCase: true,
1524
+ groupKind: "values-first"
1381
1525
  }
1382
- ]
1526
+ ],
1527
+ "perfectionist/sort-named-imports": [
1528
+ "error",
1529
+ {
1530
+ type: "alphabetical",
1531
+ order: "asc",
1532
+ ignoreCase: true,
1533
+ ignoreAlias: false,
1534
+ groupKind: "values-first"
1535
+ }
1536
+ ],
1537
+ // Overrides built-in rules
1538
+ ...options.overrides
1383
1539
  }
1384
1540
  }
1385
- ]);
1541
+ ];
1386
1542
 
1387
- // src/configs/markdown.ts
1388
- var markdown = defineConfig([
1389
- ...default13.configs.recommended,
1543
+ // src/configs/unusedImports.ts
1544
+ var unusedImports = (options = {}) => [
1390
1545
  {
1391
- name: "ntnyq/markdown/extensions",
1392
- files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
1546
+ name: "ntnyq/unused-imports",
1547
+ plugins: {
1548
+ "unused-imports": default16
1549
+ },
1393
1550
  rules: {
1394
- "no-undef": "off",
1395
- "no-alert": "off",
1396
- "no-console": "off",
1397
- "no-unused-vars": "off",
1398
- "no-unused-expressions": "off",
1399
- "no-restricted-imports": "off",
1400
- "node/prefer-global/buffer": "off",
1401
- "node/prefer-global/process": "off",
1402
- "import/no-unresolved": "off",
1403
- "unused-imports/no-unused-imports": "off",
1404
- "unused-imports/no-unused-vars": "off",
1405
- "@typescript-eslint/comma-dangle": "off",
1406
- "@typescript-eslint/no-redeclare": "off",
1407
- "@typescript-eslint/no-namespace": "off",
1408
1551
  "@typescript-eslint/no-unused-vars": "off",
1409
- "@typescript-eslint/no-extraneous-class": "off",
1410
- "@typescript-eslint/no-use-before-define": "off"
1552
+ "unused-imports/no-unused-imports": "error",
1553
+ "unused-imports/no-unused-vars": [
1554
+ "warn",
1555
+ {
1556
+ vars: "all",
1557
+ varsIgnorePattern: "^_",
1558
+ args: "after-used",
1559
+ argsIgnorePattern: "^_"
1560
+ }
1561
+ ],
1562
+ // Overrides built-in rules
1563
+ ...options.overrides
1411
1564
  }
1412
1565
  }
1413
- ]);
1566
+ ];
1567
+
1568
+ // src/utils/env.ts
1569
+ import { resolve } from "node:path";
1570
+ import process2 from "node:process";
1571
+ import { isPackageExists } from "local-pkg";
1572
+ var hasTypeScript = isPackageExists("typescript");
1573
+ var hasVitest = isPackageExists("vitest");
1574
+ var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
1575
+ paths: [resolve(process2.cwd(), "playground")]
1576
+ });
1577
+ var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
1578
+
1579
+ // src/utils/toArray.ts
1580
+ function toArray(val) {
1581
+ val = val ?? [];
1582
+ return Array.isArray(val) ? val : [val];
1583
+ }
1584
+
1585
+ // src/utils/interopDefault.ts
1586
+ async function interopDefault(mod) {
1587
+ const resolved = await mod;
1588
+ return resolved.default || resolved;
1589
+ }
1590
+
1591
+ // src/utils/loadPlugin.ts
1592
+ async function loadPlugin(name) {
1593
+ const mod = await import(name).catch((err) => {
1594
+ console.error(err);
1595
+ throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
1596
+ });
1597
+ return interopDefault(mod);
1598
+ }
1599
+
1600
+ // src/utils/resolveSubOptions.ts
1601
+ function resolveSubOptions(options, key) {
1602
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1603
+ }
1604
+
1605
+ // src/utils/getOverrides.ts
1606
+ function getOverrides(options, key) {
1607
+ const sub = resolveSubOptions(options, key);
1608
+ return "overrides" in sub && sub.overrides ? sub.overrides : {};
1609
+ }
1414
1610
 
1415
1611
  // src/core.ts
1416
- function ntnyq(config = [], {
1417
- vue: enableVue = hasVue,
1418
- unocss: enableUnoCSS = hasUnoCSS,
1419
- vitest: enableVitest = hasVitest,
1420
- prettier: enablePrettier = true,
1421
- markdown: enableMarkdown = true,
1422
- command: enableCommand = true
1423
- } = {}) {
1424
- const configs = defineConfig([
1425
- /**
1426
- * Basic
1427
- */
1428
- ...ignores,
1429
- ...jsdoc,
1430
- ...jsx,
1431
- ...node,
1432
- ...imports,
1433
- ...unicorn,
1434
- ...comments,
1435
- ...javascript,
1436
- ...regexp,
1437
- ...typescript,
1438
- /**
1439
- * Language extensions
1440
- */
1441
- ...yml,
1442
- ...toml,
1443
- ...jsonc,
1444
- ...sortPackageJson,
1445
- ...sortTsConfig
1446
- ]);
1447
- if (enableVue) {
1448
- configs.push(...vue);
1612
+ function ntnyq(options = {}, userConfigs = []) {
1613
+ const configs = [];
1614
+ if (options.gitignore ?? true) {
1615
+ configs.push(
1616
+ ...gitignore({
1617
+ ...resolveSubOptions(options, "gitignore")
1618
+ })
1619
+ );
1449
1620
  }
1450
- if (enableVitest) {
1451
- configs.push(...vitest);
1621
+ configs.push(
1622
+ ...ignores(options.ignores),
1623
+ ...jsx(),
1624
+ ...node({
1625
+ overrides: getOverrides(options, "node")
1626
+ }),
1627
+ ...imports({
1628
+ overrides: getOverrides(options, "imports")
1629
+ }),
1630
+ ...javascript({
1631
+ ...resolveSubOptions(options, "javascript"),
1632
+ overrides: getOverrides(options, "javascript")
1633
+ })
1634
+ );
1635
+ if (options.perfectionist ?? true) {
1636
+ configs.push(
1637
+ ...perfectionist({
1638
+ overrides: getOverrides(options, "perfectionist")
1639
+ })
1640
+ );
1452
1641
  }
1453
- if (enableUnoCSS) {
1454
- configs.push(...unocss);
1642
+ if (options.unicorn ?? true) {
1643
+ configs.push(
1644
+ ...unicorn({
1645
+ overrides: getOverrides(options, "unicorn")
1646
+ })
1647
+ );
1455
1648
  }
1456
- if (enableMarkdown) {
1457
- configs.push(...markdown);
1649
+ if (options.regexp ?? true) {
1650
+ configs.push(
1651
+ ...regexp({
1652
+ overrides: getOverrides(options, "regexp")
1653
+ })
1654
+ );
1458
1655
  }
1459
- if (enableCommand) {
1460
- configs.push(...command);
1656
+ if (options.jsdoc ?? true) {
1657
+ configs.push(
1658
+ ...jsdoc({
1659
+ overrides: getOverrides(options, "jsdoc")
1660
+ })
1661
+ );
1461
1662
  }
1462
- if (enablePrettier) {
1463
- configs.push(...prettier);
1663
+ if (options.comments ?? true) {
1664
+ configs.push(
1665
+ ...comments({
1666
+ overrides: getOverrides(options, "comments")
1667
+ })
1668
+ );
1464
1669
  }
1465
- if (Object.keys(config).length > 0) {
1466
- configs.push(...Array.isArray(config) ? config : [config]);
1670
+ if (options.typescript ?? hasTypeScript) {
1671
+ configs.push(
1672
+ ...typescript({
1673
+ ...resolveSubOptions(options, "typescript"),
1674
+ overrides: getOverrides(options, "typescript")
1675
+ })
1676
+ );
1467
1677
  }
1468
- return configs;
1678
+ if (options.sortI18nLocale ?? true) {
1679
+ configs.push(...sortI18nLocale());
1680
+ }
1681
+ if (options.sortTsConfig ?? true) {
1682
+ configs.push(...sortTsConfig());
1683
+ }
1684
+ if (options.sortPackageJson ?? true) {
1685
+ configs.push(...sortPackageJson());
1686
+ }
1687
+ if (options.yml ?? true) {
1688
+ configs.push(
1689
+ ...yml({
1690
+ overrides: getOverrides(options, "yml")
1691
+ })
1692
+ );
1693
+ }
1694
+ if (options.toml ?? true) {
1695
+ configs.push(
1696
+ ...toml({
1697
+ overrides: getOverrides(options, "toml")
1698
+ })
1699
+ );
1700
+ }
1701
+ if (options.jsonc ?? true) {
1702
+ configs.push(
1703
+ ...jsonc({
1704
+ overrides: getOverrides(options, "jsonc")
1705
+ })
1706
+ );
1707
+ }
1708
+ if (options.vue ?? hasVue) {
1709
+ configs.push(
1710
+ ...vue({
1711
+ ...resolveSubOptions(options, "vue"),
1712
+ overrides: getOverrides(options, "vue")
1713
+ })
1714
+ );
1715
+ }
1716
+ if (options.vitest ?? hasVitest) {
1717
+ configs.push(
1718
+ ...vitest({
1719
+ overrides: getOverrides(options, "vitest")
1720
+ })
1721
+ );
1722
+ }
1723
+ if (options.unocss ?? hasUnoCSS) {
1724
+ configs.push(
1725
+ ...unocss({
1726
+ overrides: getOverrides(options, "unocss")
1727
+ })
1728
+ );
1729
+ }
1730
+ if (options.markdown ?? true) {
1731
+ configs.push(
1732
+ ...markdown({
1733
+ overrides: getOverrides(options, "markdown")
1734
+ })
1735
+ );
1736
+ }
1737
+ if (options.command ?? true) {
1738
+ configs.push(
1739
+ ...command({
1740
+ ...resolveSubOptions(options, "command")
1741
+ })
1742
+ );
1743
+ }
1744
+ const configPrettier = options.prettier ?? true ? prettier({
1745
+ ...resolveSubOptions(options, "prettier"),
1746
+ overrides: getOverrides(options, "prettier")
1747
+ }) : [];
1748
+ const composer = new FlatConfigComposer();
1749
+ composer.append(
1750
+ ...configs,
1751
+ ...toArray(userConfigs),
1752
+ ...configPrettier
1753
+ );
1754
+ return composer;
1469
1755
  }
1470
1756
  export {
1471
1757
  GLOB_ALL_SRC,
@@ -1482,6 +1768,8 @@ export {
1482
1768
  GLOB_LESS,
1483
1769
  GLOB_LOCKFILE,
1484
1770
  GLOB_MARKDOWN,
1771
+ GLOB_MARKDOWN_CODE,
1772
+ GLOB_MARKDOWN_NESTED,
1485
1773
  GLOB_NODE_MODULES,
1486
1774
  GLOB_SCSS,
1487
1775
  GLOB_SRC,
@@ -1493,10 +1781,11 @@ export {
1493
1781
  GLOB_TSX,
1494
1782
  GLOB_VUE,
1495
1783
  GLOB_YAML,
1784
+ antfu,
1496
1785
  command,
1497
1786
  comments,
1498
- defineConfig,
1499
- getVueVersion,
1787
+ getOverrides,
1788
+ gitignore,
1500
1789
  hasTypeScript,
1501
1790
  hasUnoCSS,
1502
1791
  hasVitest,
@@ -1517,26 +1806,30 @@ export {
1517
1806
  parserVue,
1518
1807
  parserYaml,
1519
1808
  perfectionist,
1520
- default16 as pluginComments,
1521
- default11 as pluginImport,
1522
- default7 as pluginJsdoc,
1523
- default6 as pluginJsonc,
1524
- default13 as pluginMarkdown,
1809
+ default7 as pluginAntfu,
1810
+ default17 as pluginComments,
1811
+ default12 as pluginImport,
1812
+ default8 as pluginJsdoc,
1813
+ default9 as pluginJsonc,
1814
+ default6 as pluginMarkdown,
1525
1815
  default2 as pluginNode,
1526
- default14 as pluginPerfectionist,
1527
- default12 as pluginPrettier,
1816
+ default15 as pluginPerfectionist,
1817
+ default14 as pluginPrettier,
1528
1818
  pluginRegexp,
1529
1819
  default5 as pluginToml,
1530
- default10 as pluginUnicorn,
1531
- default8 as pluginUnoCSS,
1532
- default15 as pluginUnusedImports,
1533
- default9 as pluginVitest,
1820
+ default13 as pluginUnicorn,
1821
+ default10 as pluginUnoCSS,
1822
+ default16 as pluginUnusedImports,
1823
+ default11 as pluginVitest,
1534
1824
  default3 as pluginVue,
1535
1825
  default4 as pluginYaml,
1536
1826
  prettier,
1537
1827
  regexp,
1828
+ resolveSubOptions,
1829
+ sortI18nLocale,
1538
1830
  sortPackageJson,
1539
1831
  sortTsConfig,
1832
+ toArray,
1540
1833
  toml,
1541
1834
  tseslint,
1542
1835
  typescript,