@ntnyq/eslint-config 3.0.0-beta.8 → 3.0.0

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