@ntnyq/eslint-config 7.0.0-beta.3 → 7.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -206
- package/dist/index.d.mts +5247 -1688
- package/dist/index.mjs +595 -382
- package/package.json +63 -62
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import * as parserToml from "toml-eslint-parser";
|
|
|
6
6
|
import * as parserYaml from "yaml-eslint-parser";
|
|
7
7
|
import * as parserPlain from "eslint-parser-plain";
|
|
8
8
|
import * as parserJsonc from "jsonc-eslint-parser";
|
|
9
|
+
import pluginShell from "@eslint/shell";
|
|
9
10
|
import pluginNode from "eslint-plugin-n";
|
|
10
11
|
import pluginVue from "eslint-plugin-vue";
|
|
11
12
|
import pluginYml from "eslint-plugin-yml";
|
|
@@ -29,6 +30,7 @@ import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
|
29
30
|
import pluginNoOnlyTests from "eslint-plugin-no-only-tests";
|
|
30
31
|
import pluginGitHubAction from "eslint-plugin-github-action";
|
|
31
32
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
33
|
+
import pluginVuePerfectionist from "eslint-plugin-vue-perfectionist";
|
|
32
34
|
import * as pluginESLintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
33
35
|
import processorVueBlocks from "eslint-processor-vue-blocks";
|
|
34
36
|
import { resolve } from "node:path";
|
|
@@ -40,7 +42,7 @@ import { createTypeScriptImportResolver } from "eslint-import-resolver-typescrip
|
|
|
40
42
|
import globals from "globals";
|
|
41
43
|
import createGitIgnoreConfig from "eslint-config-flat-gitignore";
|
|
42
44
|
import jsConfig from "@eslint/js";
|
|
43
|
-
|
|
45
|
+
// src/globs.ts
|
|
44
46
|
/**
|
|
45
47
|
* @file globs constants
|
|
46
48
|
*/
|
|
@@ -58,6 +60,9 @@ const GLOB_TYPES = [
|
|
|
58
60
|
`**/types/${GLOB_TS}`,
|
|
59
61
|
`**/types.ts`
|
|
60
62
|
];
|
|
63
|
+
const GLOB_VUE = "**/*.vue";
|
|
64
|
+
const GLOB_PINIA_STORE = `**/store?(s)/*.${GLOB_SRC_EXT}`;
|
|
65
|
+
const GLOB_VUE_COMPOSABLES = [`**/composables/*.${GLOB_SRC_EXT}`, `**/use*${GLOB_SRC_EXT}`];
|
|
61
66
|
const GLOB_TYPE_TEST = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
|
|
62
67
|
const GLOB_TEST = [
|
|
63
68
|
`**/*.test.${GLOB_SRC_EXT}`,
|
|
@@ -79,10 +84,11 @@ const GLOB_JSON_SCHEMA = ["**/*.schema.json", "**/schemas/*.json"];
|
|
|
79
84
|
const GLOB_TSCONFIG_JSON = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
80
85
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
81
86
|
const GLOB_PNPM_WORKSPACE_YAML = "**/pnpm-workspace.yaml";
|
|
87
|
+
const GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
|
|
82
88
|
const GLOB_SVG = "**/*.svg";
|
|
83
|
-
const GLOB_VUE = "**/*.vue";
|
|
84
89
|
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
85
90
|
const GLOB_TOML = "**/*.toml";
|
|
91
|
+
const GLOB_SHELL = "**/*.{sh,bash}";
|
|
86
92
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
87
93
|
const GLOB_ASTRO = "**/*.astro";
|
|
88
94
|
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
@@ -103,8 +109,6 @@ const GLOB_ALL_SRC = [
|
|
|
103
109
|
GLOB_VUE,
|
|
104
110
|
...GLOB_SRC_EXTENSIONS
|
|
105
111
|
];
|
|
106
|
-
const GLOB_PINIA_STORE = `**/store?(s)/*.${GLOB_SRC_EXT}`;
|
|
107
|
-
const GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
|
|
108
112
|
const GLOB_NODE_MODULES = "**/node_modules/**";
|
|
109
113
|
const GLOB_DIST = "**/dist/**";
|
|
110
114
|
const GLOB_LOCKFILE = [
|
|
@@ -154,6 +158,9 @@ const GLOB_EXCLUDE = [
|
|
|
154
158
|
"**/.npmrc",
|
|
155
159
|
"**/.yarnrc",
|
|
156
160
|
"**/.husky",
|
|
161
|
+
"**/test-results/**",
|
|
162
|
+
"**/playwright-report/**",
|
|
163
|
+
"**/.playwright-cli/**",
|
|
157
164
|
"**/src-tauri/gen",
|
|
158
165
|
"**/src-tauri/target",
|
|
159
166
|
"**/*.context",
|
|
@@ -161,8 +168,126 @@ const GLOB_EXCLUDE = [
|
|
|
161
168
|
"**/*.agents",
|
|
162
169
|
"**/.*/skills"
|
|
163
170
|
];
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
// src/utils/env.ts
|
|
172
|
+
/**
|
|
173
|
+
* Check whether Pinia is available in the current project.
|
|
174
|
+
*/
|
|
175
|
+
const hasPinia = () => isPackageExists("pinia");
|
|
176
|
+
/**
|
|
177
|
+
* Check whether Vitest is available in the current project.
|
|
178
|
+
*/
|
|
179
|
+
const hasVitest = () => isPackageExists("vitest");
|
|
180
|
+
/**
|
|
181
|
+
* Check whether TypeScript runtime or preview package is available.
|
|
182
|
+
*/
|
|
183
|
+
const hasTypeScript = () => isPackageExists("typescript") || isPackageExists("@typescript/native-preview");
|
|
184
|
+
/**
|
|
185
|
+
* Check whether shadcn-vue related dependencies are available.
|
|
186
|
+
*/
|
|
187
|
+
const hasShadcnVue = () => (isPackageExists("radix-vue") || isPackageExists("reka-ui")) && isPackageExists("class-variance-authority") && isPackageExists("clsx");
|
|
188
|
+
/**
|
|
189
|
+
* Check whether UnoCSS runtime packages are available.
|
|
190
|
+
*/
|
|
191
|
+
const hasUnoCSS = () => isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
192
|
+
/**
|
|
193
|
+
* Check whether Vue ecosystem packages are available.
|
|
194
|
+
*/
|
|
195
|
+
const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", { paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")] });
|
|
196
|
+
/**
|
|
197
|
+
* Check whether oxfmt is available in the current project.
|
|
198
|
+
*/
|
|
199
|
+
const hasOxfmt = () => isPackageExists("oxfmt");
|
|
200
|
+
/**
|
|
201
|
+
* Check whether Prettier is available in the current project.
|
|
202
|
+
*/
|
|
203
|
+
const hasPrettier = () => isPackageExists("prettier");
|
|
204
|
+
/**
|
|
205
|
+
* Check whether AutoImport is available in the current project.
|
|
206
|
+
*/
|
|
207
|
+
const hasAutoImport = () => isPackageExists("unplugin-auto-import");
|
|
208
|
+
// src/utils/resolveSubOptions.ts
|
|
209
|
+
/**
|
|
210
|
+
* Normalize a sub-option value to an object.
|
|
211
|
+
*
|
|
212
|
+
* Boolean `true` means enabled with default options and returns an empty
|
|
213
|
+
* object; falsy values also fall back to an empty object.
|
|
214
|
+
*
|
|
215
|
+
* @param options - Options object that contains sub-options.
|
|
216
|
+
* @param key - Sub-option key to resolve.
|
|
217
|
+
* @returns Normalized sub-options object.
|
|
218
|
+
*/
|
|
219
|
+
function resolveSubOptions(options, key) {
|
|
220
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
221
|
+
}
|
|
222
|
+
// src/utils/getOverrides.ts
|
|
223
|
+
/**
|
|
224
|
+
* Read rule overrides from a config sub-option.
|
|
225
|
+
*
|
|
226
|
+
* @param options - Top-level config options.
|
|
227
|
+
* @param key - Sub-option key to read.
|
|
228
|
+
* @returns Rule override map when provided, otherwise an empty object.
|
|
229
|
+
*/
|
|
230
|
+
function getOverrides(options, key) {
|
|
231
|
+
const subOptions = resolveSubOptions(options, key);
|
|
232
|
+
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
233
|
+
}
|
|
234
|
+
// src/utils/isInGitHooksOrRunBySpecifyPackages.ts
|
|
235
|
+
const CHECKED_RUNNER_PACKAGES = [
|
|
236
|
+
"nano-staged",
|
|
237
|
+
"lint-staged",
|
|
238
|
+
"lefthook",
|
|
239
|
+
"tsx"
|
|
240
|
+
];
|
|
241
|
+
/**
|
|
242
|
+
* Detect whether current execution is triggered by git hook tooling.
|
|
243
|
+
*/
|
|
244
|
+
function isInGitHooksOrRunBySpecifyPackages() {
|
|
245
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || CHECKED_RUNNER_PACKAGES.some((packageName) => process.env.npm_lifecycle_script?.startsWith(packageName)));
|
|
246
|
+
}
|
|
247
|
+
// src/utils/ensurePackages.ts
|
|
248
|
+
/**
|
|
249
|
+
* @copyright {@link https://github.com/antfu/eslint-config}
|
|
250
|
+
*/
|
|
251
|
+
const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
|
|
252
|
+
/**
|
|
253
|
+
* Check whether a package can be resolved from this config package scope.
|
|
254
|
+
*/
|
|
255
|
+
function isPackageInScope(name) {
|
|
256
|
+
return isPackageExists(name, { paths: [import.meta.dirname] });
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Ensure required packages are installed for optional config features.
|
|
260
|
+
*
|
|
261
|
+
* Skips installation prompts in CI, non-TTY environments, git hooks, and
|
|
262
|
+
* when the current project is outside the config usage scope.
|
|
263
|
+
*
|
|
264
|
+
* @param packages - Package names to verify and optionally install.
|
|
265
|
+
*/
|
|
266
|
+
async function ensurePackages(packages) {
|
|
267
|
+
if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope) return;
|
|
268
|
+
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
269
|
+
if (nonExistingPackages.length === 0) return;
|
|
270
|
+
const { confirm, isCancel } = await import("@clack/prompts");
|
|
271
|
+
const confirmInstall = await confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
|
|
272
|
+
if (isCancel(confirmInstall) || !confirmInstall) return;
|
|
273
|
+
try {
|
|
274
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
275
|
+
await installPackage(nonExistingPackages, { dev: true });
|
|
276
|
+
} catch (error) {
|
|
277
|
+
throw new Error(`Failed to install required packages: ${nonExistingPackages.join(", ")}`, { cause: error });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// src/utils/interopDefault.ts
|
|
281
|
+
/**
|
|
282
|
+
* Interop default export from a module
|
|
283
|
+
* @param mod - The module
|
|
284
|
+
* @returns The default export
|
|
285
|
+
*/
|
|
286
|
+
async function interopDefault(mod) {
|
|
287
|
+
const resolved = await mod;
|
|
288
|
+
return resolved.default || resolved;
|
|
289
|
+
}
|
|
290
|
+
// src/configs/vue.ts
|
|
166
291
|
const sharedRules = {
|
|
167
292
|
...pluginVue.configs.base.rules,
|
|
168
293
|
...pluginVue.configs.essential.rules,
|
|
@@ -342,7 +467,9 @@ const unCategorizedRules = {
|
|
|
342
467
|
* @returns ESLint configs
|
|
343
468
|
*/
|
|
344
469
|
const configVue = (options = {}) => {
|
|
345
|
-
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [] } = options;
|
|
470
|
+
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [], typescript = false, vuePerfectionist: enableVuePerfectionist = false } = options;
|
|
471
|
+
const vuePerfectionistOptions = resolveSubOptions(options, "vuePerfectionist");
|
|
472
|
+
const enableAutoImport = vuePerfectionistOptions.autoImport ?? hasAutoImport();
|
|
346
473
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
347
474
|
function getVueProcessor() {
|
|
348
475
|
const processorVueSFC = pluginVue.processors[".vue"];
|
|
@@ -355,10 +482,10 @@ const configVue = (options = {}) => {
|
|
|
355
482
|
}
|
|
356
483
|
})]);
|
|
357
484
|
}
|
|
358
|
-
|
|
485
|
+
const configs = [{
|
|
359
486
|
name: "ntnyq/vue/setup",
|
|
360
487
|
plugins: {
|
|
361
|
-
"@typescript-eslint": pluginTypeScript,
|
|
488
|
+
...typescript ? { "@typescript-eslint": pluginTypeScript } : {},
|
|
362
489
|
vue: pluginVue
|
|
363
490
|
}
|
|
364
491
|
}, {
|
|
@@ -370,9 +497,9 @@ const configVue = (options = {}) => {
|
|
|
370
497
|
parserOptions: {
|
|
371
498
|
ecmaVersion,
|
|
372
499
|
extraFileExtensions,
|
|
373
|
-
parser: parserTypeScript,
|
|
374
500
|
sourceType: "module",
|
|
375
|
-
ecmaFeatures: { jsx: true }
|
|
501
|
+
ecmaFeatures: { jsx: true },
|
|
502
|
+
...typescript ? { parser: parserTypeScript } : {}
|
|
376
503
|
}
|
|
377
504
|
},
|
|
378
505
|
rules: {
|
|
@@ -409,6 +536,9 @@ const configVue = (options = {}) => {
|
|
|
409
536
|
multiline: 1,
|
|
410
537
|
singleline: 1
|
|
411
538
|
}],
|
|
539
|
+
"vue/no-content-outside-block": "error",
|
|
540
|
+
"vue/no-define-model-default": "error",
|
|
541
|
+
"vue/no-props-shadow": "error",
|
|
412
542
|
"vue/order-in-components": ["error", { order: [
|
|
413
543
|
"el",
|
|
414
544
|
"name",
|
|
@@ -502,9 +632,56 @@ const configVue = (options = {}) => {
|
|
|
502
632
|
...options.overrides
|
|
503
633
|
}
|
|
504
634
|
}];
|
|
635
|
+
if (enableVuePerfectionist) configs.push({
|
|
636
|
+
name: "ntnyq/vue/vue-perfectionist",
|
|
637
|
+
files: vuePerfectionistOptions.files ?? [
|
|
638
|
+
"**/*.vue",
|
|
639
|
+
"**/store?(s)/*.?([cm])[jt]s?(x)",
|
|
640
|
+
...GLOB_VUE_COMPOSABLES
|
|
641
|
+
],
|
|
642
|
+
plugins: { "vue-perfectionist": pluginVuePerfectionist },
|
|
643
|
+
settings: { "vue-perfectionist": { autoImport: enableAutoImport } },
|
|
644
|
+
rules: {
|
|
645
|
+
"vue-perfectionist/prefer-define-model": "warn",
|
|
646
|
+
"vue-perfectionist/callback-style": "error",
|
|
647
|
+
"vue-perfectionist/consistent-template-ref-name": "error",
|
|
648
|
+
"vue-perfectionist/define-macros-newline": "error",
|
|
649
|
+
"vue-perfectionist/no-complex-template-expression": "error",
|
|
650
|
+
"vue-perfectionist/no-complex-v-for-source": "error",
|
|
651
|
+
"vue-perfectionist/prefer-ref-pattern": "error",
|
|
652
|
+
"vue-perfectionist/prefer-simple-event-handler": ["error", {
|
|
653
|
+
allowConditional: true,
|
|
654
|
+
allowInlineFunctions: false,
|
|
655
|
+
allowLogical: true
|
|
656
|
+
}],
|
|
657
|
+
"vue-perfectionist/prefer-watch-effect-alias": "error",
|
|
658
|
+
"vue-perfectionist/sort-script-setup": ["error", { groups: [
|
|
659
|
+
["interface", "type"],
|
|
660
|
+
"define-props",
|
|
661
|
+
"define-emits",
|
|
662
|
+
"define-options",
|
|
663
|
+
"define-slots",
|
|
664
|
+
"define-model",
|
|
665
|
+
"constant",
|
|
666
|
+
"inject",
|
|
667
|
+
"composable",
|
|
668
|
+
"template-ref",
|
|
669
|
+
["ref", "reactive"],
|
|
670
|
+
"computed",
|
|
671
|
+
"variable",
|
|
672
|
+
["enum", "class"],
|
|
673
|
+
"function",
|
|
674
|
+
"watch",
|
|
675
|
+
"lifecycle-hook",
|
|
676
|
+
"provide",
|
|
677
|
+
"define-expose"
|
|
678
|
+
] }],
|
|
679
|
+
...vuePerfectionistOptions.overrides
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
return configs;
|
|
505
683
|
};
|
|
506
|
-
|
|
507
|
-
//#region src/configs/yml.ts
|
|
684
|
+
// src/configs/yml.ts
|
|
508
685
|
/**
|
|
509
686
|
* @see {@link https://github.com/ota-meshi/eslint-plugin-yml/blob/master/src/configs/base.ts}
|
|
510
687
|
*/
|
|
@@ -571,129 +748,7 @@ const configYml = (options = {}) => {
|
|
|
571
748
|
}
|
|
572
749
|
}];
|
|
573
750
|
};
|
|
574
|
-
|
|
575
|
-
//#region src/utils/env.ts
|
|
576
|
-
/**
|
|
577
|
-
* Check whether Pinia is available in the current project.
|
|
578
|
-
*/
|
|
579
|
-
const hasPinia = () => isPackageExists("pinia");
|
|
580
|
-
/**
|
|
581
|
-
* Check whether Vitest is available in the current project.
|
|
582
|
-
*/
|
|
583
|
-
const hasVitest = () => isPackageExists("vitest");
|
|
584
|
-
/**
|
|
585
|
-
* Check whether TypeScript runtime or preview package is available.
|
|
586
|
-
*/
|
|
587
|
-
const hasTypeScript = () => isPackageExists("typescript") || isPackageExists("@typescript/native-preview");
|
|
588
|
-
/**
|
|
589
|
-
* Check whether shadcn-vue related dependencies are available.
|
|
590
|
-
*/
|
|
591
|
-
const hasShadcnVue = () => (isPackageExists("radix-vue") || isPackageExists("reka-ui")) && isPackageExists("class-variance-authority") && isPackageExists("clsx");
|
|
592
|
-
/**
|
|
593
|
-
* Check whether UnoCSS runtime packages are available.
|
|
594
|
-
*/
|
|
595
|
-
const hasUnoCSS = () => isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
596
|
-
/**
|
|
597
|
-
* Check whether Vue ecosystem packages are available.
|
|
598
|
-
*/
|
|
599
|
-
const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", { paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")] });
|
|
600
|
-
/**
|
|
601
|
-
* Check whether oxfmt is available in the current project.
|
|
602
|
-
*/
|
|
603
|
-
const hasOxfmt = () => isPackageExists("oxfmt");
|
|
604
|
-
/**
|
|
605
|
-
* Check whether Prettier is available in the current project.
|
|
606
|
-
*/
|
|
607
|
-
const hasPrettier = () => isPackageExists("prettier");
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/utils/resolveSubOptions.ts
|
|
610
|
-
/**
|
|
611
|
-
* Normalize a sub-option value to an object.
|
|
612
|
-
*
|
|
613
|
-
* Boolean `true` means enabled with default options and returns an empty
|
|
614
|
-
* object; falsy values also fall back to an empty object.
|
|
615
|
-
*
|
|
616
|
-
* @param options - Options object that contains sub-options.
|
|
617
|
-
* @param key - Sub-option key to resolve.
|
|
618
|
-
* @returns Normalized sub-options object.
|
|
619
|
-
*/
|
|
620
|
-
function resolveSubOptions(options, key) {
|
|
621
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
622
|
-
}
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region src/utils/getOverrides.ts
|
|
625
|
-
/**
|
|
626
|
-
* Read rule overrides from a config sub-option.
|
|
627
|
-
*
|
|
628
|
-
* @param options - Top-level config options.
|
|
629
|
-
* @param key - Sub-option key to read.
|
|
630
|
-
* @returns Rule override map when provided, otherwise an empty object.
|
|
631
|
-
*/
|
|
632
|
-
function getOverrides(options, key) {
|
|
633
|
-
const subOptions = resolveSubOptions(options, key);
|
|
634
|
-
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
635
|
-
}
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region src/utils/isInGitHooksOrRunBySpecifyPackages.ts
|
|
638
|
-
const CHECKED_RUNNER_PACKAGES = [
|
|
639
|
-
"nano-staged",
|
|
640
|
-
"lint-staged",
|
|
641
|
-
"lefthook",
|
|
642
|
-
"tsx"
|
|
643
|
-
];
|
|
644
|
-
/**
|
|
645
|
-
* Detect whether current execution is triggered by git hook tooling.
|
|
646
|
-
*/
|
|
647
|
-
function isInGitHooksOrRunBySpecifyPackages() {
|
|
648
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || CHECKED_RUNNER_PACKAGES.some((packageName) => process.env.npm_lifecycle_script?.startsWith(packageName)));
|
|
649
|
-
}
|
|
650
|
-
//#endregion
|
|
651
|
-
//#region src/utils/ensurePackages.ts
|
|
652
|
-
/**
|
|
653
|
-
* @copyright {@link https://github.com/antfu/eslint-config}
|
|
654
|
-
*/
|
|
655
|
-
const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
|
|
656
|
-
/**
|
|
657
|
-
* Check whether a package can be resolved from this config package scope.
|
|
658
|
-
*/
|
|
659
|
-
function isPackageInScope(name) {
|
|
660
|
-
return isPackageExists(name, { paths: [import.meta.dirname] });
|
|
661
|
-
}
|
|
662
|
-
/**
|
|
663
|
-
* Ensure required packages are installed for optional config features.
|
|
664
|
-
*
|
|
665
|
-
* Skips installation prompts in CI, non-TTY environments, git hooks, and
|
|
666
|
-
* when the current project is outside the config usage scope.
|
|
667
|
-
*
|
|
668
|
-
* @param packages - Package names to verify and optionally install.
|
|
669
|
-
*/
|
|
670
|
-
async function ensurePackages(packages) {
|
|
671
|
-
if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope) return;
|
|
672
|
-
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
673
|
-
if (nonExistingPackages.length === 0) return;
|
|
674
|
-
const { confirm, isCancel } = await import("@clack/prompts");
|
|
675
|
-
const confirmInstall = await confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
|
|
676
|
-
if (isCancel(confirmInstall) || confirmInstall !== true) return;
|
|
677
|
-
try {
|
|
678
|
-
const { installPackage } = await import("@antfu/install-pkg");
|
|
679
|
-
await installPackage(nonExistingPackages, { dev: true });
|
|
680
|
-
} catch (err) {
|
|
681
|
-
throw new Error(`Failed to install required packages: ${nonExistingPackages.join(", ")}`, { cause: err });
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
//#endregion
|
|
685
|
-
//#region src/utils/interopDefault.ts
|
|
686
|
-
/**
|
|
687
|
-
* Interop default export from a module
|
|
688
|
-
* @param mod - The module
|
|
689
|
-
* @returns The default export
|
|
690
|
-
*/
|
|
691
|
-
async function interopDefault(mod) {
|
|
692
|
-
const resolved = await mod;
|
|
693
|
-
return resolved.default || resolved;
|
|
694
|
-
}
|
|
695
|
-
//#endregion
|
|
696
|
-
//#region src/configs/html.ts
|
|
751
|
+
// src/configs/html.ts
|
|
697
752
|
/**
|
|
698
753
|
* Config for html files
|
|
699
754
|
*
|
|
@@ -717,7 +772,7 @@ const configHtml = async (options = {}) => {
|
|
|
717
772
|
"@html-eslint/indent": "error",
|
|
718
773
|
"@html-eslint/no-duplicate-attrs": "error",
|
|
719
774
|
"@html-eslint/no-duplicate-id": "error",
|
|
720
|
-
"@html-eslint/no-extra-spacing-
|
|
775
|
+
"@html-eslint/no-extra-spacing-tags": "error",
|
|
721
776
|
"@html-eslint/no-multiple-h1": "error",
|
|
722
777
|
"@html-eslint/no-obsolete-tags": "error",
|
|
723
778
|
"@html-eslint/quotes": "error",
|
|
@@ -732,8 +787,7 @@ const configHtml = async (options = {}) => {
|
|
|
732
787
|
}
|
|
733
788
|
}];
|
|
734
789
|
};
|
|
735
|
-
|
|
736
|
-
//#region src/configs/node.ts
|
|
790
|
+
// src/configs/node.ts
|
|
737
791
|
/**
|
|
738
792
|
* Config for common files
|
|
739
793
|
*
|
|
@@ -753,12 +807,13 @@ const configNode = (options = {}) => [{
|
|
|
753
807
|
"node/no-path-concat": "error",
|
|
754
808
|
"node/prefer-global/buffer": ["error", "never"],
|
|
755
809
|
"node/prefer-global/process": ["error", "never"],
|
|
810
|
+
"node/prefer-import/assert-strict": "error",
|
|
811
|
+
"node/prefer-process-get-builtin-module": "error",
|
|
756
812
|
"node/process-exit-as-throw": "error",
|
|
757
813
|
...options.overrides
|
|
758
814
|
}
|
|
759
815
|
}];
|
|
760
|
-
|
|
761
|
-
//#region src/configs/pnpm.ts
|
|
816
|
+
// src/configs/pnpm.ts
|
|
762
817
|
/**
|
|
763
818
|
* Config for pnpm package manager
|
|
764
819
|
*
|
|
@@ -768,33 +823,38 @@ const configNode = (options = {}) => [{
|
|
|
768
823
|
* @returns ESLint configs
|
|
769
824
|
*/
|
|
770
825
|
const configPnpm = async (options = {}) => {
|
|
826
|
+
const { json: enableJson = true, yaml: enableYaml = true } = options;
|
|
827
|
+
const jsonOptions = resolveSubOptions(options, "json");
|
|
828
|
+
const yamlOptions = resolveSubOptions(options, "yaml");
|
|
829
|
+
if (!enableJson && !enableYaml) return [];
|
|
771
830
|
await ensurePackages(["eslint-plugin-pnpm"]);
|
|
772
831
|
const pluginPnpm = await interopDefault(import("eslint-plugin-pnpm"));
|
|
773
|
-
const
|
|
774
|
-
|
|
832
|
+
const configs = [];
|
|
833
|
+
if (enableJson) configs.push({
|
|
775
834
|
name: "ntnyq/pnpm/package-json",
|
|
776
|
-
files:
|
|
835
|
+
files: jsonOptions.files ?? ["**/package.json"],
|
|
777
836
|
plugins: { pnpm: pluginPnpm },
|
|
778
837
|
languageOptions: { parser: parserJsonc },
|
|
779
838
|
rules: {
|
|
780
839
|
"pnpm/json-enforce-catalog": ["error", { autofix: true }],
|
|
781
840
|
"pnpm/json-valid-catalog": "error",
|
|
782
|
-
...
|
|
841
|
+
...jsonOptions.overrides
|
|
783
842
|
}
|
|
784
|
-
}
|
|
843
|
+
});
|
|
844
|
+
if (enableYaml) configs.push({
|
|
785
845
|
name: "ntnyq/pnpm/pnpm-workspace-yaml",
|
|
786
|
-
files:
|
|
846
|
+
files: yamlOptions.files ?? ["**/pnpm-workspace.yaml"],
|
|
787
847
|
plugins: { pnpm: pluginPnpm },
|
|
788
848
|
languageOptions: { parser: parserYaml },
|
|
789
849
|
rules: {
|
|
790
850
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
791
851
|
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
792
|
-
...
|
|
852
|
+
...yamlOptions.overrides
|
|
793
853
|
}
|
|
794
|
-
}
|
|
854
|
+
});
|
|
855
|
+
return configs;
|
|
795
856
|
};
|
|
796
|
-
|
|
797
|
-
//#region src/configs/sort.ts
|
|
857
|
+
// src/configs/sort.ts
|
|
798
858
|
/**
|
|
799
859
|
* Config for sort keys and values
|
|
800
860
|
*
|
|
@@ -1188,8 +1248,7 @@ const configSort = (options = {}) => {
|
|
|
1188
1248
|
});
|
|
1189
1249
|
return configs;
|
|
1190
1250
|
};
|
|
1191
|
-
|
|
1192
|
-
//#region src/configs/svgo.ts
|
|
1251
|
+
// src/configs/svgo.ts
|
|
1193
1252
|
/**
|
|
1194
1253
|
* Config for svg files
|
|
1195
1254
|
*
|
|
@@ -1218,8 +1277,7 @@ const configSVGO = (options = {}) => {
|
|
|
1218
1277
|
}
|
|
1219
1278
|
}];
|
|
1220
1279
|
};
|
|
1221
|
-
|
|
1222
|
-
//#region src/configs/test.ts
|
|
1280
|
+
// src/configs/test.ts
|
|
1223
1281
|
/**
|
|
1224
1282
|
* Config for test files
|
|
1225
1283
|
*
|
|
@@ -1229,23 +1287,26 @@ const configSVGO = (options = {}) => {
|
|
|
1229
1287
|
* @returns ESLint configs
|
|
1230
1288
|
*/
|
|
1231
1289
|
const configTest = (options = {}) => {
|
|
1232
|
-
const { files = [...GLOB_TEST], vitest: enableVitest = hasVitest() } = options;
|
|
1233
|
-
const
|
|
1290
|
+
const { files = [...GLOB_TEST], base: enableBase = true, vitest: enableVitest = hasVitest() } = options;
|
|
1291
|
+
const baseOptions = resolveSubOptions(options, "base");
|
|
1292
|
+
const vitestOptions = resolveSubOptions(options, "vitest");
|
|
1293
|
+
const configs = [];
|
|
1294
|
+
if (enableBase) configs.push({
|
|
1234
1295
|
name: "ntnyq/test/setup",
|
|
1235
1296
|
plugins: { "no-only-tests": pluginNoOnlyTests }
|
|
1236
1297
|
}, {
|
|
1237
1298
|
name: "ntnyq/test/base",
|
|
1238
|
-
files,
|
|
1299
|
+
files: baseOptions.files ?? files,
|
|
1239
1300
|
rules: {
|
|
1240
1301
|
"max-lines-per-function": "off",
|
|
1241
1302
|
"no-unused-expressions": "off",
|
|
1242
1303
|
"no-only-tests/no-only-tests": "error",
|
|
1243
|
-
...
|
|
1304
|
+
...baseOptions.overrides
|
|
1244
1305
|
}
|
|
1245
|
-
}
|
|
1306
|
+
});
|
|
1246
1307
|
if (enableVitest) configs.push({
|
|
1247
1308
|
name: "ntnyq/test/vitest",
|
|
1248
|
-
files,
|
|
1309
|
+
files: vitestOptions.files ?? files,
|
|
1249
1310
|
plugins: { vitest: pluginVitest },
|
|
1250
1311
|
settings: {},
|
|
1251
1312
|
rules: {
|
|
@@ -1256,13 +1317,12 @@ const configTest = (options = {}) => {
|
|
|
1256
1317
|
"expectTypeOf",
|
|
1257
1318
|
"assertType"
|
|
1258
1319
|
] }],
|
|
1259
|
-
...
|
|
1320
|
+
...vitestOptions.overrides
|
|
1260
1321
|
}
|
|
1261
1322
|
});
|
|
1262
1323
|
return configs;
|
|
1263
1324
|
};
|
|
1264
|
-
|
|
1265
|
-
//#region src/configs/toml.ts
|
|
1325
|
+
// src/configs/toml.ts
|
|
1266
1326
|
/**
|
|
1267
1327
|
* Config for toml files
|
|
1268
1328
|
*
|
|
@@ -1302,8 +1362,7 @@ const configToml = (options = {}) => {
|
|
|
1302
1362
|
}
|
|
1303
1363
|
}];
|
|
1304
1364
|
};
|
|
1305
|
-
|
|
1306
|
-
//#region src/configs/antfu.ts
|
|
1365
|
+
// src/configs/antfu.ts
|
|
1307
1366
|
/**
|
|
1308
1367
|
* Config for common files
|
|
1309
1368
|
*
|
|
@@ -1323,8 +1382,7 @@ const configAntfu = (options = {}) => [{
|
|
|
1323
1382
|
...options.overrides
|
|
1324
1383
|
}
|
|
1325
1384
|
}];
|
|
1326
|
-
|
|
1327
|
-
//#region src/configs/astro.ts
|
|
1385
|
+
// src/configs/astro.ts
|
|
1328
1386
|
/**
|
|
1329
1387
|
* Config for astro files
|
|
1330
1388
|
*
|
|
@@ -1336,7 +1394,7 @@ const configAntfu = (options = {}) => [{
|
|
|
1336
1394
|
const configAstro = async (options = {}) => {
|
|
1337
1395
|
await ensurePackages(["astro-eslint-parser", "eslint-plugin-astro"]);
|
|
1338
1396
|
const [parserAstro, pluginAstro] = await Promise.all([interopDefault(import("astro-eslint-parser")), interopDefault(import("eslint-plugin-astro"))]);
|
|
1339
|
-
const { files = [GLOB_ASTRO], extraFileExtensions = [] } = options;
|
|
1397
|
+
const { files = [GLOB_ASTRO], ecmaVersion = "latest", extraFileExtensions = [], typescript = false } = options;
|
|
1340
1398
|
return [{
|
|
1341
1399
|
name: "ntnyq/astro",
|
|
1342
1400
|
files,
|
|
@@ -1347,8 +1405,9 @@ const configAstro = async (options = {}) => {
|
|
|
1347
1405
|
sourceType: "module",
|
|
1348
1406
|
globals: { ...pluginAstro.environments.astro.globals },
|
|
1349
1407
|
parserOptions: {
|
|
1408
|
+
ecmaVersion,
|
|
1350
1409
|
extraFileExtensions,
|
|
1351
|
-
parser: parserTypeScript
|
|
1410
|
+
...typescript ? { parser: parserTypeScript } : {}
|
|
1352
1411
|
}
|
|
1353
1412
|
},
|
|
1354
1413
|
rules: {
|
|
@@ -1359,13 +1418,11 @@ const configAstro = async (options = {}) => {
|
|
|
1359
1418
|
"astro/no-deprecated-astro-resolve": "error",
|
|
1360
1419
|
"astro/no-deprecated-getentrybyslug": "error",
|
|
1361
1420
|
"astro/no-unused-define-vars-in-style": "error",
|
|
1362
|
-
"astro/valid-compile": "error",
|
|
1363
1421
|
...options.overrides
|
|
1364
1422
|
}
|
|
1365
1423
|
}];
|
|
1366
1424
|
};
|
|
1367
|
-
|
|
1368
|
-
//#region src/configs/jsdoc.ts
|
|
1425
|
+
// src/configs/jsdoc.ts
|
|
1369
1426
|
const SPECIAL_CHAR = {
|
|
1370
1427
|
emptyString: "",
|
|
1371
1428
|
singleSpace: " "
|
|
@@ -1410,9 +1467,7 @@ const configJsdoc = (options = {}) => {
|
|
|
1410
1467
|
"jsdoc/require-next-description": "warn",
|
|
1411
1468
|
"jsdoc/require-next-type": "warn",
|
|
1412
1469
|
"jsdoc/require-throws-description": "warn",
|
|
1413
|
-
"jsdoc/require-throws-type": "warn",
|
|
1414
1470
|
"jsdoc/require-yields-description": "warn",
|
|
1415
|
-
"jsdoc/require-yields-type": "warn",
|
|
1416
1471
|
"jsdoc/ts-method-signature-style": "warn",
|
|
1417
1472
|
"jsdoc/ts-no-empty-object-type": "warn",
|
|
1418
1473
|
"jsdoc/ts-no-unnecessary-template-expression": "warn",
|
|
@@ -1435,6 +1490,7 @@ const configJsdoc = (options = {}) => {
|
|
|
1435
1490
|
"internal"
|
|
1436
1491
|
] }],
|
|
1437
1492
|
"jsdoc/check-types": "error",
|
|
1493
|
+
"jsdoc/escape-inline-tags": "error",
|
|
1438
1494
|
/**
|
|
1439
1495
|
* @pg Fixable rules
|
|
1440
1496
|
*/
|
|
@@ -1469,12 +1525,12 @@ const configJsdoc = (options = {}) => {
|
|
|
1469
1525
|
stringQuotes: "single",
|
|
1470
1526
|
typeBracketSpacing: SPECIAL_CHAR.emptyString,
|
|
1471
1527
|
unionSpacing: SPECIAL_CHAR.singleSpace
|
|
1472
|
-
}]
|
|
1473
|
-
|
|
1474
|
-
|
|
1528
|
+
}],
|
|
1529
|
+
...options.overrides
|
|
1530
|
+
}
|
|
1475
1531
|
},
|
|
1476
1532
|
{
|
|
1477
|
-
name: "ntnyq/jsdoc/
|
|
1533
|
+
name: "ntnyq/jsdoc/javascript",
|
|
1478
1534
|
files: [GLOB_JS, GLOB_JSX],
|
|
1479
1535
|
rules: {
|
|
1480
1536
|
"jsdoc/no-types": "off",
|
|
@@ -1482,25 +1538,28 @@ const configJsdoc = (options = {}) => {
|
|
|
1482
1538
|
"jsdoc/require-param-type": "error",
|
|
1483
1539
|
"jsdoc/require-property-type": "error",
|
|
1484
1540
|
"jsdoc/require-returns-type": "error",
|
|
1541
|
+
"jsdoc/require-throws-type": "error",
|
|
1542
|
+
"jsdoc/require-yields-type": "error",
|
|
1485
1543
|
...options.overrides
|
|
1486
1544
|
}
|
|
1487
1545
|
},
|
|
1488
1546
|
{
|
|
1489
|
-
name: "ntnyq/jsdoc/
|
|
1547
|
+
name: "ntnyq/jsdoc/typescript",
|
|
1490
1548
|
files: [GLOB_TS, GLOB_TSX],
|
|
1491
1549
|
rules: {
|
|
1492
1550
|
"jsdoc/no-undefined-types": "off",
|
|
1493
1551
|
"jsdoc/require-param-type": "off",
|
|
1494
1552
|
"jsdoc/require-property-type": "off",
|
|
1495
1553
|
"jsdoc/require-returns-type": "off",
|
|
1554
|
+
"jsdoc/require-throws-type": "off",
|
|
1555
|
+
"jsdoc/require-yields-type": "off",
|
|
1496
1556
|
"jsdoc/no-types": "error",
|
|
1497
1557
|
...options.overrides
|
|
1498
1558
|
}
|
|
1499
1559
|
}
|
|
1500
1560
|
];
|
|
1501
1561
|
};
|
|
1502
|
-
|
|
1503
|
-
//#region src/configs/jsonc.ts
|
|
1562
|
+
// src/configs/jsonc.ts
|
|
1504
1563
|
/**
|
|
1505
1564
|
* @see {@link https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/lib/configs/base.ts}
|
|
1506
1565
|
*/
|
|
@@ -1529,6 +1588,7 @@ const configJsonc = (options = {}) => {
|
|
|
1529
1588
|
plugins: { jsonc: pluginJsonc },
|
|
1530
1589
|
languageOptions: { parser: parserJsonc },
|
|
1531
1590
|
rules: {
|
|
1591
|
+
"no-irregular-whitespace": "off",
|
|
1532
1592
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
1533
1593
|
"jsonc/comma-dangle": ["error", "never"],
|
|
1534
1594
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -1545,6 +1605,7 @@ const configJsonc = (options = {}) => {
|
|
|
1545
1605
|
"jsonc/no-floating-decimal": "error",
|
|
1546
1606
|
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
1547
1607
|
"jsonc/no-infinity": "error",
|
|
1608
|
+
"jsonc/no-irregular-whitespace": "error",
|
|
1548
1609
|
"jsonc/no-multi-str": "error",
|
|
1549
1610
|
"jsonc/no-nan": "error",
|
|
1550
1611
|
"jsonc/no-number-props": "error",
|
|
@@ -1592,8 +1653,7 @@ const configJsonc = (options = {}) => {
|
|
|
1592
1653
|
}
|
|
1593
1654
|
}];
|
|
1594
1655
|
};
|
|
1595
|
-
|
|
1596
|
-
//#region src/configs/ntnyq.ts
|
|
1656
|
+
// src/configs/ntnyq.ts
|
|
1597
1657
|
/**
|
|
1598
1658
|
* Config for common files
|
|
1599
1659
|
*
|
|
@@ -1607,12 +1667,29 @@ const configNtnyq = (options = {}) => [{
|
|
|
1607
1667
|
plugins: { ntnyq: pluginNtnyq },
|
|
1608
1668
|
rules: {
|
|
1609
1669
|
"ntnyq/no-duplicate-exports": "error",
|
|
1670
|
+
"ntnyq/no-explicit-void-return-type": "error",
|
|
1671
|
+
"ntnyq/no-restricted-bindings": ["error", { restrictions: [{
|
|
1672
|
+
message: "Use a domain name such as requestError; reserve error for catch parameters.",
|
|
1673
|
+
names: ["error"],
|
|
1674
|
+
except: ["catch-parameter"],
|
|
1675
|
+
regions: [
|
|
1676
|
+
"script",
|
|
1677
|
+
"vue-script",
|
|
1678
|
+
"vue-script-setup"
|
|
1679
|
+
],
|
|
1680
|
+
scope: "top-level"
|
|
1681
|
+
}] }],
|
|
1610
1682
|
"ntnyq/prefer-newline-after-file-header": "error",
|
|
1683
|
+
"ntnyq/prefer-object-method-syntax": ["error", {
|
|
1684
|
+
allowArrowFunctions: "singleLineOnly",
|
|
1685
|
+
avoidQuotes: true,
|
|
1686
|
+
fix: true
|
|
1687
|
+
}],
|
|
1688
|
+
"ntnyq/return-object-multiline": "error",
|
|
1611
1689
|
...options.overrides
|
|
1612
1690
|
}
|
|
1613
1691
|
}];
|
|
1614
|
-
|
|
1615
|
-
//#region src/configs/oxfmt.ts
|
|
1692
|
+
// src/configs/oxfmt.ts
|
|
1616
1693
|
/**
|
|
1617
1694
|
* Config for using oxfmt
|
|
1618
1695
|
*
|
|
@@ -1621,7 +1698,7 @@ const configNtnyq = (options = {}) => [{
|
|
|
1621
1698
|
* @returns ESLint configs
|
|
1622
1699
|
*/
|
|
1623
1700
|
const configOxfmt = (options = {}) => {
|
|
1624
|
-
const { files:
|
|
1701
|
+
const { files: nativeFiles = [
|
|
1625
1702
|
GLOB_SRC,
|
|
1626
1703
|
GLOB_VUE,
|
|
1627
1704
|
GLOB_JSON,
|
|
@@ -1630,10 +1707,10 @@ const configOxfmt = (options = {}) => {
|
|
|
1630
1707
|
GLOB_YAML,
|
|
1631
1708
|
GLOB_TOML,
|
|
1632
1709
|
GLOB_MARKDOWN
|
|
1633
|
-
], ignores: ignoresWithoutParser = [], filesExtensions:
|
|
1710
|
+
], ignores: ignoresWithoutParser = [], filesExtensions: plainParserFiles = [GLOB_STYLE, GLOB_HTML] } = options;
|
|
1634
1711
|
return [{
|
|
1635
|
-
name: "ntnyq/oxfmt/
|
|
1636
|
-
files:
|
|
1712
|
+
name: "ntnyq/oxfmt/native-files",
|
|
1713
|
+
files: nativeFiles,
|
|
1637
1714
|
ignores: ignoresWithoutParser,
|
|
1638
1715
|
plugins: { oxfmt: pluginOxfmt },
|
|
1639
1716
|
rules: {
|
|
@@ -1641,9 +1718,9 @@ const configOxfmt = (options = {}) => {
|
|
|
1641
1718
|
...options.overrides
|
|
1642
1719
|
}
|
|
1643
1720
|
}, {
|
|
1644
|
-
name: "ntnyq/oxfmt/
|
|
1645
|
-
files:
|
|
1646
|
-
ignores:
|
|
1721
|
+
name: "ntnyq/oxfmt/plain-parser-files",
|
|
1722
|
+
files: plainParserFiles,
|
|
1723
|
+
ignores: [...nativeFiles.flat(), ...ignoresWithoutParser],
|
|
1647
1724
|
plugins: { oxfmt: pluginOxfmt },
|
|
1648
1725
|
languageOptions: { parser: parserPlain },
|
|
1649
1726
|
rules: {
|
|
@@ -1652,8 +1729,7 @@ const configOxfmt = (options = {}) => {
|
|
|
1652
1729
|
}
|
|
1653
1730
|
}];
|
|
1654
1731
|
};
|
|
1655
|
-
|
|
1656
|
-
//#region src/configs/pinia.ts
|
|
1732
|
+
// src/configs/pinia.ts
|
|
1657
1733
|
/**
|
|
1658
1734
|
* Config for pinia store
|
|
1659
1735
|
*
|
|
@@ -1683,8 +1759,38 @@ const configPinia = (options = {}) => {
|
|
|
1683
1759
|
}
|
|
1684
1760
|
}];
|
|
1685
1761
|
};
|
|
1686
|
-
|
|
1687
|
-
|
|
1762
|
+
// src/configs/shell.ts
|
|
1763
|
+
/**
|
|
1764
|
+
* Config for shell scripts
|
|
1765
|
+
*
|
|
1766
|
+
* @see {@link https://github.com/eslint/shell}
|
|
1767
|
+
*
|
|
1768
|
+
* @param options - {@link ConfigShellOptions}
|
|
1769
|
+
* @returns ESLint configs
|
|
1770
|
+
*/
|
|
1771
|
+
const configShell = (options = {}) => {
|
|
1772
|
+
const { files = [GLOB_SHELL], language = "bash" } = options;
|
|
1773
|
+
return [{
|
|
1774
|
+
name: "ntnyq/shell",
|
|
1775
|
+
files,
|
|
1776
|
+
plugins: { shell: pluginShell },
|
|
1777
|
+
language: `shell/${language}`,
|
|
1778
|
+
rules: {
|
|
1779
|
+
"shell/no-expansions-in-single-quotes": "warn",
|
|
1780
|
+
"shell/no-backticks": "error",
|
|
1781
|
+
"shell/no-ls-iteration": "error",
|
|
1782
|
+
"shell/no-unquoted-expansions": "error",
|
|
1783
|
+
"shell/no-unused-vars": "error",
|
|
1784
|
+
"shell/no-useless-cat": "error",
|
|
1785
|
+
"shell/no-useless-echo": "error",
|
|
1786
|
+
"shell/no-variables-in-printf-format": "error",
|
|
1787
|
+
"shell/require-cd-guard": "error",
|
|
1788
|
+
"shell/require-read-r": "error",
|
|
1789
|
+
...options.overrides
|
|
1790
|
+
}
|
|
1791
|
+
}];
|
|
1792
|
+
};
|
|
1793
|
+
// src/configs/depend.ts
|
|
1688
1794
|
/**
|
|
1689
1795
|
* Config for optimisations dependency
|
|
1690
1796
|
*
|
|
@@ -1723,8 +1829,7 @@ const configDepend = (options = {}) => {
|
|
|
1723
1829
|
});
|
|
1724
1830
|
return configs;
|
|
1725
1831
|
};
|
|
1726
|
-
|
|
1727
|
-
//#region src/configs/regexp.ts
|
|
1832
|
+
// src/configs/regexp.ts
|
|
1728
1833
|
/**
|
|
1729
1834
|
* @file config for plugin regexp
|
|
1730
1835
|
* @see {@link https://github.com/ota-meshi/eslint-plugin-regexp}
|
|
@@ -1752,8 +1857,7 @@ const configRegexp = (options = {}) => {
|
|
|
1752
1857
|
}
|
|
1753
1858
|
}];
|
|
1754
1859
|
};
|
|
1755
|
-
|
|
1756
|
-
//#region src/configs/svelte.ts
|
|
1860
|
+
// src/configs/svelte.ts
|
|
1757
1861
|
/**
|
|
1758
1862
|
* Config for svelte files
|
|
1759
1863
|
*
|
|
@@ -1765,7 +1869,7 @@ const configRegexp = (options = {}) => {
|
|
|
1765
1869
|
const configSvelte = async (options = {}) => {
|
|
1766
1870
|
await ensurePackages(["svelte-eslint-parser", "eslint-plugin-svelte"]);
|
|
1767
1871
|
const [parserSvelte, pluginSvelte] = await Promise.all([interopDefault(import("svelte-eslint-parser")), interopDefault(import("eslint-plugin-svelte"))]);
|
|
1768
|
-
const { files = [GLOB_SVELTE], extraFileExtensions = [] } = options;
|
|
1872
|
+
const { files = [GLOB_SVELTE], ecmaVersion = "latest", extraFileExtensions = [], typescript = false } = options;
|
|
1769
1873
|
return [{
|
|
1770
1874
|
name: "ntnyq/svelte",
|
|
1771
1875
|
files,
|
|
@@ -1775,8 +1879,9 @@ const configSvelte = async (options = {}) => {
|
|
|
1775
1879
|
parser: parserSvelte,
|
|
1776
1880
|
sourceType: "module",
|
|
1777
1881
|
parserOptions: {
|
|
1882
|
+
ecmaVersion,
|
|
1778
1883
|
extraFileExtensions,
|
|
1779
|
-
parser: parserTypeScript
|
|
1884
|
+
...typescript ? { parser: parserTypeScript } : {}
|
|
1780
1885
|
}
|
|
1781
1886
|
},
|
|
1782
1887
|
rules: {
|
|
@@ -1838,8 +1943,7 @@ const configSvelte = async (options = {}) => {
|
|
|
1838
1943
|
}
|
|
1839
1944
|
}];
|
|
1840
1945
|
};
|
|
1841
|
-
|
|
1842
|
-
//#region src/configs/unocss.ts
|
|
1946
|
+
// src/configs/unocss.ts
|
|
1843
1947
|
/**
|
|
1844
1948
|
* Config for UnoCSS
|
|
1845
1949
|
*
|
|
@@ -1857,8 +1961,7 @@ const configUnoCSS = (options = {}) => [{
|
|
|
1857
1961
|
...options.overrides
|
|
1858
1962
|
}
|
|
1859
1963
|
}];
|
|
1860
|
-
|
|
1861
|
-
//#region src/commands/index.ts
|
|
1964
|
+
// src/commands/index.ts
|
|
1862
1965
|
const commands = [defineCommand({
|
|
1863
1966
|
name: "regexper",
|
|
1864
1967
|
match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
|
|
@@ -1883,8 +1986,7 @@ const commands = [defineCommand({
|
|
|
1883
1986
|
});
|
|
1884
1987
|
}
|
|
1885
1988
|
})];
|
|
1886
|
-
|
|
1887
|
-
//#region src/configs/command.ts
|
|
1989
|
+
// src/configs/command.ts
|
|
1888
1990
|
/**
|
|
1889
1991
|
* Config for using comments as codemod
|
|
1890
1992
|
*
|
|
@@ -1904,8 +2006,7 @@ const configCommand = (options = {}) => [{
|
|
|
1904
2006
|
}),
|
|
1905
2007
|
name: "ntnyq/command"
|
|
1906
2008
|
}];
|
|
1907
|
-
|
|
1908
|
-
//#region src/configs/ignores.ts
|
|
2009
|
+
// src/configs/ignores.ts
|
|
1909
2010
|
/**
|
|
1910
2011
|
* Config for ignore files from linting
|
|
1911
2012
|
*
|
|
@@ -1923,8 +2024,7 @@ const configIgnores = (customIgnores = []) => {
|
|
|
1923
2024
|
ignores
|
|
1924
2025
|
}];
|
|
1925
2026
|
};
|
|
1926
|
-
|
|
1927
|
-
//#region src/configs/importX.ts
|
|
2027
|
+
// src/configs/importX.ts
|
|
1928
2028
|
/**
|
|
1929
2029
|
* Config for imports and exports
|
|
1930
2030
|
*
|
|
@@ -1971,8 +2071,7 @@ const configImportX = (options = {}) => {
|
|
|
1971
2071
|
}
|
|
1972
2072
|
}];
|
|
1973
2073
|
};
|
|
1974
|
-
|
|
1975
|
-
//#region src/configs/unicorn.ts
|
|
2074
|
+
// src/configs/unicorn.ts
|
|
1976
2075
|
/**
|
|
1977
2076
|
* Built-in presets of `eslint-plugin-unicorn`
|
|
1978
2077
|
*/
|
|
@@ -2002,70 +2101,123 @@ const configUnicorn = (options = {}) => {
|
|
|
2002
2101
|
name: "ntnyq/unicorn",
|
|
2003
2102
|
plugins: { unicorn: pluginUnicorn },
|
|
2004
2103
|
rules: {
|
|
2104
|
+
/**
|
|
2105
|
+
* @pg Compatibility
|
|
2106
|
+
*/
|
|
2005
2107
|
"unicorn/explicit-length-check": "off",
|
|
2006
2108
|
/**
|
|
2109
|
+
* Conditional mutations
|
|
2110
|
+
*/
|
|
2111
|
+
"unicorn/no-immediate-mutation": "off",
|
|
2112
|
+
/**
|
|
2007
2113
|
* @see https://caniuse.com/?search=globalThis
|
|
2008
2114
|
*/
|
|
2009
2115
|
"unicorn/prefer-global-this": "off",
|
|
2010
2116
|
"unicorn/prefer-top-level-await": "off",
|
|
2117
|
+
/**
|
|
2118
|
+
* @pg Assertion
|
|
2119
|
+
*/
|
|
2011
2120
|
"unicorn/consistent-assert": "error",
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
"unicorn/escape-case": "error",
|
|
2121
|
+
/**
|
|
2122
|
+
* @pg Built-in
|
|
2123
|
+
*/
|
|
2016
2124
|
"unicorn/new-for-builtins": "error",
|
|
2017
|
-
"unicorn/no-accessor-recursion": "error",
|
|
2018
|
-
"unicorn/no-blob-to-file": "error",
|
|
2019
|
-
"unicorn/no-canvas-to-image": "error",
|
|
2020
2125
|
"unicorn/no-console-spaces": "error",
|
|
2021
|
-
"unicorn/no-for-loop": "error",
|
|
2022
|
-
"unicorn/no-hex-escape": "error",
|
|
2023
|
-
"unicorn/no-immediate-mutation": "error",
|
|
2024
2126
|
"unicorn/no-instanceof-builtins": "error",
|
|
2025
|
-
"unicorn/no-invalid-
|
|
2026
|
-
"unicorn/no-late-current-target-access": "error",
|
|
2027
|
-
"unicorn/no-lonely-if": "error",
|
|
2127
|
+
"unicorn/no-invalid-intl-options": "error",
|
|
2028
2128
|
"unicorn/no-new-buffer": "error",
|
|
2129
|
+
"unicorn/no-typeof-undefined": "error",
|
|
2130
|
+
"unicorn/no-unnecessary-global-this": "error",
|
|
2131
|
+
"unicorn/no-unused-builtin-method-return": "error",
|
|
2132
|
+
"unicorn/no-using-resource-escape": "error",
|
|
2133
|
+
/**
|
|
2134
|
+
* @pg Class
|
|
2135
|
+
*/
|
|
2136
|
+
"unicorn/no-accessor-recursion": "error",
|
|
2137
|
+
"unicorn/no-incomplete-accessor-override": "error",
|
|
2029
2138
|
"unicorn/no-static-only-class": "error",
|
|
2030
2139
|
"unicorn/no-this-outside-of-class": "error",
|
|
2031
|
-
"unicorn/no-
|
|
2032
|
-
"unicorn/
|
|
2140
|
+
"unicorn/no-useless-override": "error",
|
|
2141
|
+
"unicorn/prefer-class-fields": "error",
|
|
2142
|
+
/**
|
|
2143
|
+
* @pg Control Flow
|
|
2144
|
+
*/
|
|
2145
|
+
"unicorn/no-accidental-bitwise-operator": "error",
|
|
2146
|
+
"unicorn/no-chained-comparison": "error",
|
|
2147
|
+
"unicorn/no-constant-zero-expression": "error",
|
|
2148
|
+
"unicorn/no-double-comparison": "error",
|
|
2149
|
+
"unicorn/no-duplicate-logical-operands": "error",
|
|
2150
|
+
"unicorn/no-for-loop": "error",
|
|
2151
|
+
"unicorn/no-impossible-length-comparison": "error",
|
|
2152
|
+
"unicorn/no-lonely-if": "error",
|
|
2153
|
+
"unicorn/no-misrefactored-assignment": "error",
|
|
2154
|
+
"unicorn/no-unnecessary-boolean-comparison": "error",
|
|
2033
2155
|
"unicorn/no-unnecessary-nested-ternary": "error",
|
|
2156
|
+
"unicorn/no-useless-boolean-cast": "error",
|
|
2157
|
+
"unicorn/no-useless-coercion": "error",
|
|
2034
2158
|
"unicorn/no-useless-collection-argument": "error",
|
|
2035
|
-
"unicorn/no-useless-
|
|
2036
|
-
"unicorn/
|
|
2037
|
-
"unicorn/prefer-
|
|
2038
|
-
"unicorn/prefer-
|
|
2039
|
-
"unicorn/prefer-keyboard-event-key": "error",
|
|
2040
|
-
"unicorn/prefer-math-min-max": "error",
|
|
2041
|
-
"unicorn/prefer-math-trunc": "error",
|
|
2042
|
-
"unicorn/prefer-modern-math-apis": "error",
|
|
2043
|
-
"unicorn/prefer-negative-index": "error",
|
|
2044
|
-
"unicorn/prefer-node-protocol": "error",
|
|
2045
|
-
"unicorn/prefer-optional-catch-binding": "error",
|
|
2046
|
-
"unicorn/prefer-prototype-methods": "error",
|
|
2047
|
-
"unicorn/prefer-reflect-apply": "error",
|
|
2048
|
-
"unicorn/prefer-response-static-json": "error",
|
|
2049
|
-
"unicorn/prefer-structured-clone": "error",
|
|
2159
|
+
"unicorn/no-useless-continue": "error",
|
|
2160
|
+
"unicorn/no-useless-else": "error",
|
|
2161
|
+
"unicorn/prefer-block-statement-over-iife": "error",
|
|
2162
|
+
"unicorn/prefer-combined-guards": "error",
|
|
2050
2163
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
2051
2164
|
"unicorn/switch-case-break-position": "error",
|
|
2052
2165
|
/**
|
|
2053
2166
|
* @pg Error
|
|
2054
2167
|
*/
|
|
2055
2168
|
"unicorn/catch-error-name": ["error", {
|
|
2056
|
-
name: "
|
|
2169
|
+
name: "error",
|
|
2057
2170
|
ignore: ["^_."]
|
|
2058
2171
|
}],
|
|
2059
2172
|
"unicorn/custom-error-definition": "error",
|
|
2173
|
+
"unicorn/error-message": "error",
|
|
2060
2174
|
"unicorn/no-useless-error-capture-stack-trace": "error",
|
|
2175
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
2061
2176
|
"unicorn/prefer-type-error": "error",
|
|
2062
2177
|
"unicorn/throw-new-error": "error",
|
|
2063
2178
|
/**
|
|
2179
|
+
* @pg Promise
|
|
2180
|
+
*/
|
|
2181
|
+
"unicorn/no-async-promise-finally": "error",
|
|
2182
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
2183
|
+
"unicorn/no-multiple-promise-resolver-calls": "error",
|
|
2184
|
+
"unicorn/no-unnecessary-await": "error",
|
|
2185
|
+
"unicorn/no-unsafe-promise-all-settled-values": "error",
|
|
2186
|
+
"unicorn/prefer-then-catch": "error",
|
|
2187
|
+
/**
|
|
2188
|
+
* @pg Function
|
|
2189
|
+
*/
|
|
2190
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
2191
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
2192
|
+
/**
|
|
2193
|
+
* @pg Web APIs
|
|
2194
|
+
*/
|
|
2195
|
+
"unicorn/no-blob-to-file": "error",
|
|
2196
|
+
"unicorn/no-canvas-to-image": "error",
|
|
2197
|
+
"unicorn/no-invalid-fetch-options": "error",
|
|
2198
|
+
"unicorn/no-invalid-response-options": "error",
|
|
2199
|
+
"unicorn/no-invalid-url-protocol-comparison": "error",
|
|
2200
|
+
"unicorn/no-transition-all": "error",
|
|
2201
|
+
"unicorn/no-unnecessary-fetch-options": "error",
|
|
2202
|
+
"unicorn/no-url-in-search-params": "error",
|
|
2203
|
+
"unicorn/prefer-abort-signal-any": "error",
|
|
2204
|
+
"unicorn/prefer-abort-signal-timeout": "error",
|
|
2205
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
2206
|
+
"unicorn/prefer-observer-apis": "error",
|
|
2207
|
+
"unicorn/prefer-response-static-json": "error",
|
|
2208
|
+
"unicorn/prefer-url-search-parameters": "error",
|
|
2209
|
+
"unicorn/require-text-decoder-streaming": "error",
|
|
2210
|
+
/**
|
|
2064
2211
|
* @pg Number
|
|
2065
2212
|
*/
|
|
2066
2213
|
"unicorn/no-zero-fractions": "error",
|
|
2067
2214
|
"unicorn/number-literal-case": ["error", { hexadecimalValue: "lowercase" }],
|
|
2068
2215
|
"unicorn/prefer-math-abs": "error",
|
|
2216
|
+
"unicorn/prefer-math-min-max": "error",
|
|
2217
|
+
"unicorn/prefer-math-trunc": "error",
|
|
2218
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
2219
|
+
"unicorn/prefer-negative-index": "error",
|
|
2220
|
+
"unicorn/prefer-number-coercion": "error",
|
|
2069
2221
|
"unicorn/prefer-number-properties": "error",
|
|
2070
2222
|
/**
|
|
2071
2223
|
* @pg BigInt
|
|
@@ -2079,24 +2231,37 @@ const configUnicorn = (options = {}) => {
|
|
|
2079
2231
|
* @pg Date
|
|
2080
2232
|
*/
|
|
2081
2233
|
"unicorn/consistent-date-clone": "error",
|
|
2234
|
+
"unicorn/no-invalid-temporal-arithmetic": "error",
|
|
2082
2235
|
"unicorn/prefer-date-now": "error",
|
|
2236
|
+
"unicorn/prefer-temporal-conversion": "error",
|
|
2083
2237
|
/**
|
|
2084
2238
|
* @pg String
|
|
2085
2239
|
*/
|
|
2086
2240
|
"unicorn/consistent-template-literal-escape": "error",
|
|
2241
|
+
"unicorn/escape-case": "error",
|
|
2242
|
+
"unicorn/no-invalid-character-comparison": "error",
|
|
2243
|
+
"unicorn/no-unnecessary-string-trim": "error",
|
|
2244
|
+
"unicorn/no-unsafe-string-replacement": "error",
|
|
2087
2245
|
"unicorn/prefer-code-point": "error",
|
|
2088
2246
|
"unicorn/prefer-string-pad-start-end": "error",
|
|
2089
2247
|
"unicorn/prefer-string-repeat": "error",
|
|
2090
2248
|
"unicorn/prefer-string-slice": "error",
|
|
2091
2249
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2092
2250
|
"unicorn/prefer-string-trim-start-end": "error",
|
|
2251
|
+
"unicorn/prefer-unicode-code-point-escapes": "error",
|
|
2093
2252
|
/**
|
|
2094
2253
|
* @pg DOM
|
|
2095
2254
|
*/
|
|
2096
2255
|
"unicorn/better-dom-traversing": "error",
|
|
2097
2256
|
"unicorn/dom-node-dataset": "error",
|
|
2098
2257
|
"unicorn/no-incorrect-query-selector": "error",
|
|
2258
|
+
"unicorn/no-invalid-boolean-attribute-value": "error",
|
|
2259
|
+
"unicorn/no-invalid-dom-token": "error",
|
|
2260
|
+
"unicorn/no-invalid-file-input-accept": "error",
|
|
2099
2261
|
"unicorn/no-invalid-remove-event-listener": "error",
|
|
2262
|
+
"unicorn/no-invalid-style-set-property": "error",
|
|
2263
|
+
"unicorn/no-late-current-target-access": "error",
|
|
2264
|
+
"unicorn/no-prevent-default-in-passive-listener": "error",
|
|
2100
2265
|
"unicorn/prefer-add-event-listener": "error",
|
|
2101
2266
|
"unicorn/prefer-classlist-toggle": "error",
|
|
2102
2267
|
"unicorn/prefer-dom-node-append": "error",
|
|
@@ -2104,6 +2269,7 @@ const configUnicorn = (options = {}) => {
|
|
|
2104
2269
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
2105
2270
|
"unicorn/prefer-modern-dom-apis": "error",
|
|
2106
2271
|
"unicorn/prefer-query-selector": "error",
|
|
2272
|
+
"unicorn/prefer-toggle-attribute": "error",
|
|
2107
2273
|
/**
|
|
2108
2274
|
* @pg Array
|
|
2109
2275
|
*/
|
|
@@ -2118,37 +2284,73 @@ const configUnicorn = (options = {}) => {
|
|
|
2118
2284
|
"unicorn/no-array-fill-with-reference-type": "error",
|
|
2119
2285
|
"unicorn/no-array-from-fill": "error",
|
|
2120
2286
|
"unicorn/no-array-method-this-argument": "error",
|
|
2287
|
+
"unicorn/no-boolean-sort-comparator": "error",
|
|
2121
2288
|
"unicorn/no-confusing-array-splice": "error",
|
|
2289
|
+
"unicorn/no-confusing-array-with": "error",
|
|
2290
|
+
"unicorn/no-duplicate-loops": "error",
|
|
2122
2291
|
"unicorn/no-new-array": "error",
|
|
2123
2292
|
"unicorn/no-unnecessary-array-flat-depth": "error",
|
|
2124
2293
|
"unicorn/no-unnecessary-array-splice-count": "error",
|
|
2125
2294
|
"unicorn/no-unnecessary-slice-end": "error",
|
|
2126
|
-
"unicorn/no-unused-array-method-return": "error",
|
|
2127
2295
|
"unicorn/prefer-array-find": "error",
|
|
2128
2296
|
"unicorn/prefer-array-flat-map": "error",
|
|
2297
|
+
"unicorn/prefer-array-from-range": "error",
|
|
2129
2298
|
"unicorn/prefer-array-index-of": "error",
|
|
2130
2299
|
"unicorn/prefer-array-some": "error",
|
|
2300
|
+
"unicorn/prefer-includes": "error",
|
|
2131
2301
|
"unicorn/prefer-includes-over-repeated-comparisons": "error",
|
|
2302
|
+
"unicorn/prefer-single-array-predicate": "error",
|
|
2132
2303
|
"unicorn/prefer-single-call": "error",
|
|
2133
2304
|
"unicorn/require-array-join-separator": "error",
|
|
2134
2305
|
/**
|
|
2306
|
+
* @pg Iterator
|
|
2307
|
+
*/
|
|
2308
|
+
"unicorn/no-async-iterator-callback": "error",
|
|
2309
|
+
"unicorn/no-unused-iterator-helper": "error",
|
|
2310
|
+
"unicorn/no-useless-iterator-to-array": "error",
|
|
2311
|
+
/**
|
|
2135
2312
|
* @pg Set
|
|
2136
2313
|
*/
|
|
2137
2314
|
"unicorn/no-duplicate-set-values": "error",
|
|
2315
|
+
"unicorn/no-useless-set-construction": "error",
|
|
2138
2316
|
"unicorn/prefer-set-has": "error",
|
|
2139
2317
|
"unicorn/prefer-set-size": "error",
|
|
2140
2318
|
/**
|
|
2319
|
+
* @pg Map
|
|
2320
|
+
*/
|
|
2321
|
+
"unicorn/prefer-has-check": "error",
|
|
2322
|
+
/**
|
|
2323
|
+
* @pg Object
|
|
2324
|
+
*/
|
|
2325
|
+
"unicorn/consistent-conditional-object-spread": ["error", "ternary"],
|
|
2326
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
2327
|
+
"unicorn/no-collection-bracket-access": "error",
|
|
2328
|
+
"unicorn/no-invalid-property-descriptor": "error",
|
|
2329
|
+
"unicorn/no-object-methods-with-collections": "error",
|
|
2330
|
+
"unicorn/no-unsafe-property-key": "error",
|
|
2331
|
+
"unicorn/prefer-object-from-entries": "error",
|
|
2332
|
+
"unicorn/prefer-single-object-destructuring": "error",
|
|
2333
|
+
/**
|
|
2334
|
+
* @pg Data
|
|
2335
|
+
*/
|
|
2336
|
+
"unicorn/consistent-json-file-read": "error",
|
|
2337
|
+
"unicorn/no-unsafe-buffer-conversion": "error",
|
|
2338
|
+
"unicorn/no-unsafe-json-serialization": "error",
|
|
2339
|
+
"unicorn/prefer-structured-clone": "error",
|
|
2340
|
+
/**
|
|
2141
2341
|
* @pg Module
|
|
2142
2342
|
*/
|
|
2143
2343
|
"unicorn/no-exports-in-scripts": "error",
|
|
2344
|
+
"unicorn/no-useless-re-export": "error",
|
|
2345
|
+
"unicorn/prefer-import-meta-properties": "error",
|
|
2346
|
+
"unicorn/prefer-node-protocol": "error",
|
|
2144
2347
|
"unicorn/require-module-attributes": "error",
|
|
2145
2348
|
"unicorn/require-module-specifiers": "error",
|
|
2146
2349
|
...options.overrides
|
|
2147
2350
|
}
|
|
2148
2351
|
}];
|
|
2149
2352
|
};
|
|
2150
|
-
|
|
2151
|
-
//#region src/configs/deMorgan.ts
|
|
2353
|
+
// src/configs/deMorgan.ts
|
|
2152
2354
|
/**
|
|
2153
2355
|
* Config for optimize logic
|
|
2154
2356
|
*
|
|
@@ -2165,8 +2367,7 @@ const configDeMorgan = (options = {}) => [{
|
|
|
2165
2367
|
...options.overrides
|
|
2166
2368
|
}
|
|
2167
2369
|
}];
|
|
2168
|
-
|
|
2169
|
-
//#region src/configs/markdown.ts
|
|
2370
|
+
// src/configs/markdown.ts
|
|
2170
2371
|
/**
|
|
2171
2372
|
* Config for markdown files
|
|
2172
2373
|
*
|
|
@@ -2198,7 +2399,7 @@ const configMarkdown = (options = {}) => {
|
|
|
2198
2399
|
languageOptions: { parser: parserPlain }
|
|
2199
2400
|
},
|
|
2200
2401
|
{
|
|
2201
|
-
name: "ntnyq/markdown/
|
|
2402
|
+
name: "ntnyq/markdown/code-blocks",
|
|
2202
2403
|
files: [...files, ...extraFileExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*${ext}`)],
|
|
2203
2404
|
languageOptions: { parserOptions: {
|
|
2204
2405
|
project: false,
|
|
@@ -2231,8 +2432,7 @@ const configMarkdown = (options = {}) => {
|
|
|
2231
2432
|
}
|
|
2232
2433
|
];
|
|
2233
2434
|
};
|
|
2234
|
-
|
|
2235
|
-
//#region src/configs/prettier.ts
|
|
2435
|
+
// src/configs/prettier.ts
|
|
2236
2436
|
/**
|
|
2237
2437
|
* Config for using prettier
|
|
2238
2438
|
*
|
|
@@ -2355,6 +2555,10 @@ const PERFECTIONIST = Object.freeze({
|
|
|
2355
2555
|
],
|
|
2356
2556
|
sortExportAttributesGroups: ["unknown"],
|
|
2357
2557
|
sortExportsGroups: [
|
|
2558
|
+
"wildcard-export",
|
|
2559
|
+
"named-export",
|
|
2560
|
+
"singleline-export",
|
|
2561
|
+
"multiline-export",
|
|
2358
2562
|
"value-export",
|
|
2359
2563
|
"type-export",
|
|
2360
2564
|
"unknown"
|
|
@@ -2427,8 +2631,7 @@ const PERFECTIONIST = Object.freeze({
|
|
|
2427
2631
|
"unknown"
|
|
2428
2632
|
]
|
|
2429
2633
|
});
|
|
2430
|
-
|
|
2431
|
-
//#region src/configs/specials.ts
|
|
2634
|
+
// src/configs/specials.ts
|
|
2432
2635
|
/**
|
|
2433
2636
|
* Config for special files
|
|
2434
2637
|
*
|
|
@@ -2436,87 +2639,88 @@ const PERFECTIONIST = Object.freeze({
|
|
|
2436
2639
|
* @returns ESLint configs
|
|
2437
2640
|
*/
|
|
2438
2641
|
const configSpecials = (options = {}) => {
|
|
2439
|
-
const { shadcnVue: enableShadcnVue = hasShadcnVue() } = options;
|
|
2440
|
-
const
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
{
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
{
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2642
|
+
const { additionalConfigs, bin: enableBin = true, cli: enableCli = true, configFiles: enableConfigFiles = true, scripts: enableScripts = true, shadcnVue: enableShadcnVue = hasShadcnVue(), userScripts: enableUserScripts = true } = options;
|
|
2643
|
+
const binOptions = resolveSubOptions(options, "bin");
|
|
2644
|
+
const cliOptions = resolveSubOptions(options, "cli");
|
|
2645
|
+
const configFilesOptions = resolveSubOptions(options, "configFiles");
|
|
2646
|
+
const scriptsOptions = resolveSubOptions(options, "scripts");
|
|
2647
|
+
const shadcnVueOptions = resolveSubOptions(options, "shadcnVue");
|
|
2648
|
+
const userScriptsOptions = resolveSubOptions(options, "userScripts");
|
|
2649
|
+
const configs = [];
|
|
2650
|
+
if (enableScripts) configs.push({
|
|
2651
|
+
name: "ntnyq/specials/scripts",
|
|
2652
|
+
files: scriptsOptions.files ?? [`**/scripts/**/*.?([cm])[jt]s?(x)`],
|
|
2653
|
+
rules: {
|
|
2654
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2655
|
+
"no-console": "off",
|
|
2656
|
+
...scriptsOptions.overrides
|
|
2657
|
+
}
|
|
2658
|
+
});
|
|
2659
|
+
if (enableCli) configs.push({
|
|
2660
|
+
name: "ntnyq/specials/cli",
|
|
2661
|
+
files: cliOptions.files ?? [`**/cli/**/*.?([cm])[jt]s?(x)`, `**/cli.?([cm])[jt]s?(x)`],
|
|
2662
|
+
rules: {
|
|
2663
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2664
|
+
"no-console": "off",
|
|
2665
|
+
...cliOptions.overrides
|
|
2666
|
+
}
|
|
2667
|
+
});
|
|
2668
|
+
if (enableBin) configs.push({
|
|
2669
|
+
name: "ntnyq/specials/bin",
|
|
2670
|
+
files: binOptions.files ?? [`**/bin/**/*.?([cm])[jt]s?(x)`, `**/bin.?([cm])[jt]s?(x)`],
|
|
2671
|
+
rules: {
|
|
2672
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2673
|
+
"antfu/no-import-dist": "off",
|
|
2674
|
+
"no-console": "off",
|
|
2675
|
+
...binOptions.overrides
|
|
2676
|
+
}
|
|
2677
|
+
});
|
|
2678
|
+
if (enableUserScripts) configs.push({
|
|
2679
|
+
name: "ntnyq/specials/userscript",
|
|
2680
|
+
files: userScriptsOptions.files ?? [`**/*.user.?([cm])[jt]s?(x)`],
|
|
2681
|
+
languageOptions: { globals: { ...globals.greasemonkey } },
|
|
2682
|
+
rules: {
|
|
2683
|
+
camelcase: ["error", { allow: ["^GM_.+"] }],
|
|
2684
|
+
...userScriptsOptions.overrides
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
if (enableConfigFiles) configs.push({
|
|
2688
|
+
name: "ntnyq/specials/config-file",
|
|
2689
|
+
files: configFilesOptions.files ?? [`**/*.config*.?([cm])[jt]s?(x)`],
|
|
2690
|
+
plugins: {
|
|
2691
|
+
"import-x": pluginImportX,
|
|
2692
|
+
perfectionist: pluginPerfectionist
|
|
2477
2693
|
},
|
|
2478
|
-
{
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
"import-x/no-default-export": "off",
|
|
2489
|
-
"no-console": "off",
|
|
2490
|
-
"perfectionist/sort-objects": ["error", {
|
|
2491
|
-
...PERFECTIONIST.partialRuleOptions,
|
|
2492
|
-
groups: PERFECTIONIST.sortObjectsGroups
|
|
2493
|
-
}],
|
|
2494
|
-
...options.overridesConfigFileRules
|
|
2495
|
-
}
|
|
2694
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2695
|
+
rules: {
|
|
2696
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2697
|
+
"import-x/no-default-export": "off",
|
|
2698
|
+
"no-console": "off",
|
|
2699
|
+
"perfectionist/sort-objects": ["error", {
|
|
2700
|
+
...PERFECTIONIST.partialRuleOptions,
|
|
2701
|
+
groups: PERFECTIONIST.sortObjectsGroups
|
|
2702
|
+
}],
|
|
2703
|
+
...configFilesOptions.overrides
|
|
2496
2704
|
}
|
|
2497
|
-
|
|
2498
|
-
if (enableShadcnVue) {
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
});
|
|
2514
|
-
}
|
|
2515
|
-
if (options.specialCaseConfigs) configs.push(...options.specialCaseConfigs);
|
|
2705
|
+
});
|
|
2706
|
+
if (enableShadcnVue) configs.push({
|
|
2707
|
+
name: "ntnyq/specials/shadcn-vue",
|
|
2708
|
+
files: shadcnVueOptions.files ?? ["**/components/ui/**/*.ts", "**/components/ui/**/*.vue"],
|
|
2709
|
+
rules: {
|
|
2710
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
2711
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
2712
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
2713
|
+
"vue/define-emits-declaration": "off",
|
|
2714
|
+
"vue/html-button-has-type": "off",
|
|
2715
|
+
"vue/no-duplicate-attr-inheritance": "off",
|
|
2716
|
+
"vue/prefer-use-template-ref": "off",
|
|
2717
|
+
...shadcnVueOptions.overrides
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
if (additionalConfigs) configs.push(...additionalConfigs);
|
|
2516
2721
|
return configs;
|
|
2517
2722
|
};
|
|
2518
|
-
|
|
2519
|
-
//#region src/configs/gitignore.ts
|
|
2723
|
+
// src/configs/gitignore.ts
|
|
2520
2724
|
/**
|
|
2521
2725
|
* Config for respect `.gitignore`
|
|
2522
2726
|
*
|
|
@@ -2526,14 +2730,15 @@ const configSpecials = (options = {}) => {
|
|
|
2526
2730
|
* @returns ESLint configs
|
|
2527
2731
|
*/
|
|
2528
2732
|
const configGitIgnore = (options = {}) => {
|
|
2529
|
-
options.strict ??= false;
|
|
2530
2733
|
return [{
|
|
2531
|
-
...createGitIgnoreConfig(
|
|
2734
|
+
...createGitIgnoreConfig({
|
|
2735
|
+
...options,
|
|
2736
|
+
strict: options.strict ?? false
|
|
2737
|
+
}),
|
|
2532
2738
|
name: "ntnyq/gitignore"
|
|
2533
2739
|
}];
|
|
2534
2740
|
};
|
|
2535
|
-
|
|
2536
|
-
//#region src/configs/javascript.ts
|
|
2741
|
+
// src/configs/javascript.ts
|
|
2537
2742
|
const strictRules = {
|
|
2538
2743
|
complexity: ["error", { max: 30 }],
|
|
2539
2744
|
"max-depth": ["error", { max: 5 }],
|
|
@@ -2562,9 +2767,9 @@ const configJavaScript = (options = {}) => {
|
|
|
2562
2767
|
const { ecmaVersion = "latest" } = options;
|
|
2563
2768
|
return [{
|
|
2564
2769
|
...jsConfig.configs.recommended,
|
|
2565
|
-
name: "ntnyq/
|
|
2770
|
+
name: "ntnyq/javascript/recommended"
|
|
2566
2771
|
}, {
|
|
2567
|
-
name: "ntnyq/
|
|
2772
|
+
name: "ntnyq/javascript/core",
|
|
2568
2773
|
languageOptions: {
|
|
2569
2774
|
ecmaVersion,
|
|
2570
2775
|
sourceType: "module",
|
|
@@ -2741,8 +2946,7 @@ const configJSX = () => [{
|
|
|
2741
2946
|
files: [GLOB_JSX_ONLY],
|
|
2742
2947
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
|
|
2743
2948
|
}];
|
|
2744
|
-
|
|
2745
|
-
//#region src/configs/typescript.ts
|
|
2949
|
+
// src/configs/typescript.ts
|
|
2746
2950
|
/**
|
|
2747
2951
|
* @see {@link https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts}
|
|
2748
2952
|
*/
|
|
@@ -2802,7 +3006,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2802
3006
|
const { allowDefaultProject = [], ecmaVersion = "latest", extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
2803
3007
|
const files = options.files ?? [
|
|
2804
3008
|
"**/*.?([cm])ts",
|
|
2805
|
-
|
|
3009
|
+
"**/*.?([cm])tsx",
|
|
2806
3010
|
...extraFileExtensions.map((ext) => `**/*${ext}`)
|
|
2807
3011
|
];
|
|
2808
3012
|
function createParserConfig(enableTypeAware = false, files = [], ignores = []) {
|
|
@@ -2820,7 +3024,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2820
3024
|
...parserOptions
|
|
2821
3025
|
};
|
|
2822
3026
|
return {
|
|
2823
|
-
name: `ntnyq/
|
|
3027
|
+
name: `ntnyq/typescript/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
2824
3028
|
files,
|
|
2825
3029
|
ignores: [...ignores],
|
|
2826
3030
|
languageOptions: {
|
|
@@ -2831,7 +3035,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2831
3035
|
}
|
|
2832
3036
|
return [
|
|
2833
3037
|
{
|
|
2834
|
-
name: "ntnyq/
|
|
3038
|
+
name: "ntnyq/typescript/setup",
|
|
2835
3039
|
plugins: {
|
|
2836
3040
|
"@typescript-eslint": pluginTypeScript,
|
|
2837
3041
|
antfu: pluginAntfu
|
|
@@ -2839,7 +3043,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2839
3043
|
},
|
|
2840
3044
|
...enableTypeAwareLint ? [createParserConfig(false, files), createParserConfig(true, filesTypeAware, ignoresTypeAware)] : [createParserConfig(false, files)],
|
|
2841
3045
|
{
|
|
2842
|
-
name: "ntnyq/
|
|
3046
|
+
name: "ntnyq/typescript/rules",
|
|
2843
3047
|
files,
|
|
2844
3048
|
rules: {
|
|
2845
3049
|
...recommendedRules,
|
|
@@ -2914,7 +3118,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2914
3118
|
}
|
|
2915
3119
|
},
|
|
2916
3120
|
...enableTypeAwareLint ? [{
|
|
2917
|
-
name: "ntnyq/
|
|
3121
|
+
name: "ntnyq/typescript/rules/type-aware",
|
|
2918
3122
|
files: [...filesTypeAware],
|
|
2919
3123
|
ignores: [...ignoresTypeAware],
|
|
2920
3124
|
rules: {
|
|
@@ -2923,7 +3127,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2923
3127
|
}
|
|
2924
3128
|
}] : [],
|
|
2925
3129
|
{
|
|
2926
|
-
name: "ntnyq/
|
|
3130
|
+
name: "ntnyq/typescript/types",
|
|
2927
3131
|
files: [...GLOB_TYPES],
|
|
2928
3132
|
rules: {
|
|
2929
3133
|
"@typescript-eslint/no-use-before-define": "off",
|
|
@@ -2937,8 +3141,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2937
3141
|
}
|
|
2938
3142
|
];
|
|
2939
3143
|
};
|
|
2940
|
-
|
|
2941
|
-
//#region src/configs/eslintPlugin.ts
|
|
3144
|
+
// src/configs/eslintPlugin.ts
|
|
2942
3145
|
/**
|
|
2943
3146
|
* Config for eslint plugin
|
|
2944
3147
|
*
|
|
@@ -2960,8 +3163,7 @@ const configESLintPlugin = async (options = {}) => {
|
|
|
2960
3163
|
}
|
|
2961
3164
|
}];
|
|
2962
3165
|
};
|
|
2963
|
-
|
|
2964
|
-
//#region src/configs/githubAction.ts
|
|
3166
|
+
// src/configs/githubAction.ts
|
|
2965
3167
|
/**
|
|
2966
3168
|
* Config for github action files
|
|
2967
3169
|
*
|
|
@@ -2987,8 +3189,7 @@ const configGitHubAction = (options = {}) => {
|
|
|
2987
3189
|
}
|
|
2988
3190
|
}];
|
|
2989
3191
|
};
|
|
2990
|
-
|
|
2991
|
-
//#region src/configs/perfectionist.ts
|
|
3192
|
+
// src/configs/perfectionist.ts
|
|
2992
3193
|
/**
|
|
2993
3194
|
* Config for sorting imports, exports, objects and etc
|
|
2994
3195
|
*
|
|
@@ -2998,7 +3199,14 @@ const configGitHubAction = (options = {}) => {
|
|
|
2998
3199
|
* @returns ESLint configs
|
|
2999
3200
|
*/
|
|
3000
3201
|
const configPerfectionist = (options = {}) => {
|
|
3001
|
-
const {
|
|
3202
|
+
const { all: enableAll = false, constants: enableSortConstants = true, enums: enableSortEnums = true, partitionByComment = PERFECTIONIST.partialRuleOptions.partitionByComment, types: enableSortTypes = true } = options;
|
|
3203
|
+
const commonOptions = resolveSubOptions(options, "common");
|
|
3204
|
+
const constantsOptions = resolveSubOptions(options, "constants");
|
|
3205
|
+
const enumsOptions = resolveSubOptions(options, "enums");
|
|
3206
|
+
const typesOptions = resolveSubOptions(options, "types");
|
|
3207
|
+
const filesConstants = constantsOptions.files ?? [`**/constants/**/*.?([cm])[jt]s?(x)`, `**/constants.?([cm])[jt]s?(x)`];
|
|
3208
|
+
const filesEnums = enumsOptions.files ?? [`**/enums/**/*.?([cm])[jt]s?(x)`, `**/enums.?([cm])[jt]s?(x)`];
|
|
3209
|
+
const filesTypes = typesOptions.files ?? [...GLOB_TYPES];
|
|
3002
3210
|
const sharedOptionsWithNewlinesBetween = {
|
|
3003
3211
|
newlinesBetween: "ignore",
|
|
3004
3212
|
partitionByComment
|
|
@@ -3092,21 +3300,21 @@ const configPerfectionist = (options = {}) => {
|
|
|
3092
3300
|
settings: { perfectionist: PERFECTIONIST.pluginSettings }
|
|
3093
3301
|
};
|
|
3094
3302
|
const configs = [{
|
|
3095
|
-
name:
|
|
3303
|
+
name: enableAll ? "ntnyq/perfectionist/all" : "ntnyq/perfectionist/common",
|
|
3096
3304
|
...sharedConfig,
|
|
3097
3305
|
rules: {
|
|
3098
3306
|
...commonRules,
|
|
3099
|
-
...
|
|
3307
|
+
...enableAll ? {
|
|
3100
3308
|
...sharedRules,
|
|
3101
3309
|
...sortEnumsRules,
|
|
3102
3310
|
...sortTypesRules,
|
|
3103
3311
|
...sortConstantsRules,
|
|
3104
3312
|
...extraRules
|
|
3105
3313
|
} : {},
|
|
3106
|
-
...
|
|
3314
|
+
...commonOptions.overrides
|
|
3107
3315
|
}
|
|
3108
3316
|
}];
|
|
3109
|
-
if (
|
|
3317
|
+
if (enableAll) return configs;
|
|
3110
3318
|
if (enableSortEnums) configs.push({
|
|
3111
3319
|
name: "ntnyq/perfectionist/enums",
|
|
3112
3320
|
files: filesEnums,
|
|
@@ -3114,7 +3322,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
3114
3322
|
rules: {
|
|
3115
3323
|
...sharedRules,
|
|
3116
3324
|
...sortEnumsRules,
|
|
3117
|
-
...
|
|
3325
|
+
...enumsOptions.overrides
|
|
3118
3326
|
}
|
|
3119
3327
|
});
|
|
3120
3328
|
if (enableSortTypes) configs.push({
|
|
@@ -3124,7 +3332,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
3124
3332
|
rules: {
|
|
3125
3333
|
...sharedRules,
|
|
3126
3334
|
...sortTypesRules,
|
|
3127
|
-
...
|
|
3335
|
+
...typesOptions.overrides
|
|
3128
3336
|
}
|
|
3129
3337
|
});
|
|
3130
3338
|
if (enableSortConstants) configs.push({
|
|
@@ -3134,13 +3342,12 @@ const configPerfectionist = (options = {}) => {
|
|
|
3134
3342
|
rules: {
|
|
3135
3343
|
...sharedRules,
|
|
3136
3344
|
...sortConstantsRules,
|
|
3137
|
-
...
|
|
3345
|
+
...constantsOptions.overrides
|
|
3138
3346
|
}
|
|
3139
3347
|
});
|
|
3140
3348
|
return configs;
|
|
3141
3349
|
};
|
|
3142
|
-
|
|
3143
|
-
//#region src/configs/unusedImports.ts
|
|
3350
|
+
// src/configs/unusedImports.ts
|
|
3144
3351
|
/**
|
|
3145
3352
|
* Config for remove unused imports
|
|
3146
3353
|
*
|
|
@@ -3156,6 +3363,7 @@ const configUnusedImports = async (options = {}) => {
|
|
|
3156
3363
|
plugins: { "unused-imports": await interopDefault(import("eslint-plugin-unused-imports")) },
|
|
3157
3364
|
rules: {
|
|
3158
3365
|
"@typescript-eslint/no-unused-vars": "off",
|
|
3366
|
+
"no-unused-vars": "off",
|
|
3159
3367
|
"unused-imports/no-unused-imports": "error",
|
|
3160
3368
|
"unused-imports/no-unused-vars": ["error", {
|
|
3161
3369
|
args: "after-used",
|
|
@@ -3171,8 +3379,7 @@ const configUnusedImports = async (options = {}) => {
|
|
|
3171
3379
|
}
|
|
3172
3380
|
}];
|
|
3173
3381
|
};
|
|
3174
|
-
|
|
3175
|
-
//#region src/configs/eslintComments.ts
|
|
3382
|
+
// src/configs/eslintComments.ts
|
|
3176
3383
|
/**
|
|
3177
3384
|
* Config for eslint comments
|
|
3178
3385
|
*
|
|
@@ -3190,8 +3397,7 @@ const configESLintComments = (options = {}) => [{
|
|
|
3190
3397
|
...options.overrides
|
|
3191
3398
|
}
|
|
3192
3399
|
}];
|
|
3193
|
-
|
|
3194
|
-
//#region src/core.ts
|
|
3400
|
+
// src/core.ts
|
|
3195
3401
|
/**
|
|
3196
3402
|
* @file factory function to create ESLint config
|
|
3197
3403
|
*/
|
|
@@ -3199,7 +3405,7 @@ const configESLintComments = (options = {}) => [{
|
|
|
3199
3405
|
* Config factory
|
|
3200
3406
|
*/
|
|
3201
3407
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
3202
|
-
const { shareable = {}, ignores: userIgnores = [], vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = hasTypeScript(), oxfmt: enableOxfmt = hasOxfmt(), prettier: enablePrettier = hasPrettier(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, jsdoc: enableJsdoc = true, importX: enableImportX = true, specials: enableSpecials = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false, unusedImports: enableUnusedImports = false } = options;
|
|
3408
|
+
const { shareable = {}, ignores: userIgnores = [], vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = shareable.typescript ?? hasTypeScript(), oxfmt: enableOxfmt = hasOxfmt(), prettier: enablePrettier = hasPrettier(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, jsdoc: enableJsdoc = true, importX: enableImportX = true, specials: enableSpecials = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, shell: enableShell = false, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false, unusedImports: enableUnusedImports = false } = options;
|
|
3203
3409
|
const configs = [];
|
|
3204
3410
|
const { ecmaVersion = "latest", extraFileExtensions: shareableExtraFileExtensions = [] } = shareable;
|
|
3205
3411
|
const extraFileExtensions = [...shareableExtraFileExtensions];
|
|
@@ -3222,11 +3428,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3222
3428
|
overrides: getOverrides(options, "jsdoc"),
|
|
3223
3429
|
...resolveSubOptions(options, "jsdoc")
|
|
3224
3430
|
}));
|
|
3225
|
-
if (enablePerfectionist) configs.push(configPerfectionist(
|
|
3226
|
-
|
|
3227
|
-
|
|
3431
|
+
if (enablePerfectionist) configs.push(configPerfectionist(resolveSubOptions(options, "perfectionist")));
|
|
3432
|
+
if (enableUnicorn) configs.push(configUnicorn({
|
|
3433
|
+
...resolveSubOptions(options, "unicorn"),
|
|
3434
|
+
overrides: getOverrides(options, "unicorn")
|
|
3228
3435
|
}));
|
|
3229
|
-
if (enableUnicorn) configs.push(configUnicorn({ overrides: getOverrides(options, "unicorn") }));
|
|
3230
3436
|
if (enablePinia) configs.push(configPinia({
|
|
3231
3437
|
...resolveSubOptions(options, "pinia"),
|
|
3232
3438
|
overrides: getOverrides(options, "pinia")
|
|
@@ -3245,8 +3451,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3245
3451
|
if (enableVue) configs.push(configVue({
|
|
3246
3452
|
ecmaVersion,
|
|
3247
3453
|
usingFormatter: !!usingFormatter,
|
|
3248
|
-
...resolveSubOptions(options, "vue"),
|
|
3249
3454
|
typescript: !!enableTypeScript,
|
|
3455
|
+
...resolveSubOptions(options, "vue"),
|
|
3250
3456
|
overrides: getOverrides(options, "vue"),
|
|
3251
3457
|
extraFileExtensions
|
|
3252
3458
|
}));
|
|
@@ -3265,22 +3471,21 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3265
3471
|
overrides: getOverrides(options, "jsonc")
|
|
3266
3472
|
}));
|
|
3267
3473
|
if (enableAstro) configs.push(configAstro({
|
|
3268
|
-
|
|
3474
|
+
ecmaVersion,
|
|
3269
3475
|
typescript: !!enableTypeScript,
|
|
3476
|
+
...resolveSubOptions(options, "astro"),
|
|
3270
3477
|
overrides: getOverrides(options, "astro"),
|
|
3271
3478
|
extraFileExtensions
|
|
3272
3479
|
}));
|
|
3273
3480
|
if (enableSvelte) configs.push(configSvelte({
|
|
3274
|
-
|
|
3481
|
+
ecmaVersion,
|
|
3275
3482
|
typescript: !!enableTypeScript,
|
|
3483
|
+
...resolveSubOptions(options, "svelte"),
|
|
3276
3484
|
overrides: getOverrides(options, "svelte"),
|
|
3277
3485
|
extraFileExtensions
|
|
3278
3486
|
}));
|
|
3279
3487
|
if (enableSort) configs.push(configSort(resolveSubOptions(options, "sort")));
|
|
3280
|
-
if (enableTest) configs.push(configTest(
|
|
3281
|
-
...resolveSubOptions(options, "test"),
|
|
3282
|
-
overrides: getOverrides(options, "test")
|
|
3283
|
-
}));
|
|
3488
|
+
if (enableTest) configs.push(configTest(resolveSubOptions(options, "test")));
|
|
3284
3489
|
if (enableUnoCSS) configs.push(configUnoCSS({ overrides: getOverrides(options, "unocss") }));
|
|
3285
3490
|
if (enableMarkdown) configs.push(configMarkdown({
|
|
3286
3491
|
...resolveSubOptions(options, "markdown"),
|
|
@@ -3303,6 +3508,10 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3303
3508
|
overrides: getOverrides(options, "html")
|
|
3304
3509
|
}));
|
|
3305
3510
|
if (enableSpecials) configs.push(configSpecials(resolveSubOptions(options, "specials")));
|
|
3511
|
+
if (enableShell) configs.push(configShell({
|
|
3512
|
+
...resolveSubOptions(options, "shell"),
|
|
3513
|
+
overrides: getOverrides(options, "shell")
|
|
3514
|
+
}));
|
|
3306
3515
|
const formatterConfigs = [];
|
|
3307
3516
|
const prettierConfigs = configPrettier({
|
|
3308
3517
|
...resolveSubOptions(options, "prettier"),
|
|
@@ -3315,7 +3524,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3315
3524
|
if (options.__DEV__) formatterConfigs.push(...prettierConfigs, ...oxfmtConfigs);
|
|
3316
3525
|
else if (enablePrettier) formatterConfigs.push(...prettierConfigs);
|
|
3317
3526
|
else if (enableOxfmt) formatterConfigs.push(...oxfmtConfigs);
|
|
3318
|
-
|
|
3527
|
+
const composer = new FlatConfigComposer(...configs, ...userConfigs, ...formatterConfigs);
|
|
3528
|
+
if (enableShell) {
|
|
3529
|
+
const { files = [GLOB_SHELL] } = resolveSubOptions(options, "shell");
|
|
3530
|
+
return composer.setDefaultIgnores((ignores) => [...ignores, ...files]);
|
|
3531
|
+
}
|
|
3532
|
+
return composer;
|
|
3319
3533
|
}
|
|
3320
|
-
|
|
3321
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_EXTENSIONS, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_YAML, PERFECTIONIST, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configOxfmt, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasOxfmt, hasPinia, hasPrettier, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginDeMorgan, pluginDepend, pluginESLintComments, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNoOnlyTests, pluginNode, pluginNtnyq, pluginOxfmt, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|
|
3534
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SHELL, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_EXTENSIONS, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_VUE_COMPOSABLES, GLOB_YAML, PERFECTIONIST, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configOxfmt, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configShell, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasAutoImport, hasOxfmt, hasPinia, hasPrettier, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginDeMorgan, pluginDepend, pluginESLintComments, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNoOnlyTests, pluginNode, pluginNtnyq, pluginOxfmt, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginShell, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginVuePerfectionist, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|