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