@ntnyq/eslint-config 7.0.0-beta.2 → 7.0.0-beta.21
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 +4635 -1830
- package/dist/index.mjs +481 -302
- package/package.json +57 -57
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,7 @@ import pluginDeMorgan from "eslint-plugin-de-morgan";
|
|
|
29
29
|
import pluginNoOnlyTests from "eslint-plugin-no-only-tests";
|
|
30
30
|
import pluginGitHubAction from "eslint-plugin-github-action";
|
|
31
31
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
32
|
+
import pluginVuePerfectionist from "eslint-plugin-vue-perfectionist";
|
|
32
33
|
import * as pluginESLintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
33
34
|
import processorVueBlocks from "eslint-processor-vue-blocks";
|
|
34
35
|
import { resolve } from "node:path";
|
|
@@ -58,6 +59,9 @@ const GLOB_TYPES = [
|
|
|
58
59
|
`**/types/${GLOB_TS}`,
|
|
59
60
|
`**/types.ts`
|
|
60
61
|
];
|
|
62
|
+
const GLOB_VUE = "**/*.vue";
|
|
63
|
+
const GLOB_PINIA_STORE = `**/store?(s)/*.${GLOB_SRC_EXT}`;
|
|
64
|
+
const GLOB_VUE_COMPOSABLES = [`**/composables/*.${GLOB_SRC_EXT}`, `**/use*${GLOB_SRC_EXT}`];
|
|
61
65
|
const GLOB_TYPE_TEST = [`**/*.test-d.${GLOB_SRC_EXT}`, `**/*.spec-d.${GLOB_SRC_EXT}`];
|
|
62
66
|
const GLOB_TEST = [
|
|
63
67
|
`**/*.test.${GLOB_SRC_EXT}`,
|
|
@@ -79,8 +83,8 @@ const GLOB_JSON_SCHEMA = ["**/*.schema.json", "**/schemas/*.json"];
|
|
|
79
83
|
const GLOB_TSCONFIG_JSON = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
80
84
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
81
85
|
const GLOB_PNPM_WORKSPACE_YAML = "**/pnpm-workspace.yaml";
|
|
86
|
+
const GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
|
|
82
87
|
const GLOB_SVG = "**/*.svg";
|
|
83
|
-
const GLOB_VUE = "**/*.vue";
|
|
84
88
|
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
85
89
|
const GLOB_TOML = "**/*.toml";
|
|
86
90
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
@@ -103,8 +107,6 @@ const GLOB_ALL_SRC = [
|
|
|
103
107
|
GLOB_VUE,
|
|
104
108
|
...GLOB_SRC_EXTENSIONS
|
|
105
109
|
];
|
|
106
|
-
const GLOB_PINIA_STORE = `**/store?(s)/*.${GLOB_SRC_EXT}`;
|
|
107
|
-
const GLOB_GITHUB_ACTION = "**/.github/workflows/*.y?(a)ml";
|
|
108
110
|
const GLOB_NODE_MODULES = "**/node_modules/**";
|
|
109
111
|
const GLOB_DIST = "**/dist/**";
|
|
110
112
|
const GLOB_LOCKFILE = [
|
|
@@ -154,6 +156,9 @@ const GLOB_EXCLUDE = [
|
|
|
154
156
|
"**/.npmrc",
|
|
155
157
|
"**/.yarnrc",
|
|
156
158
|
"**/.husky",
|
|
159
|
+
"**/test-results/**",
|
|
160
|
+
"**/playwright-report/**",
|
|
161
|
+
"**/.playwright-cli/**",
|
|
157
162
|
"**/src-tauri/gen",
|
|
158
163
|
"**/src-tauri/target",
|
|
159
164
|
"**/*.context",
|
|
@@ -162,6 +167,127 @@ const GLOB_EXCLUDE = [
|
|
|
162
167
|
"**/.*/skills"
|
|
163
168
|
];
|
|
164
169
|
//#endregion
|
|
170
|
+
//#region src/utils/env.ts
|
|
171
|
+
/**
|
|
172
|
+
* Check whether Pinia is available in the current project.
|
|
173
|
+
*/
|
|
174
|
+
const hasPinia = () => isPackageExists("pinia");
|
|
175
|
+
/**
|
|
176
|
+
* Check whether Vitest is available in the current project.
|
|
177
|
+
*/
|
|
178
|
+
const hasVitest = () => isPackageExists("vitest");
|
|
179
|
+
/**
|
|
180
|
+
* Check whether TypeScript runtime or preview package is available.
|
|
181
|
+
*/
|
|
182
|
+
const hasTypeScript = () => isPackageExists("typescript") || isPackageExists("@typescript/native-preview");
|
|
183
|
+
/**
|
|
184
|
+
* Check whether shadcn-vue related dependencies are available.
|
|
185
|
+
*/
|
|
186
|
+
const hasShadcnVue = () => (isPackageExists("radix-vue") || isPackageExists("reka-ui")) && isPackageExists("class-variance-authority") && isPackageExists("clsx");
|
|
187
|
+
/**
|
|
188
|
+
* Check whether UnoCSS runtime packages are available.
|
|
189
|
+
*/
|
|
190
|
+
const hasUnoCSS = () => isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
191
|
+
/**
|
|
192
|
+
* Check whether Vue ecosystem packages are available.
|
|
193
|
+
*/
|
|
194
|
+
const hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", { paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")] });
|
|
195
|
+
/**
|
|
196
|
+
* Check whether oxfmt is available in the current project.
|
|
197
|
+
*/
|
|
198
|
+
const hasOxfmt = () => isPackageExists("oxfmt");
|
|
199
|
+
/**
|
|
200
|
+
* Check whether Prettier is available in the current project.
|
|
201
|
+
*/
|
|
202
|
+
const hasPrettier = () => isPackageExists("prettier");
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/utils/resolveSubOptions.ts
|
|
205
|
+
/**
|
|
206
|
+
* Normalize a sub-option value to an object.
|
|
207
|
+
*
|
|
208
|
+
* Boolean `true` means enabled with default options and returns an empty
|
|
209
|
+
* object; falsy values also fall back to an empty object.
|
|
210
|
+
*
|
|
211
|
+
* @param options - Options object that contains sub-options.
|
|
212
|
+
* @param key - Sub-option key to resolve.
|
|
213
|
+
* @returns Normalized sub-options object.
|
|
214
|
+
*/
|
|
215
|
+
function resolveSubOptions(options, key) {
|
|
216
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/utils/getOverrides.ts
|
|
220
|
+
/**
|
|
221
|
+
* Read rule overrides from a config sub-option.
|
|
222
|
+
*
|
|
223
|
+
* @param options - Top-level config options.
|
|
224
|
+
* @param key - Sub-option key to read.
|
|
225
|
+
* @returns Rule override map when provided, otherwise an empty object.
|
|
226
|
+
*/
|
|
227
|
+
function getOverrides(options, key) {
|
|
228
|
+
const subOptions = resolveSubOptions(options, key);
|
|
229
|
+
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/utils/isInGitHooksOrRunBySpecifyPackages.ts
|
|
233
|
+
const CHECKED_RUNNER_PACKAGES = [
|
|
234
|
+
"nano-staged",
|
|
235
|
+
"lint-staged",
|
|
236
|
+
"lefthook",
|
|
237
|
+
"tsx"
|
|
238
|
+
];
|
|
239
|
+
/**
|
|
240
|
+
* Detect whether current execution is triggered by git hook tooling.
|
|
241
|
+
*/
|
|
242
|
+
function isInGitHooksOrRunBySpecifyPackages() {
|
|
243
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || CHECKED_RUNNER_PACKAGES.some((packageName) => process.env.npm_lifecycle_script?.startsWith(packageName)));
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/utils/ensurePackages.ts
|
|
247
|
+
/**
|
|
248
|
+
* @copyright {@link https://github.com/antfu/eslint-config}
|
|
249
|
+
*/
|
|
250
|
+
const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
|
|
251
|
+
/**
|
|
252
|
+
* Check whether a package can be resolved from this config package scope.
|
|
253
|
+
*/
|
|
254
|
+
function isPackageInScope(name) {
|
|
255
|
+
return isPackageExists(name, { paths: [import.meta.dirname] });
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Ensure required packages are installed for optional config features.
|
|
259
|
+
*
|
|
260
|
+
* Skips installation prompts in CI, non-TTY environments, git hooks, and
|
|
261
|
+
* when the current project is outside the config usage scope.
|
|
262
|
+
*
|
|
263
|
+
* @param packages - Package names to verify and optionally install.
|
|
264
|
+
*/
|
|
265
|
+
async function ensurePackages(packages) {
|
|
266
|
+
if (process.env.CI || !process.stdout.isTTY || isInGitHooksOrRunBySpecifyPackages() || !isCwdInScope) return;
|
|
267
|
+
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
268
|
+
if (nonExistingPackages.length === 0) return;
|
|
269
|
+
const { confirm, isCancel } = await import("@clack/prompts");
|
|
270
|
+
const confirmInstall = await confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
|
|
271
|
+
if (isCancel(confirmInstall) || !confirmInstall) return;
|
|
272
|
+
try {
|
|
273
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
274
|
+
await installPackage(nonExistingPackages, { dev: true });
|
|
275
|
+
} catch (error) {
|
|
276
|
+
throw new Error(`Failed to install required packages: ${nonExistingPackages.join(", ")}`, { cause: error });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region 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
|
+
//#endregion
|
|
165
291
|
//#region src/configs/vue.ts
|
|
166
292
|
const sharedRules = {
|
|
167
293
|
...pluginVue.configs.base.rules,
|
|
@@ -342,7 +468,8 @@ const unCategorizedRules = {
|
|
|
342
468
|
* @returns ESLint configs
|
|
343
469
|
*/
|
|
344
470
|
const configVue = (options = {}) => {
|
|
345
|
-
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [] } = options;
|
|
471
|
+
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [], typescript = false, vuePerfectionist: enableVuePerfectionist = false } = options;
|
|
472
|
+
const vuePerfectionistOptions = resolveSubOptions(options, "vuePerfectionist");
|
|
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: {
|
|
@@ -502,6 +629,43 @@ const configVue = (options = {}) => {
|
|
|
502
629
|
...options.overrides
|
|
503
630
|
}
|
|
504
631
|
}];
|
|
632
|
+
if (enableVuePerfectionist) configs.push({
|
|
633
|
+
name: "ntnyq/vue/vue-perfectionist",
|
|
634
|
+
files: vuePerfectionistOptions.files ?? [
|
|
635
|
+
"**/*.vue",
|
|
636
|
+
GLOB_PINIA_STORE,
|
|
637
|
+
...GLOB_VUE_COMPOSABLES
|
|
638
|
+
],
|
|
639
|
+
plugins: { "vue-perfectionist": pluginVuePerfectionist },
|
|
640
|
+
rules: {
|
|
641
|
+
"vue-perfectionist/callback-style": "error",
|
|
642
|
+
"vue-perfectionist/define-macros-newline": "error",
|
|
643
|
+
"vue-perfectionist/prefer-ref-pattern": "error",
|
|
644
|
+
"vue-perfectionist/sort-script-setup": ["error", { groups: [
|
|
645
|
+
["interface", "type"],
|
|
646
|
+
"define-props",
|
|
647
|
+
"define-emits",
|
|
648
|
+
"define-options",
|
|
649
|
+
"define-slots",
|
|
650
|
+
"define-model",
|
|
651
|
+
"constant",
|
|
652
|
+
"inject",
|
|
653
|
+
"composable",
|
|
654
|
+
"template-ref",
|
|
655
|
+
["ref", "reactive"],
|
|
656
|
+
"computed",
|
|
657
|
+
"variable",
|
|
658
|
+
["enum", "class"],
|
|
659
|
+
"function",
|
|
660
|
+
"watch",
|
|
661
|
+
"lifecycle-hook",
|
|
662
|
+
"provide",
|
|
663
|
+
"define-expose"
|
|
664
|
+
] }],
|
|
665
|
+
...vuePerfectionistOptions.overrides
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
return configs;
|
|
505
669
|
};
|
|
506
670
|
//#endregion
|
|
507
671
|
//#region src/configs/yml.ts
|
|
@@ -572,127 +736,6 @@ const configYml = (options = {}) => {
|
|
|
572
736
|
}];
|
|
573
737
|
};
|
|
574
738
|
//#endregion
|
|
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
739
|
//#region src/configs/html.ts
|
|
697
740
|
/**
|
|
698
741
|
* Config for html files
|
|
@@ -717,7 +760,7 @@ const configHtml = async (options = {}) => {
|
|
|
717
760
|
"@html-eslint/indent": "error",
|
|
718
761
|
"@html-eslint/no-duplicate-attrs": "error",
|
|
719
762
|
"@html-eslint/no-duplicate-id": "error",
|
|
720
|
-
"@html-eslint/no-extra-spacing-
|
|
763
|
+
"@html-eslint/no-extra-spacing-tags": "error",
|
|
721
764
|
"@html-eslint/no-multiple-h1": "error",
|
|
722
765
|
"@html-eslint/no-obsolete-tags": "error",
|
|
723
766
|
"@html-eslint/quotes": "error",
|
|
@@ -753,6 +796,8 @@ const configNode = (options = {}) => [{
|
|
|
753
796
|
"node/no-path-concat": "error",
|
|
754
797
|
"node/prefer-global/buffer": ["error", "never"],
|
|
755
798
|
"node/prefer-global/process": ["error", "never"],
|
|
799
|
+
"node/prefer-import/assert-strict": "error",
|
|
800
|
+
"node/prefer-process-get-builtin-module": "error",
|
|
756
801
|
"node/process-exit-as-throw": "error",
|
|
757
802
|
...options.overrides
|
|
758
803
|
}
|
|
@@ -768,30 +813,36 @@ const configNode = (options = {}) => [{
|
|
|
768
813
|
* @returns ESLint configs
|
|
769
814
|
*/
|
|
770
815
|
const configPnpm = async (options = {}) => {
|
|
816
|
+
const { json: enableJson = true, yaml: enableYaml = true } = options;
|
|
817
|
+
const jsonOptions = resolveSubOptions(options, "json");
|
|
818
|
+
const yamlOptions = resolveSubOptions(options, "yaml");
|
|
819
|
+
if (!enableJson && !enableYaml) return [];
|
|
771
820
|
await ensurePackages(["eslint-plugin-pnpm"]);
|
|
772
821
|
const pluginPnpm = await interopDefault(import("eslint-plugin-pnpm"));
|
|
773
|
-
const
|
|
774
|
-
|
|
822
|
+
const configs = [];
|
|
823
|
+
if (enableJson) configs.push({
|
|
775
824
|
name: "ntnyq/pnpm/package-json",
|
|
776
|
-
files:
|
|
825
|
+
files: jsonOptions.files ?? ["**/package.json"],
|
|
777
826
|
plugins: { pnpm: pluginPnpm },
|
|
778
827
|
languageOptions: { parser: parserJsonc },
|
|
779
828
|
rules: {
|
|
780
829
|
"pnpm/json-enforce-catalog": ["error", { autofix: true }],
|
|
781
830
|
"pnpm/json-valid-catalog": "error",
|
|
782
|
-
...
|
|
831
|
+
...jsonOptions.overrides
|
|
783
832
|
}
|
|
784
|
-
}
|
|
833
|
+
});
|
|
834
|
+
if (enableYaml) configs.push({
|
|
785
835
|
name: "ntnyq/pnpm/pnpm-workspace-yaml",
|
|
786
|
-
files:
|
|
836
|
+
files: yamlOptions.files ?? ["**/pnpm-workspace.yaml"],
|
|
787
837
|
plugins: { pnpm: pluginPnpm },
|
|
788
838
|
languageOptions: { parser: parserYaml },
|
|
789
839
|
rules: {
|
|
790
840
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
791
841
|
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
792
|
-
...
|
|
842
|
+
...yamlOptions.overrides
|
|
793
843
|
}
|
|
794
|
-
}
|
|
844
|
+
});
|
|
845
|
+
return configs;
|
|
795
846
|
};
|
|
796
847
|
//#endregion
|
|
797
848
|
//#region src/configs/sort.ts
|
|
@@ -1229,23 +1280,26 @@ const configSVGO = (options = {}) => {
|
|
|
1229
1280
|
* @returns ESLint configs
|
|
1230
1281
|
*/
|
|
1231
1282
|
const configTest = (options = {}) => {
|
|
1232
|
-
const { files = [...GLOB_TEST], vitest: enableVitest = hasVitest() } = options;
|
|
1233
|
-
const
|
|
1283
|
+
const { files = [...GLOB_TEST], base: enableBase = true, vitest: enableVitest = hasVitest() } = options;
|
|
1284
|
+
const baseOptions = resolveSubOptions(options, "base");
|
|
1285
|
+
const vitestOptions = resolveSubOptions(options, "vitest");
|
|
1286
|
+
const configs = [];
|
|
1287
|
+
if (enableBase) configs.push({
|
|
1234
1288
|
name: "ntnyq/test/setup",
|
|
1235
1289
|
plugins: { "no-only-tests": pluginNoOnlyTests }
|
|
1236
1290
|
}, {
|
|
1237
1291
|
name: "ntnyq/test/base",
|
|
1238
|
-
files,
|
|
1292
|
+
files: baseOptions.files ?? files,
|
|
1239
1293
|
rules: {
|
|
1240
1294
|
"max-lines-per-function": "off",
|
|
1241
1295
|
"no-unused-expressions": "off",
|
|
1242
1296
|
"no-only-tests/no-only-tests": "error",
|
|
1243
|
-
...
|
|
1297
|
+
...baseOptions.overrides
|
|
1244
1298
|
}
|
|
1245
|
-
}
|
|
1299
|
+
});
|
|
1246
1300
|
if (enableVitest) configs.push({
|
|
1247
1301
|
name: "ntnyq/test/vitest",
|
|
1248
|
-
files,
|
|
1302
|
+
files: vitestOptions.files ?? files,
|
|
1249
1303
|
plugins: { vitest: pluginVitest },
|
|
1250
1304
|
settings: {},
|
|
1251
1305
|
rules: {
|
|
@@ -1256,7 +1310,7 @@ const configTest = (options = {}) => {
|
|
|
1256
1310
|
"expectTypeOf",
|
|
1257
1311
|
"assertType"
|
|
1258
1312
|
] }],
|
|
1259
|
-
...
|
|
1313
|
+
...vitestOptions.overrides
|
|
1260
1314
|
}
|
|
1261
1315
|
});
|
|
1262
1316
|
return configs;
|
|
@@ -1336,7 +1390,7 @@ const configAntfu = (options = {}) => [{
|
|
|
1336
1390
|
const configAstro = async (options = {}) => {
|
|
1337
1391
|
await ensurePackages(["astro-eslint-parser", "eslint-plugin-astro"]);
|
|
1338
1392
|
const [parserAstro, pluginAstro] = await Promise.all([interopDefault(import("astro-eslint-parser")), interopDefault(import("eslint-plugin-astro"))]);
|
|
1339
|
-
const { files = [GLOB_ASTRO], extraFileExtensions = [] } = options;
|
|
1393
|
+
const { files = [GLOB_ASTRO], ecmaVersion = "latest", extraFileExtensions = [], typescript = false } = options;
|
|
1340
1394
|
return [{
|
|
1341
1395
|
name: "ntnyq/astro",
|
|
1342
1396
|
files,
|
|
@@ -1347,8 +1401,9 @@ const configAstro = async (options = {}) => {
|
|
|
1347
1401
|
sourceType: "module",
|
|
1348
1402
|
globals: { ...pluginAstro.environments.astro.globals },
|
|
1349
1403
|
parserOptions: {
|
|
1404
|
+
ecmaVersion,
|
|
1350
1405
|
extraFileExtensions,
|
|
1351
|
-
parser: parserTypeScript
|
|
1406
|
+
...typescript ? { parser: parserTypeScript } : {}
|
|
1352
1407
|
}
|
|
1353
1408
|
},
|
|
1354
1409
|
rules: {
|
|
@@ -1359,7 +1414,6 @@ const configAstro = async (options = {}) => {
|
|
|
1359
1414
|
"astro/no-deprecated-astro-resolve": "error",
|
|
1360
1415
|
"astro/no-deprecated-getentrybyslug": "error",
|
|
1361
1416
|
"astro/no-unused-define-vars-in-style": "error",
|
|
1362
|
-
"astro/valid-compile": "error",
|
|
1363
1417
|
...options.overrides
|
|
1364
1418
|
}
|
|
1365
1419
|
}];
|
|
@@ -1410,9 +1464,7 @@ const configJsdoc = (options = {}) => {
|
|
|
1410
1464
|
"jsdoc/require-next-description": "warn",
|
|
1411
1465
|
"jsdoc/require-next-type": "warn",
|
|
1412
1466
|
"jsdoc/require-throws-description": "warn",
|
|
1413
|
-
"jsdoc/require-throws-type": "warn",
|
|
1414
1467
|
"jsdoc/require-yields-description": "warn",
|
|
1415
|
-
"jsdoc/require-yields-type": "warn",
|
|
1416
1468
|
"jsdoc/ts-method-signature-style": "warn",
|
|
1417
1469
|
"jsdoc/ts-no-empty-object-type": "warn",
|
|
1418
1470
|
"jsdoc/ts-no-unnecessary-template-expression": "warn",
|
|
@@ -1435,6 +1487,7 @@ const configJsdoc = (options = {}) => {
|
|
|
1435
1487
|
"internal"
|
|
1436
1488
|
] }],
|
|
1437
1489
|
"jsdoc/check-types": "error",
|
|
1490
|
+
"jsdoc/escape-inline-tags": "error",
|
|
1438
1491
|
/**
|
|
1439
1492
|
* @pg Fixable rules
|
|
1440
1493
|
*/
|
|
@@ -1469,12 +1522,12 @@ const configJsdoc = (options = {}) => {
|
|
|
1469
1522
|
stringQuotes: "single",
|
|
1470
1523
|
typeBracketSpacing: SPECIAL_CHAR.emptyString,
|
|
1471
1524
|
unionSpacing: SPECIAL_CHAR.singleSpace
|
|
1472
|
-
}]
|
|
1473
|
-
|
|
1474
|
-
|
|
1525
|
+
}],
|
|
1526
|
+
...options.overrides
|
|
1527
|
+
}
|
|
1475
1528
|
},
|
|
1476
1529
|
{
|
|
1477
|
-
name: "ntnyq/jsdoc/
|
|
1530
|
+
name: "ntnyq/jsdoc/javascript",
|
|
1478
1531
|
files: [GLOB_JS, GLOB_JSX],
|
|
1479
1532
|
rules: {
|
|
1480
1533
|
"jsdoc/no-types": "off",
|
|
@@ -1482,17 +1535,21 @@ const configJsdoc = (options = {}) => {
|
|
|
1482
1535
|
"jsdoc/require-param-type": "error",
|
|
1483
1536
|
"jsdoc/require-property-type": "error",
|
|
1484
1537
|
"jsdoc/require-returns-type": "error",
|
|
1538
|
+
"jsdoc/require-throws-type": "error",
|
|
1539
|
+
"jsdoc/require-yields-type": "error",
|
|
1485
1540
|
...options.overrides
|
|
1486
1541
|
}
|
|
1487
1542
|
},
|
|
1488
1543
|
{
|
|
1489
|
-
name: "ntnyq/jsdoc/
|
|
1544
|
+
name: "ntnyq/jsdoc/typescript",
|
|
1490
1545
|
files: [GLOB_TS, GLOB_TSX],
|
|
1491
1546
|
rules: {
|
|
1492
1547
|
"jsdoc/no-undefined-types": "off",
|
|
1493
1548
|
"jsdoc/require-param-type": "off",
|
|
1494
1549
|
"jsdoc/require-property-type": "off",
|
|
1495
1550
|
"jsdoc/require-returns-type": "off",
|
|
1551
|
+
"jsdoc/require-throws-type": "off",
|
|
1552
|
+
"jsdoc/require-yields-type": "off",
|
|
1496
1553
|
"jsdoc/no-types": "error",
|
|
1497
1554
|
...options.overrides
|
|
1498
1555
|
}
|
|
@@ -1529,6 +1586,7 @@ const configJsonc = (options = {}) => {
|
|
|
1529
1586
|
plugins: { jsonc: pluginJsonc },
|
|
1530
1587
|
languageOptions: { parser: parserJsonc },
|
|
1531
1588
|
rules: {
|
|
1589
|
+
"no-irregular-whitespace": "off",
|
|
1532
1590
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
1533
1591
|
"jsonc/comma-dangle": ["error", "never"],
|
|
1534
1592
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -1545,6 +1603,7 @@ const configJsonc = (options = {}) => {
|
|
|
1545
1603
|
"jsonc/no-floating-decimal": "error",
|
|
1546
1604
|
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
1547
1605
|
"jsonc/no-infinity": "error",
|
|
1606
|
+
"jsonc/no-irregular-whitespace": "error",
|
|
1548
1607
|
"jsonc/no-multi-str": "error",
|
|
1549
1608
|
"jsonc/no-nan": "error",
|
|
1550
1609
|
"jsonc/no-number-props": "error",
|
|
@@ -1607,7 +1666,13 @@ const configNtnyq = (options = {}) => [{
|
|
|
1607
1666
|
plugins: { ntnyq: pluginNtnyq },
|
|
1608
1667
|
rules: {
|
|
1609
1668
|
"ntnyq/no-duplicate-exports": "error",
|
|
1669
|
+
"ntnyq/no-explicit-void-return-type": "error",
|
|
1610
1670
|
"ntnyq/prefer-newline-after-file-header": "error",
|
|
1671
|
+
"ntnyq/prefer-object-method-syntax": ["error", {
|
|
1672
|
+
allowArrowFunctions: "singleLineOnly",
|
|
1673
|
+
avoidQuotes: true,
|
|
1674
|
+
fix: true
|
|
1675
|
+
}],
|
|
1611
1676
|
...options.overrides
|
|
1612
1677
|
}
|
|
1613
1678
|
}];
|
|
@@ -1621,7 +1686,7 @@ const configNtnyq = (options = {}) => [{
|
|
|
1621
1686
|
* @returns ESLint configs
|
|
1622
1687
|
*/
|
|
1623
1688
|
const configOxfmt = (options = {}) => {
|
|
1624
|
-
const { files:
|
|
1689
|
+
const { files: nativeFiles = [
|
|
1625
1690
|
GLOB_SRC,
|
|
1626
1691
|
GLOB_VUE,
|
|
1627
1692
|
GLOB_JSON,
|
|
@@ -1630,10 +1695,10 @@ const configOxfmt = (options = {}) => {
|
|
|
1630
1695
|
GLOB_YAML,
|
|
1631
1696
|
GLOB_TOML,
|
|
1632
1697
|
GLOB_MARKDOWN
|
|
1633
|
-
], ignores: ignoresWithoutParser = [], filesExtensions:
|
|
1698
|
+
], ignores: ignoresWithoutParser = [], filesExtensions: plainParserFiles = [GLOB_STYLE, GLOB_HTML] } = options;
|
|
1634
1699
|
return [{
|
|
1635
|
-
name: "ntnyq/oxfmt/
|
|
1636
|
-
files:
|
|
1700
|
+
name: "ntnyq/oxfmt/native-files",
|
|
1701
|
+
files: nativeFiles,
|
|
1637
1702
|
ignores: ignoresWithoutParser,
|
|
1638
1703
|
plugins: { oxfmt: pluginOxfmt },
|
|
1639
1704
|
rules: {
|
|
@@ -1641,9 +1706,9 @@ const configOxfmt = (options = {}) => {
|
|
|
1641
1706
|
...options.overrides
|
|
1642
1707
|
}
|
|
1643
1708
|
}, {
|
|
1644
|
-
name: "ntnyq/oxfmt/
|
|
1645
|
-
files:
|
|
1646
|
-
ignores:
|
|
1709
|
+
name: "ntnyq/oxfmt/plain-parser-files",
|
|
1710
|
+
files: plainParserFiles,
|
|
1711
|
+
ignores: [...nativeFiles.flat(), ...ignoresWithoutParser],
|
|
1647
1712
|
plugins: { oxfmt: pluginOxfmt },
|
|
1648
1713
|
languageOptions: { parser: parserPlain },
|
|
1649
1714
|
rules: {
|
|
@@ -1765,7 +1830,7 @@ const configRegexp = (options = {}) => {
|
|
|
1765
1830
|
const configSvelte = async (options = {}) => {
|
|
1766
1831
|
await ensurePackages(["svelte-eslint-parser", "eslint-plugin-svelte"]);
|
|
1767
1832
|
const [parserSvelte, pluginSvelte] = await Promise.all([interopDefault(import("svelte-eslint-parser")), interopDefault(import("eslint-plugin-svelte"))]);
|
|
1768
|
-
const { files = [GLOB_SVELTE], extraFileExtensions = [] } = options;
|
|
1833
|
+
const { files = [GLOB_SVELTE], ecmaVersion = "latest", extraFileExtensions = [], typescript = false } = options;
|
|
1769
1834
|
return [{
|
|
1770
1835
|
name: "ntnyq/svelte",
|
|
1771
1836
|
files,
|
|
@@ -1775,8 +1840,9 @@ const configSvelte = async (options = {}) => {
|
|
|
1775
1840
|
parser: parserSvelte,
|
|
1776
1841
|
sourceType: "module",
|
|
1777
1842
|
parserOptions: {
|
|
1843
|
+
ecmaVersion,
|
|
1778
1844
|
extraFileExtensions,
|
|
1779
|
-
parser: parserTypeScript
|
|
1845
|
+
...typescript ? { parser: parserTypeScript } : {}
|
|
1780
1846
|
}
|
|
1781
1847
|
},
|
|
1782
1848
|
rules: {
|
|
@@ -2002,62 +2068,113 @@ const configUnicorn = (options = {}) => {
|
|
|
2002
2068
|
name: "ntnyq/unicorn",
|
|
2003
2069
|
plugins: { unicorn: pluginUnicorn },
|
|
2004
2070
|
rules: {
|
|
2071
|
+
/**
|
|
2072
|
+
* @pg Compatibility
|
|
2073
|
+
*/
|
|
2005
2074
|
"unicorn/explicit-length-check": "off",
|
|
2006
2075
|
/**
|
|
2076
|
+
* Conditional mutations
|
|
2077
|
+
*/
|
|
2078
|
+
"unicorn/no-immediate-mutation": "off",
|
|
2079
|
+
/**
|
|
2007
2080
|
* @see https://caniuse.com/?search=globalThis
|
|
2008
2081
|
*/
|
|
2009
2082
|
"unicorn/prefer-global-this": "off",
|
|
2010
2083
|
"unicorn/prefer-top-level-await": "off",
|
|
2084
|
+
/**
|
|
2085
|
+
* @pg Assertion
|
|
2086
|
+
*/
|
|
2011
2087
|
"unicorn/consistent-assert": "error",
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2088
|
+
/**
|
|
2089
|
+
* @pg Built-in
|
|
2090
|
+
*/
|
|
2015
2091
|
"unicorn/new-for-builtins": "error",
|
|
2016
|
-
"unicorn/no-accessor-recursion": "error",
|
|
2017
2092
|
"unicorn/no-console-spaces": "error",
|
|
2018
|
-
"unicorn/no-for-loop": "error",
|
|
2019
|
-
"unicorn/no-hex-escape": "error",
|
|
2020
|
-
"unicorn/no-immediate-mutation": "error",
|
|
2021
2093
|
"unicorn/no-instanceof-builtins": "error",
|
|
2022
|
-
"unicorn/no-lonely-if": "error",
|
|
2023
2094
|
"unicorn/no-new-buffer": "error",
|
|
2024
|
-
"unicorn/no-static-only-class": "error",
|
|
2025
2095
|
"unicorn/no-typeof-undefined": "error",
|
|
2026
|
-
"unicorn/no-unnecessary-
|
|
2027
|
-
"unicorn/no-
|
|
2028
|
-
"unicorn/no-
|
|
2096
|
+
"unicorn/no-unnecessary-global-this": "error",
|
|
2097
|
+
"unicorn/no-unused-builtin-method-return": "error",
|
|
2098
|
+
"unicorn/no-using-resource-escape": "error",
|
|
2099
|
+
/**
|
|
2100
|
+
* @pg Class
|
|
2101
|
+
*/
|
|
2102
|
+
"unicorn/no-accessor-recursion": "error",
|
|
2103
|
+
"unicorn/no-static-only-class": "error",
|
|
2104
|
+
"unicorn/no-this-outside-of-class": "error",
|
|
2105
|
+
"unicorn/no-useless-override": "error",
|
|
2029
2106
|
"unicorn/prefer-class-fields": "error",
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
"unicorn/
|
|
2034
|
-
"unicorn/
|
|
2035
|
-
"unicorn/
|
|
2036
|
-
"unicorn/
|
|
2037
|
-
"unicorn/
|
|
2038
|
-
"unicorn/
|
|
2039
|
-
"unicorn/
|
|
2040
|
-
"unicorn/
|
|
2041
|
-
"unicorn/
|
|
2042
|
-
"unicorn/
|
|
2107
|
+
/**
|
|
2108
|
+
* @pg Control Flow
|
|
2109
|
+
*/
|
|
2110
|
+
"unicorn/no-accidental-bitwise-operator": "error",
|
|
2111
|
+
"unicorn/no-chained-comparison": "error",
|
|
2112
|
+
"unicorn/no-constant-zero-expression": "error",
|
|
2113
|
+
"unicorn/no-double-comparison": "error",
|
|
2114
|
+
"unicorn/no-duplicate-logical-operands": "error",
|
|
2115
|
+
"unicorn/no-for-loop": "error",
|
|
2116
|
+
"unicorn/no-lonely-if": "error",
|
|
2117
|
+
"unicorn/no-unnecessary-boolean-comparison": "error",
|
|
2118
|
+
"unicorn/no-unnecessary-nested-ternary": "error",
|
|
2119
|
+
"unicorn/no-useless-boolean-cast": "error",
|
|
2120
|
+
"unicorn/no-useless-coercion": "error",
|
|
2121
|
+
"unicorn/no-useless-collection-argument": "error",
|
|
2122
|
+
"unicorn/no-useless-continue": "error",
|
|
2123
|
+
"unicorn/no-useless-else": "error",
|
|
2124
|
+
"unicorn/prefer-block-statement-over-iife": "error",
|
|
2125
|
+
"unicorn/prefer-combined-guards": "error",
|
|
2043
2126
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
2044
2127
|
"unicorn/switch-case-break-position": "error",
|
|
2045
2128
|
/**
|
|
2046
2129
|
* @pg Error
|
|
2047
2130
|
*/
|
|
2048
2131
|
"unicorn/catch-error-name": ["error", {
|
|
2049
|
-
name: "
|
|
2132
|
+
name: "error",
|
|
2050
2133
|
ignore: ["^_."]
|
|
2051
2134
|
}],
|
|
2052
2135
|
"unicorn/custom-error-definition": "error",
|
|
2136
|
+
"unicorn/error-message": "error",
|
|
2053
2137
|
"unicorn/no-useless-error-capture-stack-trace": "error",
|
|
2138
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
2054
2139
|
"unicorn/prefer-type-error": "error",
|
|
2055
2140
|
"unicorn/throw-new-error": "error",
|
|
2056
2141
|
/**
|
|
2142
|
+
* @pg Promise
|
|
2143
|
+
*/
|
|
2144
|
+
"unicorn/no-async-promise-finally": "error",
|
|
2145
|
+
"unicorn/no-multiple-promise-resolver-calls": "error",
|
|
2146
|
+
"unicorn/no-unnecessary-await": "error",
|
|
2147
|
+
"unicorn/no-unsafe-promise-all-settled-values": "error",
|
|
2148
|
+
"unicorn/prefer-then-catch": "error",
|
|
2149
|
+
/**
|
|
2150
|
+
* @pg Function
|
|
2151
|
+
*/
|
|
2152
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
2153
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
2154
|
+
/**
|
|
2155
|
+
* @pg Web APIs
|
|
2156
|
+
*/
|
|
2157
|
+
"unicorn/no-blob-to-file": "error",
|
|
2158
|
+
"unicorn/no-canvas-to-image": "error",
|
|
2159
|
+
"unicorn/no-transition-all": "error",
|
|
2160
|
+
"unicorn/no-unnecessary-fetch-options": "error",
|
|
2161
|
+
"unicorn/prefer-abort-signal-any": "error",
|
|
2162
|
+
"unicorn/prefer-abort-signal-timeout": "error",
|
|
2163
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
2164
|
+
"unicorn/prefer-observer-apis": "error",
|
|
2165
|
+
"unicorn/prefer-response-static-json": "error",
|
|
2166
|
+
"unicorn/prefer-url-search-parameters": "error",
|
|
2167
|
+
/**
|
|
2057
2168
|
* @pg Number
|
|
2058
2169
|
*/
|
|
2059
2170
|
"unicorn/no-zero-fractions": "error",
|
|
2060
2171
|
"unicorn/number-literal-case": ["error", { hexadecimalValue: "lowercase" }],
|
|
2172
|
+
"unicorn/prefer-math-abs": "error",
|
|
2173
|
+
"unicorn/prefer-math-min-max": "error",
|
|
2174
|
+
"unicorn/prefer-math-trunc": "error",
|
|
2175
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
2176
|
+
"unicorn/prefer-negative-index": "error",
|
|
2177
|
+
"unicorn/prefer-number-coercion": "error",
|
|
2061
2178
|
"unicorn/prefer-number-properties": "error",
|
|
2062
2179
|
/**
|
|
2063
2180
|
* @pg BigInt
|
|
@@ -2066,36 +2183,44 @@ const configUnicorn = (options = {}) => {
|
|
|
2066
2183
|
/**
|
|
2067
2184
|
* @pg RegExp
|
|
2068
2185
|
*/
|
|
2069
|
-
/**
|
|
2070
|
-
* Prefer `eslint-plugin-regexp` instead
|
|
2071
|
-
*/
|
|
2072
|
-
"unicorn/better-regex": "off",
|
|
2073
2186
|
"unicorn/prefer-regexp-test": "error",
|
|
2074
2187
|
/**
|
|
2075
2188
|
* @pg Date
|
|
2076
2189
|
*/
|
|
2077
2190
|
"unicorn/consistent-date-clone": "error",
|
|
2078
2191
|
"unicorn/prefer-date-now": "error",
|
|
2192
|
+
"unicorn/prefer-temporal-conversion": "error",
|
|
2079
2193
|
/**
|
|
2080
2194
|
* @pg String
|
|
2081
2195
|
*/
|
|
2082
2196
|
"unicorn/consistent-template-literal-escape": "error",
|
|
2197
|
+
"unicorn/escape-case": "error",
|
|
2198
|
+
"unicorn/no-unnecessary-string-trim": "error",
|
|
2199
|
+
"unicorn/no-unsafe-string-replacement": "error",
|
|
2083
2200
|
"unicorn/prefer-code-point": "error",
|
|
2201
|
+
"unicorn/prefer-string-pad-start-end": "error",
|
|
2202
|
+
"unicorn/prefer-string-repeat": "error",
|
|
2084
2203
|
"unicorn/prefer-string-slice": "error",
|
|
2085
2204
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2086
2205
|
"unicorn/prefer-string-trim-start-end": "error",
|
|
2206
|
+
"unicorn/prefer-unicode-code-point-escapes": "error",
|
|
2087
2207
|
/**
|
|
2088
2208
|
* @pg DOM
|
|
2089
2209
|
*/
|
|
2210
|
+
"unicorn/better-dom-traversing": "error",
|
|
2211
|
+
"unicorn/dom-node-dataset": "error",
|
|
2212
|
+
"unicorn/no-incorrect-query-selector": "error",
|
|
2213
|
+
"unicorn/no-invalid-file-input-accept": "error",
|
|
2090
2214
|
"unicorn/no-invalid-remove-event-listener": "error",
|
|
2215
|
+
"unicorn/no-late-current-target-access": "error",
|
|
2091
2216
|
"unicorn/prefer-add-event-listener": "error",
|
|
2092
2217
|
"unicorn/prefer-classlist-toggle": "error",
|
|
2093
2218
|
"unicorn/prefer-dom-node-append": "error",
|
|
2094
|
-
"unicorn/prefer-dom-node-dataset": "error",
|
|
2095
2219
|
"unicorn/prefer-dom-node-remove": "error",
|
|
2096
2220
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
2097
2221
|
"unicorn/prefer-modern-dom-apis": "error",
|
|
2098
2222
|
"unicorn/prefer-query-selector": "error",
|
|
2223
|
+
"unicorn/prefer-toggle-attribute": "error",
|
|
2099
2224
|
/**
|
|
2100
2225
|
* @pg Array
|
|
2101
2226
|
*/
|
|
@@ -2107,27 +2232,66 @@ const configUnicorn = (options = {}) => {
|
|
|
2107
2232
|
*/
|
|
2108
2233
|
"unicorn/no-array-reverse": "off",
|
|
2109
2234
|
"unicorn/no-array-sort": "off",
|
|
2235
|
+
"unicorn/no-array-fill-with-reference-type": "error",
|
|
2236
|
+
"unicorn/no-array-from-fill": "error",
|
|
2110
2237
|
"unicorn/no-array-method-this-argument": "error",
|
|
2238
|
+
"unicorn/no-boolean-sort-comparator": "error",
|
|
2239
|
+
"unicorn/no-confusing-array-splice": "error",
|
|
2240
|
+
"unicorn/no-confusing-array-with": "error",
|
|
2241
|
+
"unicorn/no-duplicate-loops": "error",
|
|
2111
2242
|
"unicorn/no-new-array": "error",
|
|
2112
2243
|
"unicorn/no-unnecessary-array-flat-depth": "error",
|
|
2113
2244
|
"unicorn/no-unnecessary-array-splice-count": "error",
|
|
2114
2245
|
"unicorn/no-unnecessary-slice-end": "error",
|
|
2115
2246
|
"unicorn/prefer-array-find": "error",
|
|
2116
2247
|
"unicorn/prefer-array-flat-map": "error",
|
|
2248
|
+
"unicorn/prefer-array-from-range": "error",
|
|
2117
2249
|
"unicorn/prefer-array-index-of": "error",
|
|
2118
2250
|
"unicorn/prefer-array-some": "error",
|
|
2251
|
+
"unicorn/prefer-includes": "error",
|
|
2252
|
+
"unicorn/prefer-includes-over-repeated-comparisons": "error",
|
|
2253
|
+
"unicorn/prefer-single-array-predicate": "error",
|
|
2119
2254
|
"unicorn/prefer-single-call": "error",
|
|
2120
2255
|
"unicorn/require-array-join-separator": "error",
|
|
2121
2256
|
/**
|
|
2257
|
+
* @pg Iterator
|
|
2258
|
+
*/
|
|
2259
|
+
"unicorn/no-async-iterator-callback": "error",
|
|
2260
|
+
"unicorn/no-unused-iterator-helper": "error",
|
|
2261
|
+
"unicorn/no-useless-iterator-to-array": "error",
|
|
2262
|
+
/**
|
|
2122
2263
|
* @pg Set
|
|
2123
2264
|
*/
|
|
2265
|
+
"unicorn/no-duplicate-set-values": "error",
|
|
2266
|
+
"unicorn/no-useless-set-construction": "error",
|
|
2124
2267
|
"unicorn/prefer-set-has": "error",
|
|
2125
2268
|
"unicorn/prefer-set-size": "error",
|
|
2126
2269
|
/**
|
|
2270
|
+
* @pg Map
|
|
2271
|
+
*/
|
|
2272
|
+
"unicorn/prefer-has-check": "error",
|
|
2273
|
+
/**
|
|
2274
|
+
* @pg Object
|
|
2275
|
+
*/
|
|
2276
|
+
"unicorn/consistent-conditional-object-spread": ["error", "ternary"],
|
|
2277
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
2278
|
+
"unicorn/no-unsafe-property-key": "error",
|
|
2279
|
+
"unicorn/prefer-object-from-entries": "error",
|
|
2280
|
+
"unicorn/prefer-single-object-destructuring": "error",
|
|
2281
|
+
/**
|
|
2282
|
+
* @pg Data
|
|
2283
|
+
*/
|
|
2284
|
+
"unicorn/consistent-json-file-read": "error",
|
|
2285
|
+
"unicorn/prefer-structured-clone": "error",
|
|
2286
|
+
/**
|
|
2127
2287
|
* @pg Module
|
|
2128
2288
|
*/
|
|
2129
|
-
"unicorn/
|
|
2289
|
+
"unicorn/no-exports-in-scripts": "error",
|
|
2290
|
+
"unicorn/no-useless-re-export": "error",
|
|
2291
|
+
"unicorn/prefer-import-meta-properties": "error",
|
|
2292
|
+
"unicorn/prefer-node-protocol": "error",
|
|
2130
2293
|
"unicorn/require-module-attributes": "error",
|
|
2294
|
+
"unicorn/require-module-specifiers": "error",
|
|
2131
2295
|
...options.overrides
|
|
2132
2296
|
}
|
|
2133
2297
|
}];
|
|
@@ -2183,7 +2347,7 @@ const configMarkdown = (options = {}) => {
|
|
|
2183
2347
|
languageOptions: { parser: parserPlain }
|
|
2184
2348
|
},
|
|
2185
2349
|
{
|
|
2186
|
-
name: "ntnyq/markdown/
|
|
2350
|
+
name: "ntnyq/markdown/code-blocks",
|
|
2187
2351
|
files: [...files, ...extraFileExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*${ext}`)],
|
|
2188
2352
|
languageOptions: { parserOptions: {
|
|
2189
2353
|
project: false,
|
|
@@ -2340,6 +2504,10 @@ const PERFECTIONIST = Object.freeze({
|
|
|
2340
2504
|
],
|
|
2341
2505
|
sortExportAttributesGroups: ["unknown"],
|
|
2342
2506
|
sortExportsGroups: [
|
|
2507
|
+
"wildcard-export",
|
|
2508
|
+
"named-export",
|
|
2509
|
+
"singleline-export",
|
|
2510
|
+
"multiline-export",
|
|
2343
2511
|
"value-export",
|
|
2344
2512
|
"type-export",
|
|
2345
2513
|
"unknown"
|
|
@@ -2421,83 +2589,85 @@ const PERFECTIONIST = Object.freeze({
|
|
|
2421
2589
|
* @returns ESLint configs
|
|
2422
2590
|
*/
|
|
2423
2591
|
const configSpecials = (options = {}) => {
|
|
2424
|
-
const { shadcnVue: enableShadcnVue = hasShadcnVue() } = options;
|
|
2425
|
-
const
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
},
|
|
2435
|
-
{
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
},
|
|
2444
|
-
{
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2592
|
+
const { additionalConfigs, bin: enableBin = true, cli: enableCli = true, configFiles: enableConfigFiles = true, scripts: enableScripts = true, shadcnVue: enableShadcnVue = hasShadcnVue(), userScripts: enableUserScripts = true } = options;
|
|
2593
|
+
const binOptions = resolveSubOptions(options, "bin");
|
|
2594
|
+
const cliOptions = resolveSubOptions(options, "cli");
|
|
2595
|
+
const configFilesOptions = resolveSubOptions(options, "configFiles");
|
|
2596
|
+
const scriptsOptions = resolveSubOptions(options, "scripts");
|
|
2597
|
+
const shadcnVueOptions = resolveSubOptions(options, "shadcnVue");
|
|
2598
|
+
const userScriptsOptions = resolveSubOptions(options, "userScripts");
|
|
2599
|
+
const configs = [];
|
|
2600
|
+
if (enableScripts) configs.push({
|
|
2601
|
+
name: "ntnyq/specials/scripts",
|
|
2602
|
+
files: scriptsOptions.files ?? [`**/scripts/${GLOB_SRC}`],
|
|
2603
|
+
rules: {
|
|
2604
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2605
|
+
"no-console": "off",
|
|
2606
|
+
...scriptsOptions.overrides
|
|
2607
|
+
}
|
|
2608
|
+
});
|
|
2609
|
+
if (enableCli) configs.push({
|
|
2610
|
+
name: "ntnyq/specials/cli",
|
|
2611
|
+
files: cliOptions.files ?? [`**/cli/${GLOB_SRC}`, `**/cli.?([cm])[jt]s?(x)`],
|
|
2612
|
+
rules: {
|
|
2613
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2614
|
+
"no-console": "off",
|
|
2615
|
+
...cliOptions.overrides
|
|
2616
|
+
}
|
|
2617
|
+
});
|
|
2618
|
+
if (enableBin) configs.push({
|
|
2619
|
+
name: "ntnyq/specials/bin",
|
|
2620
|
+
files: binOptions.files ?? [`**/bin/${GLOB_SRC}`, `**/bin.?([cm])[jt]s?(x)`],
|
|
2621
|
+
rules: {
|
|
2622
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2623
|
+
"antfu/no-import-dist": "off",
|
|
2624
|
+
"no-console": "off",
|
|
2625
|
+
...binOptions.overrides
|
|
2626
|
+
}
|
|
2627
|
+
});
|
|
2628
|
+
if (enableUserScripts) configs.push({
|
|
2629
|
+
name: "ntnyq/specials/userscript",
|
|
2630
|
+
files: userScriptsOptions.files ?? [`**/*.user.?([cm])[jt]s?(x)`],
|
|
2631
|
+
languageOptions: { globals: { ...globals.greasemonkey } },
|
|
2632
|
+
rules: {
|
|
2633
|
+
camelcase: ["error", { allow: ["^GM_.+"] }],
|
|
2634
|
+
...userScriptsOptions.overrides
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2637
|
+
if (enableConfigFiles) configs.push({
|
|
2638
|
+
name: "ntnyq/specials/config-file",
|
|
2639
|
+
files: configFilesOptions.files ?? [`**/*.config*.?([cm])[jt]s?(x)`],
|
|
2640
|
+
plugins: {
|
|
2641
|
+
"import-x": pluginImportX,
|
|
2642
|
+
perfectionist: pluginPerfectionist
|
|
2462
2643
|
},
|
|
2463
|
-
{
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
"import-x/no-default-export": "off",
|
|
2474
|
-
"no-console": "off",
|
|
2475
|
-
"perfectionist/sort-objects": ["error", {
|
|
2476
|
-
...PERFECTIONIST.partialRuleOptions,
|
|
2477
|
-
groups: PERFECTIONIST.sortObjectsGroups
|
|
2478
|
-
}],
|
|
2479
|
-
...options.overridesConfigFileRules
|
|
2480
|
-
}
|
|
2644
|
+
settings: { perfectionist: PERFECTIONIST.pluginSettings },
|
|
2645
|
+
rules: {
|
|
2646
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2647
|
+
"import-x/no-default-export": "off",
|
|
2648
|
+
"no-console": "off",
|
|
2649
|
+
"perfectionist/sort-objects": ["error", {
|
|
2650
|
+
...PERFECTIONIST.partialRuleOptions,
|
|
2651
|
+
groups: PERFECTIONIST.sortObjectsGroups
|
|
2652
|
+
}],
|
|
2653
|
+
...configFilesOptions.overrides
|
|
2481
2654
|
}
|
|
2482
|
-
|
|
2483
|
-
if (enableShadcnVue) {
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
if (options.specialCaseConfigs) configs.push(...options.specialCaseConfigs);
|
|
2655
|
+
});
|
|
2656
|
+
if (enableShadcnVue) configs.push({
|
|
2657
|
+
name: "ntnyq/specials/shadcn-vue",
|
|
2658
|
+
files: shadcnVueOptions.files ?? ["**/components/ui/**/*.ts", "**/components/ui/**/*.vue"],
|
|
2659
|
+
rules: {
|
|
2660
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
2661
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
2662
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
2663
|
+
"vue/define-emits-declaration": "off",
|
|
2664
|
+
"vue/html-button-has-type": "off",
|
|
2665
|
+
"vue/no-duplicate-attr-inheritance": "off",
|
|
2666
|
+
"vue/prefer-use-template-ref": "off",
|
|
2667
|
+
...shadcnVueOptions.overrides
|
|
2668
|
+
}
|
|
2669
|
+
});
|
|
2670
|
+
if (additionalConfigs) configs.push(...additionalConfigs);
|
|
2501
2671
|
return configs;
|
|
2502
2672
|
};
|
|
2503
2673
|
//#endregion
|
|
@@ -2511,9 +2681,11 @@ const configSpecials = (options = {}) => {
|
|
|
2511
2681
|
* @returns ESLint configs
|
|
2512
2682
|
*/
|
|
2513
2683
|
const configGitIgnore = (options = {}) => {
|
|
2514
|
-
options.strict ??= false;
|
|
2515
2684
|
return [{
|
|
2516
|
-
...createGitIgnoreConfig(
|
|
2685
|
+
...createGitIgnoreConfig({
|
|
2686
|
+
...options,
|
|
2687
|
+
strict: options.strict ?? false
|
|
2688
|
+
}),
|
|
2517
2689
|
name: "ntnyq/gitignore"
|
|
2518
2690
|
}];
|
|
2519
2691
|
};
|
|
@@ -2547,9 +2719,9 @@ const configJavaScript = (options = {}) => {
|
|
|
2547
2719
|
const { ecmaVersion = "latest" } = options;
|
|
2548
2720
|
return [{
|
|
2549
2721
|
...jsConfig.configs.recommended,
|
|
2550
|
-
name: "ntnyq/
|
|
2722
|
+
name: "ntnyq/javascript/recommended"
|
|
2551
2723
|
}, {
|
|
2552
|
-
name: "ntnyq/
|
|
2724
|
+
name: "ntnyq/javascript/core",
|
|
2553
2725
|
languageOptions: {
|
|
2554
2726
|
ecmaVersion,
|
|
2555
2727
|
sourceType: "module",
|
|
@@ -2805,7 +2977,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2805
2977
|
...parserOptions
|
|
2806
2978
|
};
|
|
2807
2979
|
return {
|
|
2808
|
-
name: `ntnyq/
|
|
2980
|
+
name: `ntnyq/typescript/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
2809
2981
|
files,
|
|
2810
2982
|
ignores: [...ignores],
|
|
2811
2983
|
languageOptions: {
|
|
@@ -2816,7 +2988,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2816
2988
|
}
|
|
2817
2989
|
return [
|
|
2818
2990
|
{
|
|
2819
|
-
name: "ntnyq/
|
|
2991
|
+
name: "ntnyq/typescript/setup",
|
|
2820
2992
|
plugins: {
|
|
2821
2993
|
"@typescript-eslint": pluginTypeScript,
|
|
2822
2994
|
antfu: pluginAntfu
|
|
@@ -2824,7 +2996,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2824
2996
|
},
|
|
2825
2997
|
...enableTypeAwareLint ? [createParserConfig(false, files), createParserConfig(true, filesTypeAware, ignoresTypeAware)] : [createParserConfig(false, files)],
|
|
2826
2998
|
{
|
|
2827
|
-
name: "ntnyq/
|
|
2999
|
+
name: "ntnyq/typescript/rules",
|
|
2828
3000
|
files,
|
|
2829
3001
|
rules: {
|
|
2830
3002
|
...recommendedRules,
|
|
@@ -2899,7 +3071,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2899
3071
|
}
|
|
2900
3072
|
},
|
|
2901
3073
|
...enableTypeAwareLint ? [{
|
|
2902
|
-
name: "ntnyq/
|
|
3074
|
+
name: "ntnyq/typescript/rules/type-aware",
|
|
2903
3075
|
files: [...filesTypeAware],
|
|
2904
3076
|
ignores: [...ignoresTypeAware],
|
|
2905
3077
|
rules: {
|
|
@@ -2908,7 +3080,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2908
3080
|
}
|
|
2909
3081
|
}] : [],
|
|
2910
3082
|
{
|
|
2911
|
-
name: "ntnyq/
|
|
3083
|
+
name: "ntnyq/typescript/types",
|
|
2912
3084
|
files: [...GLOB_TYPES],
|
|
2913
3085
|
rules: {
|
|
2914
3086
|
"@typescript-eslint/no-use-before-define": "off",
|
|
@@ -2983,7 +3155,14 @@ const configGitHubAction = (options = {}) => {
|
|
|
2983
3155
|
* @returns ESLint configs
|
|
2984
3156
|
*/
|
|
2985
3157
|
const configPerfectionist = (options = {}) => {
|
|
2986
|
-
const {
|
|
3158
|
+
const { all: enableAll = false, constants: enableSortConstants = true, enums: enableSortEnums = true, partitionByComment = PERFECTIONIST.partialRuleOptions.partitionByComment, types: enableSortTypes = true } = options;
|
|
3159
|
+
const commonOptions = resolveSubOptions(options, "common");
|
|
3160
|
+
const constantsOptions = resolveSubOptions(options, "constants");
|
|
3161
|
+
const enumsOptions = resolveSubOptions(options, "enums");
|
|
3162
|
+
const typesOptions = resolveSubOptions(options, "types");
|
|
3163
|
+
const filesConstants = constantsOptions.files ?? [`**/constants/${GLOB_SRC}`, `**/constants.?([cm])[jt]s?(x)`];
|
|
3164
|
+
const filesEnums = enumsOptions.files ?? [`**/enums/${GLOB_SRC}`, `**/enums.?([cm])[jt]s?(x)`];
|
|
3165
|
+
const filesTypes = typesOptions.files ?? [...GLOB_TYPES];
|
|
2987
3166
|
const sharedOptionsWithNewlinesBetween = {
|
|
2988
3167
|
newlinesBetween: "ignore",
|
|
2989
3168
|
partitionByComment
|
|
@@ -3077,21 +3256,21 @@ const configPerfectionist = (options = {}) => {
|
|
|
3077
3256
|
settings: { perfectionist: PERFECTIONIST.pluginSettings }
|
|
3078
3257
|
};
|
|
3079
3258
|
const configs = [{
|
|
3080
|
-
name:
|
|
3259
|
+
name: enableAll ? "ntnyq/perfectionist/all" : "ntnyq/perfectionist/common",
|
|
3081
3260
|
...sharedConfig,
|
|
3082
3261
|
rules: {
|
|
3083
3262
|
...commonRules,
|
|
3084
|
-
...
|
|
3263
|
+
...enableAll ? {
|
|
3085
3264
|
...sharedRules,
|
|
3086
3265
|
...sortEnumsRules,
|
|
3087
3266
|
...sortTypesRules,
|
|
3088
3267
|
...sortConstantsRules,
|
|
3089
3268
|
...extraRules
|
|
3090
3269
|
} : {},
|
|
3091
|
-
...
|
|
3270
|
+
...commonOptions.overrides
|
|
3092
3271
|
}
|
|
3093
3272
|
}];
|
|
3094
|
-
if (
|
|
3273
|
+
if (enableAll) return configs;
|
|
3095
3274
|
if (enableSortEnums) configs.push({
|
|
3096
3275
|
name: "ntnyq/perfectionist/enums",
|
|
3097
3276
|
files: filesEnums,
|
|
@@ -3099,7 +3278,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
3099
3278
|
rules: {
|
|
3100
3279
|
...sharedRules,
|
|
3101
3280
|
...sortEnumsRules,
|
|
3102
|
-
...
|
|
3281
|
+
...enumsOptions.overrides
|
|
3103
3282
|
}
|
|
3104
3283
|
});
|
|
3105
3284
|
if (enableSortTypes) configs.push({
|
|
@@ -3109,7 +3288,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
3109
3288
|
rules: {
|
|
3110
3289
|
...sharedRules,
|
|
3111
3290
|
...sortTypesRules,
|
|
3112
|
-
...
|
|
3291
|
+
...typesOptions.overrides
|
|
3113
3292
|
}
|
|
3114
3293
|
});
|
|
3115
3294
|
if (enableSortConstants) configs.push({
|
|
@@ -3119,7 +3298,7 @@ const configPerfectionist = (options = {}) => {
|
|
|
3119
3298
|
rules: {
|
|
3120
3299
|
...sharedRules,
|
|
3121
3300
|
...sortConstantsRules,
|
|
3122
|
-
...
|
|
3301
|
+
...constantsOptions.overrides
|
|
3123
3302
|
}
|
|
3124
3303
|
});
|
|
3125
3304
|
return configs;
|
|
@@ -3141,6 +3320,7 @@ const configUnusedImports = async (options = {}) => {
|
|
|
3141
3320
|
plugins: { "unused-imports": await interopDefault(import("eslint-plugin-unused-imports")) },
|
|
3142
3321
|
rules: {
|
|
3143
3322
|
"@typescript-eslint/no-unused-vars": "off",
|
|
3323
|
+
"no-unused-vars": "off",
|
|
3144
3324
|
"unused-imports/no-unused-imports": "error",
|
|
3145
3325
|
"unused-imports/no-unused-vars": ["error", {
|
|
3146
3326
|
args: "after-used",
|
|
@@ -3184,7 +3364,7 @@ const configESLintComments = (options = {}) => [{
|
|
|
3184
3364
|
* Config factory
|
|
3185
3365
|
*/
|
|
3186
3366
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
3187
|
-
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;
|
|
3367
|
+
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, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false, unusedImports: enableUnusedImports = false } = options;
|
|
3188
3368
|
const configs = [];
|
|
3189
3369
|
const { ecmaVersion = "latest", extraFileExtensions: shareableExtraFileExtensions = [] } = shareable;
|
|
3190
3370
|
const extraFileExtensions = [...shareableExtraFileExtensions];
|
|
@@ -3207,11 +3387,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3207
3387
|
overrides: getOverrides(options, "jsdoc"),
|
|
3208
3388
|
...resolveSubOptions(options, "jsdoc")
|
|
3209
3389
|
}));
|
|
3210
|
-
if (enablePerfectionist) configs.push(configPerfectionist(
|
|
3211
|
-
|
|
3212
|
-
|
|
3390
|
+
if (enablePerfectionist) configs.push(configPerfectionist(resolveSubOptions(options, "perfectionist")));
|
|
3391
|
+
if (enableUnicorn) configs.push(configUnicorn({
|
|
3392
|
+
...resolveSubOptions(options, "unicorn"),
|
|
3393
|
+
overrides: getOverrides(options, "unicorn")
|
|
3213
3394
|
}));
|
|
3214
|
-
if (enableUnicorn) configs.push(configUnicorn({ overrides: getOverrides(options, "unicorn") }));
|
|
3215
3395
|
if (enablePinia) configs.push(configPinia({
|
|
3216
3396
|
...resolveSubOptions(options, "pinia"),
|
|
3217
3397
|
overrides: getOverrides(options, "pinia")
|
|
@@ -3230,8 +3410,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3230
3410
|
if (enableVue) configs.push(configVue({
|
|
3231
3411
|
ecmaVersion,
|
|
3232
3412
|
usingFormatter: !!usingFormatter,
|
|
3233
|
-
...resolveSubOptions(options, "vue"),
|
|
3234
3413
|
typescript: !!enableTypeScript,
|
|
3414
|
+
...resolveSubOptions(options, "vue"),
|
|
3235
3415
|
overrides: getOverrides(options, "vue"),
|
|
3236
3416
|
extraFileExtensions
|
|
3237
3417
|
}));
|
|
@@ -3250,22 +3430,21 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3250
3430
|
overrides: getOverrides(options, "jsonc")
|
|
3251
3431
|
}));
|
|
3252
3432
|
if (enableAstro) configs.push(configAstro({
|
|
3253
|
-
|
|
3433
|
+
ecmaVersion,
|
|
3254
3434
|
typescript: !!enableTypeScript,
|
|
3435
|
+
...resolveSubOptions(options, "astro"),
|
|
3255
3436
|
overrides: getOverrides(options, "astro"),
|
|
3256
3437
|
extraFileExtensions
|
|
3257
3438
|
}));
|
|
3258
3439
|
if (enableSvelte) configs.push(configSvelte({
|
|
3259
|
-
|
|
3440
|
+
ecmaVersion,
|
|
3260
3441
|
typescript: !!enableTypeScript,
|
|
3442
|
+
...resolveSubOptions(options, "svelte"),
|
|
3261
3443
|
overrides: getOverrides(options, "svelte"),
|
|
3262
3444
|
extraFileExtensions
|
|
3263
3445
|
}));
|
|
3264
3446
|
if (enableSort) configs.push(configSort(resolveSubOptions(options, "sort")));
|
|
3265
|
-
if (enableTest) configs.push(configTest(
|
|
3266
|
-
...resolveSubOptions(options, "test"),
|
|
3267
|
-
overrides: getOverrides(options, "test")
|
|
3268
|
-
}));
|
|
3447
|
+
if (enableTest) configs.push(configTest(resolveSubOptions(options, "test")));
|
|
3269
3448
|
if (enableUnoCSS) configs.push(configUnoCSS({ overrides: getOverrides(options, "unocss") }));
|
|
3270
3449
|
if (enableMarkdown) configs.push(configMarkdown({
|
|
3271
3450
|
...resolveSubOptions(options, "markdown"),
|
|
@@ -3303,4 +3482,4 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3303
3482
|
return new FlatConfigComposer(...configs, ...userConfigs, ...formatterConfigs);
|
|
3304
3483
|
}
|
|
3305
3484
|
//#endregion
|
|
3306
|
-
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 };
|
|
3485
|
+
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_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, 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, pluginVuePerfectionist, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|