@ghettoddos/eslint-config 2.0.1 → 3.0.1
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 +26 -12
- package/dist/index.d.ts +2426 -406
- package/dist/index.js +319 -125
- package/dist/lib-CEKTiw7V.js +11176 -0
- package/package.json +76 -43
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
2
6
|
import { isPackageExists } from "local-pkg";
|
|
3
7
|
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
4
8
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
@@ -8,12 +12,29 @@ import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
|
8
12
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
9
13
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
10
14
|
import { fixupPluginRules } from "@eslint/compat";
|
|
11
|
-
import process from "node:process";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
15
|
import globals from "globals";
|
|
14
16
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
15
17
|
import { configs } from "eslint-plugin-regexp";
|
|
16
18
|
|
|
19
|
+
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
20
|
+
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
21
|
+
function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
22
|
+
let directory = path.resolve(toPath(cwd) ?? "");
|
|
23
|
+
const { root } = path.parse(directory);
|
|
24
|
+
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
25
|
+
const isAbsoluteName = path.isAbsolute(name);
|
|
26
|
+
while (directory) {
|
|
27
|
+
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
28
|
+
try {
|
|
29
|
+
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
30
|
+
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
31
|
+
} catch {}
|
|
32
|
+
if (directory === stopAt || directory === root) break;
|
|
33
|
+
directory = path.dirname(directory);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
17
38
|
//#region src/configs/comments.ts
|
|
18
39
|
async function comments() {
|
|
19
40
|
return [{
|
|
@@ -52,6 +73,13 @@ const GLOB_XML = "**/*.xml";
|
|
|
52
73
|
const GLOB_SVG = "**/*.svg";
|
|
53
74
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
54
75
|
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
76
|
+
const GLOB_TESTS = [
|
|
77
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
78
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
79
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
80
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
81
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
82
|
+
];
|
|
55
83
|
const GLOB_ALL_SRC = [
|
|
56
84
|
GLOB_SRC,
|
|
57
85
|
GLOB_STYLE,
|
|
@@ -128,8 +156,13 @@ async function disables() {
|
|
|
128
156
|
|
|
129
157
|
//#endregion
|
|
130
158
|
//#region src/constants.ts
|
|
131
|
-
const ReactPackages = ["react", "nest"];
|
|
132
159
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
160
|
+
const RemixPackages = [
|
|
161
|
+
"@remix-run/node",
|
|
162
|
+
"@remix-run/react",
|
|
163
|
+
"@remix-run/serve",
|
|
164
|
+
"@remix-run/dev"
|
|
165
|
+
];
|
|
133
166
|
const ReactRouterPackages = [
|
|
134
167
|
"@react-router/node",
|
|
135
168
|
"@react-router/react",
|
|
@@ -137,13 +170,20 @@ const ReactRouterPackages = [
|
|
|
137
170
|
"@react-router/dev"
|
|
138
171
|
];
|
|
139
172
|
const NextJsPackages = ["next"];
|
|
173
|
+
const ReactNativePackages = ["react-native", "expo"];
|
|
174
|
+
const ReactPackages = [
|
|
175
|
+
...RemixPackages,
|
|
176
|
+
...ReactRouterPackages,
|
|
177
|
+
...NextJsPackages,
|
|
178
|
+
...ReactNativePackages,
|
|
179
|
+
"react"
|
|
180
|
+
];
|
|
140
181
|
const VuePackages = [
|
|
141
182
|
"vue",
|
|
142
183
|
"nuxt",
|
|
143
184
|
"vitepress",
|
|
144
185
|
"@slidev/cli"
|
|
145
186
|
];
|
|
146
|
-
const ReactNativePackages = ["react-native", "expo"];
|
|
147
187
|
|
|
148
188
|
//#endregion
|
|
149
189
|
//#region src/utils.ts
|
|
@@ -172,8 +212,7 @@ const parserPlain = {
|
|
|
172
212
|
* Combine array and non-array configs into a single array.
|
|
173
213
|
*/
|
|
174
214
|
async function combine(...configs$1) {
|
|
175
|
-
|
|
176
|
-
return resolved.flat();
|
|
215
|
+
return (await Promise.all(configs$1)).flat();
|
|
177
216
|
}
|
|
178
217
|
/**
|
|
179
218
|
* Rename plugin prefixes in a rule object.
|
|
@@ -210,9 +249,7 @@ async function ensurePackages(packages) {
|
|
|
210
249
|
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) return;
|
|
211
250
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
212
251
|
if (nonExistingPackages.length === 0) return;
|
|
213
|
-
|
|
214
|
-
const result = await p.confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
|
|
215
|
-
if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
252
|
+
if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
216
253
|
}
|
|
217
254
|
function isInEditorEnv() {
|
|
218
255
|
if (process.env.CI) return false;
|
|
@@ -279,18 +316,20 @@ async function effector(options = {}) {
|
|
|
279
316
|
//#endregion
|
|
280
317
|
//#region src/configs/stylistic.ts
|
|
281
318
|
const StylisticConfigDefaults = {
|
|
319
|
+
experimental: false,
|
|
282
320
|
indent: 2,
|
|
283
321
|
jsx: true,
|
|
284
322
|
quotes: "single",
|
|
285
323
|
semi: false
|
|
286
324
|
};
|
|
287
325
|
async function stylistic(options = {}) {
|
|
288
|
-
const { indent, jsx: jsx$1, overrides = {}, quotes, semi } = {
|
|
326
|
+
const { experimental, indent, jsx: jsx$1, overrides = {}, quotes, semi } = {
|
|
289
327
|
...StylisticConfigDefaults,
|
|
290
328
|
...options
|
|
291
329
|
};
|
|
292
330
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
293
331
|
const config$1 = pluginStylistic.configs.customize({
|
|
332
|
+
experimental,
|
|
294
333
|
indent,
|
|
295
334
|
jsx: jsx$1,
|
|
296
335
|
pluginName: "style",
|
|
@@ -305,8 +344,8 @@ async function stylistic(options = {}) {
|
|
|
305
344
|
},
|
|
306
345
|
rules: {
|
|
307
346
|
...config$1.rules,
|
|
347
|
+
...experimental ? {} : { "antfu/consistent-list-newline": "error" },
|
|
308
348
|
"antfu/consistent-chaining": "error",
|
|
309
|
-
"antfu/consistent-list-newline": "error",
|
|
310
349
|
"antfu/curly": "error",
|
|
311
350
|
"antfu/if-newline": "error",
|
|
312
351
|
"antfu/top-level-function": "error",
|
|
@@ -363,10 +402,9 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
363
402
|
xmlSortAttributesByKey: false,
|
|
364
403
|
xmlWhitespaceSensitivity: "ignore"
|
|
365
404
|
};
|
|
366
|
-
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
367
405
|
const configs$1 = [{
|
|
368
406
|
name: "formatter/setup",
|
|
369
|
-
plugins: { format:
|
|
407
|
+
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
370
408
|
}];
|
|
371
409
|
if (options.css) configs$1.push({
|
|
372
410
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
@@ -424,8 +462,11 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
424
462
|
//#endregion
|
|
425
463
|
//#region src/configs/ignores.ts
|
|
426
464
|
async function ignores(userIgnores = []) {
|
|
465
|
+
let ignores$1 = [...GLOB_EXCLUDE];
|
|
466
|
+
if (typeof userIgnores === "function") ignores$1 = userIgnores(ignores$1);
|
|
467
|
+
else ignores$1 = [...ignores$1, ...userIgnores];
|
|
427
468
|
return [{
|
|
428
|
-
ignores:
|
|
469
|
+
ignores: ignores$1,
|
|
429
470
|
name: "ignores"
|
|
430
471
|
}];
|
|
431
472
|
}
|
|
@@ -461,7 +502,7 @@ async function javascript(options = {}) {
|
|
|
461
502
|
const { isInEditor = false, overrides = {} } = options;
|
|
462
503
|
return [{
|
|
463
504
|
languageOptions: {
|
|
464
|
-
ecmaVersion:
|
|
505
|
+
ecmaVersion: "latest",
|
|
465
506
|
globals: {
|
|
466
507
|
...globals.browser,
|
|
467
508
|
...globals.es2021,
|
|
@@ -472,7 +513,7 @@ async function javascript(options = {}) {
|
|
|
472
513
|
},
|
|
473
514
|
parserOptions: {
|
|
474
515
|
ecmaFeatures: { jsx: true },
|
|
475
|
-
ecmaVersion:
|
|
516
|
+
ecmaVersion: "latest",
|
|
476
517
|
sourceType: "module"
|
|
477
518
|
},
|
|
478
519
|
sourceType: "module"
|
|
@@ -680,6 +721,37 @@ async function javascript(options = {}) {
|
|
|
680
721
|
}];
|
|
681
722
|
}
|
|
682
723
|
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/configs/jsdoc.ts
|
|
726
|
+
async function jsdoc(options = {}) {
|
|
727
|
+
const { stylistic: stylistic$1 = true } = options;
|
|
728
|
+
return [{
|
|
729
|
+
name: "jsdoc/rules",
|
|
730
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
731
|
+
rules: {
|
|
732
|
+
"jsdoc/check-access": "warn",
|
|
733
|
+
"jsdoc/check-param-names": "warn",
|
|
734
|
+
"jsdoc/check-property-names": "warn",
|
|
735
|
+
"jsdoc/check-types": "warn",
|
|
736
|
+
"jsdoc/empty-tags": "warn",
|
|
737
|
+
"jsdoc/implements-on-classes": "warn",
|
|
738
|
+
"jsdoc/no-defaults": "warn",
|
|
739
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
740
|
+
"jsdoc/require-param-name": "warn",
|
|
741
|
+
"jsdoc/require-property": "warn",
|
|
742
|
+
"jsdoc/require-property-description": "warn",
|
|
743
|
+
"jsdoc/require-property-name": "warn",
|
|
744
|
+
"jsdoc/require-returns-check": "warn",
|
|
745
|
+
"jsdoc/require-returns-description": "warn",
|
|
746
|
+
"jsdoc/require-yields-check": "warn",
|
|
747
|
+
...stylistic$1 ? {
|
|
748
|
+
"jsdoc/check-alignment": "warn",
|
|
749
|
+
"jsdoc/multiline-blocks": "warn"
|
|
750
|
+
} : {}
|
|
751
|
+
}
|
|
752
|
+
}];
|
|
753
|
+
}
|
|
754
|
+
|
|
683
755
|
//#endregion
|
|
684
756
|
//#region src/configs/jsonc.ts
|
|
685
757
|
async function jsonc(options = {}) {
|
|
@@ -849,14 +921,13 @@ async function markdown(options = {}) {
|
|
|
849
921
|
}
|
|
850
922
|
|
|
851
923
|
//#endregion
|
|
852
|
-
//#region src/configs/
|
|
853
|
-
async function
|
|
924
|
+
//#region src/configs/nextjs.ts
|
|
925
|
+
async function nextjs(options = {}) {
|
|
854
926
|
const { files = [GLOB_SRC], overrides = {} } = options;
|
|
855
927
|
await ensurePackages(["@next/eslint-plugin-next"]);
|
|
856
|
-
const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
|
|
857
928
|
return [{
|
|
858
929
|
name: "next/setup",
|
|
859
|
-
plugins: { next:
|
|
930
|
+
plugins: { next: await interopDefault(import("@next/eslint-plugin-next")) }
|
|
860
931
|
}, {
|
|
861
932
|
files,
|
|
862
933
|
languageOptions: {
|
|
@@ -966,38 +1037,128 @@ async function perfectionist() {
|
|
|
966
1037
|
|
|
967
1038
|
//#endregion
|
|
968
1039
|
//#region src/configs/pnpm.ts
|
|
969
|
-
async function pnpm() {
|
|
1040
|
+
async function pnpm(options) {
|
|
970
1041
|
const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
|
|
971
1042
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
972
1043
|
interopDefault(import("yaml-eslint-parser")),
|
|
973
1044
|
interopDefault(import("jsonc-eslint-parser"))
|
|
974
1045
|
]);
|
|
975
|
-
return [
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1046
|
+
return [
|
|
1047
|
+
{
|
|
1048
|
+
files: ["package.json", "**/package.json"],
|
|
1049
|
+
languageOptions: { parser: jsoncParser },
|
|
1050
|
+
name: "pnpm/package-json",
|
|
1051
|
+
plugins: { pnpm: pluginPnpm },
|
|
1052
|
+
rules: {
|
|
1053
|
+
"pnpm/json-enforce-catalog": ["error", { autofix: !options.isInEditor }],
|
|
1054
|
+
"pnpm/json-prefer-workspace-settings": ["error", { autofix: !options.isInEditor }],
|
|
1055
|
+
"pnpm/json-valid-catalog": ["error", { autofix: !options.isInEditor }]
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
files: ["pnpm-workspace.yaml"],
|
|
1060
|
+
languageOptions: { parser: yamlParser },
|
|
1061
|
+
name: "pnpm/pnpm-workspace-yaml",
|
|
1062
|
+
plugins: { pnpm: pluginPnpm },
|
|
1063
|
+
rules: {
|
|
1064
|
+
"pnpm/yaml-enforce-settings": ["error", { settings: {
|
|
1065
|
+
catalogMode: "prefer",
|
|
1066
|
+
cleanupUnusedCatalogs: true,
|
|
1067
|
+
shellEmulator: true,
|
|
1068
|
+
trustPolicy: "no-downgrade"
|
|
1069
|
+
} }],
|
|
1070
|
+
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
1071
|
+
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
files: ["pnpm-workspace.yaml"],
|
|
1076
|
+
name: "pnpm/pnpm-workspace-yaml-sort",
|
|
1077
|
+
rules: { "yaml/sort-keys": [
|
|
1078
|
+
"error",
|
|
1079
|
+
{
|
|
1080
|
+
order: [
|
|
1081
|
+
...[
|
|
1082
|
+
"cacheDir",
|
|
1083
|
+
"catalogMode",
|
|
1084
|
+
"cleanupUnusedCatalogs",
|
|
1085
|
+
"dedupeDirectDeps",
|
|
1086
|
+
"deployAllFiles",
|
|
1087
|
+
"enablePrePostScripts",
|
|
1088
|
+
"engineStrict",
|
|
1089
|
+
"extendNodePath",
|
|
1090
|
+
"hoist",
|
|
1091
|
+
"hoistPattern",
|
|
1092
|
+
"hoistWorkspacePackages",
|
|
1093
|
+
"ignoreCompatibilityDb",
|
|
1094
|
+
"ignoreDepScripts",
|
|
1095
|
+
"ignoreScripts",
|
|
1096
|
+
"ignoreWorkspaceRootCheck",
|
|
1097
|
+
"managePackageManagerVersions",
|
|
1098
|
+
"minimumReleaseAge",
|
|
1099
|
+
"minimumReleaseAgeExclude",
|
|
1100
|
+
"modulesDir",
|
|
1101
|
+
"nodeLinker",
|
|
1102
|
+
"nodeVersion",
|
|
1103
|
+
"optimisticRepeatInstall",
|
|
1104
|
+
"packageManagerStrict",
|
|
1105
|
+
"packageManagerStrictVersion",
|
|
1106
|
+
"preferSymlinkedExecutables",
|
|
1107
|
+
"preferWorkspacePackages",
|
|
1108
|
+
"publicHoistPattern",
|
|
1109
|
+
"registrySupportsTimeField",
|
|
1110
|
+
"requiredScrpts",
|
|
1111
|
+
"resolutionMode",
|
|
1112
|
+
"savePrefix",
|
|
1113
|
+
"scriptShell",
|
|
1114
|
+
"shamefullyHoist",
|
|
1115
|
+
"shellEmulator",
|
|
1116
|
+
"stateDir",
|
|
1117
|
+
"supportedArchitectures",
|
|
1118
|
+
"symlink",
|
|
1119
|
+
"tag",
|
|
1120
|
+
"trustPolicy",
|
|
1121
|
+
"trustPolicyExclude",
|
|
1122
|
+
"updateNotifier"
|
|
1123
|
+
],
|
|
1124
|
+
"packages",
|
|
1125
|
+
"overrides",
|
|
1126
|
+
"patchedDependencies",
|
|
1127
|
+
"catalog",
|
|
1128
|
+
"catalogs",
|
|
1129
|
+
...[
|
|
1130
|
+
"allowedDeprecatedVersions",
|
|
1131
|
+
"allowNonAppliedPatches",
|
|
1132
|
+
"configDependencies",
|
|
1133
|
+
"ignoredBuiltDependencies",
|
|
1134
|
+
"ignoredOptionalDependencies",
|
|
1135
|
+
"neverBuiltDependencies",
|
|
1136
|
+
"onlyBuiltDependencies",
|
|
1137
|
+
"onlyBuiltDependenciesFile",
|
|
1138
|
+
"packageExtensions",
|
|
1139
|
+
"peerDependencyRules"
|
|
1140
|
+
]
|
|
1141
|
+
],
|
|
1142
|
+
pathPattern: "^$"
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
order: { type: "asc" },
|
|
1146
|
+
pathPattern: ".*"
|
|
1147
|
+
}
|
|
1148
|
+
] }
|
|
993
1149
|
}
|
|
994
|
-
|
|
1150
|
+
];
|
|
995
1151
|
}
|
|
996
1152
|
|
|
997
1153
|
//#endregion
|
|
998
1154
|
//#region src/configs/react.ts
|
|
999
1155
|
async function react(options = {}) {
|
|
1000
1156
|
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {}, tsconfigPath } = options;
|
|
1157
|
+
await ensurePackages([
|
|
1158
|
+
"@eslint-react/eslint-plugin",
|
|
1159
|
+
"eslint-plugin-react-hooks",
|
|
1160
|
+
"eslint-plugin-react-refresh"
|
|
1161
|
+
]);
|
|
1001
1162
|
const isTypeAware = !!tsconfigPath;
|
|
1002
1163
|
const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
|
|
1003
1164
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
@@ -1006,6 +1167,7 @@ async function react(options = {}) {
|
|
|
1006
1167
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1007
1168
|
]);
|
|
1008
1169
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
1170
|
+
const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
1009
1171
|
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
|
|
1010
1172
|
const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
|
|
1011
1173
|
const plugins = pluginReact.configs.all.plugins;
|
|
@@ -1030,6 +1192,7 @@ async function react(options = {}) {
|
|
|
1030
1192
|
},
|
|
1031
1193
|
name: "react/rules",
|
|
1032
1194
|
rules: {
|
|
1195
|
+
"react/jsx-no-comment-textnodes": "warn",
|
|
1033
1196
|
"react/jsx-no-duplicate-props": "warn",
|
|
1034
1197
|
"react/jsx-uses-vars": "warn",
|
|
1035
1198
|
"react/no-access-state-in-setstate": "error",
|
|
@@ -1040,7 +1203,6 @@ async function react(options = {}) {
|
|
|
1040
1203
|
"react/no-children-only": "warn",
|
|
1041
1204
|
"react/no-children-to-array": "warn",
|
|
1042
1205
|
"react/no-clone-element": "warn",
|
|
1043
|
-
"react/no-comment-textnodes": "warn",
|
|
1044
1206
|
"react/no-component-will-mount": "error",
|
|
1045
1207
|
"react/no-component-will-receive-props": "error",
|
|
1046
1208
|
"react/no-component-will-update": "error",
|
|
@@ -1059,6 +1221,7 @@ async function react(options = {}) {
|
|
|
1059
1221
|
"react/no-set-state-in-component-did-update": "warn",
|
|
1060
1222
|
"react/no-set-state-in-component-will-update": "warn",
|
|
1061
1223
|
"react/no-string-refs": "error",
|
|
1224
|
+
"react/no-unnecessary-use-prefix": "warn",
|
|
1062
1225
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1063
1226
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1064
1227
|
"react/no-unsafe-component-will-update": "warn",
|
|
@@ -1068,6 +1231,7 @@ async function react(options = {}) {
|
|
|
1068
1231
|
"react/no-unused-state": "warn",
|
|
1069
1232
|
"react/no-use-context": "warn",
|
|
1070
1233
|
"react/no-useless-forward-ref": "warn",
|
|
1234
|
+
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1071
1235
|
"react/prefer-shorthand-boolean": "warn",
|
|
1072
1236
|
"react/prefer-destructuring-assignment": "warn",
|
|
1073
1237
|
"react/no-missing-context-display-name": "warn",
|
|
@@ -1087,11 +1251,8 @@ async function react(options = {}) {
|
|
|
1087
1251
|
"react-dom/no-unsafe-target-blank": "warn",
|
|
1088
1252
|
"react-dom/no-use-form-state": "error",
|
|
1089
1253
|
"react-dom/no-void-elements-with-children": "error",
|
|
1090
|
-
|
|
1091
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1254
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
1092
1255
|
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1093
|
-
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
1094
|
-
"react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
|
|
1095
1256
|
"react-web-api/no-leaked-event-listener": "warn",
|
|
1096
1257
|
"react-web-api/no-leaked-interval": "warn",
|
|
1097
1258
|
"react-web-api/no-leaked-resize-observer": "warn",
|
|
@@ -1114,7 +1275,7 @@ async function react(options = {}) {
|
|
|
1114
1275
|
"generateMetadata",
|
|
1115
1276
|
"viewport",
|
|
1116
1277
|
"generateViewport"
|
|
1117
|
-
] : [], ...isUsingReactRouter ? [
|
|
1278
|
+
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1118
1279
|
"meta",
|
|
1119
1280
|
"links",
|
|
1120
1281
|
"headers",
|
|
@@ -1299,6 +1460,14 @@ async function sortPackageJson() {
|
|
|
1299
1460
|
order: { type: "asc" },
|
|
1300
1461
|
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
1301
1462
|
},
|
|
1463
|
+
{
|
|
1464
|
+
order: { type: "asc" },
|
|
1465
|
+
pathPattern: "^workspaces\\.catalog$"
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
order: { type: "asc" },
|
|
1469
|
+
pathPattern: "^workspaces\\.catalogs\\.[^.]+$"
|
|
1470
|
+
},
|
|
1302
1471
|
{
|
|
1303
1472
|
order: [
|
|
1304
1473
|
"types",
|
|
@@ -1449,6 +1618,44 @@ function sortTsconfig() {
|
|
|
1449
1618
|
}];
|
|
1450
1619
|
}
|
|
1451
1620
|
|
|
1621
|
+
//#endregion
|
|
1622
|
+
//#region src/configs/test.ts
|
|
1623
|
+
let _pluginTest;
|
|
1624
|
+
async function test(options = {}) {
|
|
1625
|
+
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
1626
|
+
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
|
|
1627
|
+
_pluginTest = _pluginTest || {
|
|
1628
|
+
...pluginVitest,
|
|
1629
|
+
rules: {
|
|
1630
|
+
...pluginVitest.rules,
|
|
1631
|
+
...pluginNoOnlyTests.rules
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
return [{
|
|
1635
|
+
name: "test/setup",
|
|
1636
|
+
plugins: { test: _pluginTest }
|
|
1637
|
+
}, {
|
|
1638
|
+
files,
|
|
1639
|
+
name: "test/rules",
|
|
1640
|
+
rules: {
|
|
1641
|
+
"test/consistent-test-it": ["error", {
|
|
1642
|
+
fn: "it",
|
|
1643
|
+
withinDescribe: "it"
|
|
1644
|
+
}],
|
|
1645
|
+
"test/no-identical-title": "error",
|
|
1646
|
+
"test/no-import-node-test": "error",
|
|
1647
|
+
"test/no-only-tests": isInEditor ? "warn" : "error",
|
|
1648
|
+
"test/prefer-hooks-in-order": "error",
|
|
1649
|
+
"test/prefer-lowercase-title": "error",
|
|
1650
|
+
"antfu/no-top-level-await": "off",
|
|
1651
|
+
"no-unused-expressions": "off",
|
|
1652
|
+
"node/prefer-global/process": "off",
|
|
1653
|
+
"ts/explicit-function-return-type": "off",
|
|
1654
|
+
...overrides
|
|
1655
|
+
}
|
|
1656
|
+
}];
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1452
1659
|
//#endregion
|
|
1453
1660
|
//#region src/configs/toml.ts
|
|
1454
1661
|
async function toml(options = {}) {
|
|
@@ -1493,7 +1700,7 @@ async function toml(options = {}) {
|
|
|
1493
1700
|
//#endregion
|
|
1494
1701
|
//#region src/configs/typescript.ts
|
|
1495
1702
|
async function typescript(options = {}) {
|
|
1496
|
-
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
1703
|
+
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
1497
1704
|
const files = options.files ?? [
|
|
1498
1705
|
GLOB_TS,
|
|
1499
1706
|
GLOB_TSX,
|
|
@@ -1620,6 +1827,16 @@ async function typescript(options = {}) {
|
|
|
1620
1827
|
...typeAwareRules,
|
|
1621
1828
|
...overridesTypeAware
|
|
1622
1829
|
}
|
|
1830
|
+
}] : [],
|
|
1831
|
+
...erasableOnly ? [{
|
|
1832
|
+
name: "antfu/typescript/erasable-syntax-only",
|
|
1833
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-CEKTiw7V.js")) },
|
|
1834
|
+
rules: {
|
|
1835
|
+
"erasable-syntax-only/enums": "error",
|
|
1836
|
+
"erasable-syntax-only/import-aliases": "error",
|
|
1837
|
+
"erasable-syntax-only/namespaces": "error",
|
|
1838
|
+
"erasable-syntax-only/parameter-properties": "error"
|
|
1839
|
+
}
|
|
1623
1840
|
}] : []
|
|
1624
1841
|
];
|
|
1625
1842
|
}
|
|
@@ -1677,6 +1894,11 @@ async function vue(options = {}) {
|
|
|
1677
1894
|
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic: stylistic$1 = true, vueVersion = 3 } = options;
|
|
1678
1895
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1679
1896
|
const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
1897
|
+
await ensurePackages([
|
|
1898
|
+
"eslint-plugin-vue",
|
|
1899
|
+
"vue-eslint-parser",
|
|
1900
|
+
"eslint-processor-vue-blocks"
|
|
1901
|
+
]);
|
|
1680
1902
|
if (a11y) await ensurePackages(["eslint-plugin-vuejs-accessibility"]);
|
|
1681
1903
|
const [pluginVue, parserVue, processorVueBlocks, pluginVueA11y] = await Promise.all([
|
|
1682
1904
|
interopDefault(import("eslint-plugin-vue")),
|
|
@@ -1883,77 +2105,41 @@ async function yaml(options = {}) {
|
|
|
1883
2105
|
const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic$1 = true } = options;
|
|
1884
2106
|
const { indent = 2, quotes = "single" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
1885
2107
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
1886
|
-
return [
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
{
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
"yaml/
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
} : {},
|
|
1920
|
-
...overrides
|
|
1921
|
-
}
|
|
1922
|
-
},
|
|
1923
|
-
{
|
|
1924
|
-
files: ["pnpm-workspace.yaml"],
|
|
1925
|
-
name: "yaml/pnpm-workspace",
|
|
1926
|
-
rules: { "yaml/sort-keys": [
|
|
1927
|
-
"error",
|
|
1928
|
-
{
|
|
1929
|
-
order: [
|
|
1930
|
-
"packages",
|
|
1931
|
-
"overrides",
|
|
1932
|
-
"patchedDependencies",
|
|
1933
|
-
"hoistPattern",
|
|
1934
|
-
"catalog",
|
|
1935
|
-
"catalogs",
|
|
1936
|
-
"allowedDeprecatedVersions",
|
|
1937
|
-
"allowNonAppliedPatches",
|
|
1938
|
-
"configDependencies",
|
|
1939
|
-
"ignoredBuiltDependencies",
|
|
1940
|
-
"ignoredOptionalDependencies",
|
|
1941
|
-
"neverBuiltDependencies",
|
|
1942
|
-
"onlyBuiltDependencies",
|
|
1943
|
-
"onlyBuiltDependenciesFile",
|
|
1944
|
-
"packageExtensions",
|
|
1945
|
-
"peerDependencyRules",
|
|
1946
|
-
"supportedArchitectures"
|
|
1947
|
-
],
|
|
1948
|
-
pathPattern: "^$"
|
|
1949
|
-
},
|
|
1950
|
-
{
|
|
1951
|
-
order: { type: "asc" },
|
|
1952
|
-
pathPattern: ".*"
|
|
1953
|
-
}
|
|
1954
|
-
] }
|
|
2108
|
+
return [{
|
|
2109
|
+
name: "yaml/setup",
|
|
2110
|
+
plugins: { yaml: pluginYaml }
|
|
2111
|
+
}, {
|
|
2112
|
+
files,
|
|
2113
|
+
languageOptions: { parser: parserYaml },
|
|
2114
|
+
name: "yaml/rules",
|
|
2115
|
+
rules: {
|
|
2116
|
+
"style/spaced-comment": "off",
|
|
2117
|
+
"yaml/block-mapping": "error",
|
|
2118
|
+
"yaml/block-sequence": "error",
|
|
2119
|
+
"yaml/no-empty-key": "error",
|
|
2120
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
2121
|
+
"yaml/no-irregular-whitespace": "error",
|
|
2122
|
+
"yaml/plain-scalar": "error",
|
|
2123
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2124
|
+
...stylistic$1 ? {
|
|
2125
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2126
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2127
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
2128
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
2129
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
2130
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2131
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
2132
|
+
"yaml/key-spacing": "error",
|
|
2133
|
+
"yaml/no-tab-indent": "error",
|
|
2134
|
+
"yaml/quotes": ["error", {
|
|
2135
|
+
avoidEscape: true,
|
|
2136
|
+
prefer: quotes === "backtick" ? "single" : quotes
|
|
2137
|
+
}],
|
|
2138
|
+
"yaml/spaced-comment": "error"
|
|
2139
|
+
} : {},
|
|
2140
|
+
...overrides
|
|
1955
2141
|
}
|
|
1956
|
-
];
|
|
2142
|
+
}];
|
|
1957
2143
|
}
|
|
1958
2144
|
|
|
1959
2145
|
//#endregion
|
|
@@ -1977,6 +2163,7 @@ const defaultPluginRenaming = {
|
|
|
1977
2163
|
"@typescript-eslint": "ts",
|
|
1978
2164
|
"import-lite": "import",
|
|
1979
2165
|
"n": "node",
|
|
2166
|
+
"vitest": "test",
|
|
1980
2167
|
"yml": "yaml"
|
|
1981
2168
|
};
|
|
1982
2169
|
/**
|
|
@@ -1990,8 +2177,7 @@ const defaultPluginRenaming = {
|
|
|
1990
2177
|
* The merged ESLint configurations.
|
|
1991
2178
|
*/
|
|
1992
2179
|
function config(options = {}, ...userConfigs) {
|
|
1993
|
-
const
|
|
1994
|
-
const { autoRenamePlugins = true, componentExts = [], effector: enableEffector = isPackageExists("effector"), gitignore: enableGitignore = true, imports: enableImports = true, jsx: enableJsx = true, next: enableNext = NextJsPackages.some((i) => isPackageExists(i)), pnpm: enableCatalogs = false, react: enableReact = isUsingReact, reactNative: enableReactNative = ReactNativePackages.some((i) => isPackageExists(i)), regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2180
|
+
const { autoRenamePlugins = true, componentExts = [], effector: enableEffector = isPackageExists("effector"), gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsx: enableJsx = true, nextjs: enableNext = NextJsPackages.some((i) => isPackageExists(i)), pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = ReactPackages.some((i) => isPackageExists(i)), reactNative: enableReactNative = ReactNativePackages.some((i) => isPackageExists(i)), regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = isPackageExists("unocss"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
1995
2181
|
let isInEditor = options.isInEditor;
|
|
1996
2182
|
if (isInEditor == null) {
|
|
1997
2183
|
isInEditor = isInEditorEnv();
|
|
@@ -2010,10 +2196,10 @@ function config(options = {}, ...userConfigs) {
|
|
|
2010
2196
|
})]));
|
|
2011
2197
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2012
2198
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2013
|
-
configs$1.push(ignores(
|
|
2199
|
+
configs$1.push(ignores(userIgnores), javascript({
|
|
2014
2200
|
isInEditor,
|
|
2015
2201
|
overrides: getOverrides(options, "javascript")
|
|
2016
|
-
}), comments(), node(), imports({ stylistic: stylisticOptions }), perfectionist());
|
|
2202
|
+
}), comments(), node(), jsdoc({ stylistic: stylisticOptions }), imports({ stylistic: stylisticOptions }), perfectionist());
|
|
2017
2203
|
if (enableImports) configs$1.push(imports(enableImports === true ? { stylistic: stylisticOptions } : {
|
|
2018
2204
|
stylistic: stylisticOptions,
|
|
2019
2205
|
...enableImports
|
|
@@ -2032,6 +2218,10 @@ function config(options = {}, ...userConfigs) {
|
|
|
2032
2218
|
overrides: getOverrides(options, "stylistic")
|
|
2033
2219
|
}));
|
|
2034
2220
|
if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2221
|
+
if (options.test ?? true) configs$1.push(test({
|
|
2222
|
+
isInEditor,
|
|
2223
|
+
overrides: getOverrides(options, "test")
|
|
2224
|
+
}));
|
|
2035
2225
|
if (enableVue) configs$1.push(vue({
|
|
2036
2226
|
...resolveSubOptions(options, "vue"),
|
|
2037
2227
|
overrides: getOverrides(options, "vue"),
|
|
@@ -2047,7 +2237,7 @@ function config(options = {}, ...userConfigs) {
|
|
|
2047
2237
|
...resolveSubOptions(options, "reactNative"),
|
|
2048
2238
|
overrides: getOverrides(options, "reactNative")
|
|
2049
2239
|
}));
|
|
2050
|
-
if (enableNext) configs$1.push(
|
|
2240
|
+
if (enableNext) configs$1.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2051
2241
|
if (enableEffector) configs$1.push(effector({
|
|
2052
2242
|
...resolveSubOptions(options, "effector"),
|
|
2053
2243
|
overrides: getOverrides(options, "effector")
|
|
@@ -2060,7 +2250,7 @@ function config(options = {}, ...userConfigs) {
|
|
|
2060
2250
|
overrides: getOverrides(options, "jsonc"),
|
|
2061
2251
|
stylistic: stylisticOptions
|
|
2062
2252
|
}), sortPackageJson(), sortTsconfig());
|
|
2063
|
-
if (enableCatalogs) configs$1.push(pnpm());
|
|
2253
|
+
if (enableCatalogs) configs$1.push(pnpm({ isInEditor }));
|
|
2064
2254
|
if (options.yaml ?? true) configs$1.push(yaml({
|
|
2065
2255
|
overrides: getOverrides(options, "yaml"),
|
|
2066
2256
|
stylistic: stylisticOptions
|
|
@@ -2084,7 +2274,11 @@ function config(options = {}, ...userConfigs) {
|
|
|
2084
2274
|
let composer = new FlatConfigComposer();
|
|
2085
2275
|
composer = composer.append(...configs$1, ...userConfigs);
|
|
2086
2276
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2087
|
-
if (isInEditor) composer = composer.disableRulesFix([
|
|
2277
|
+
if (isInEditor) composer = composer.disableRulesFix([
|
|
2278
|
+
"unused-imports/no-unused-imports",
|
|
2279
|
+
"test/no-only-tests",
|
|
2280
|
+
"prefer-const"
|
|
2281
|
+
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
2088
2282
|
return composer;
|
|
2089
2283
|
}
|
|
2090
2284
|
|
|
@@ -2093,4 +2287,4 @@ function config(options = {}, ...userConfigs) {
|
|
|
2093
2287
|
var src_default = config;
|
|
2094
2288
|
|
|
2095
2289
|
//#endregion
|
|
2096
|
-
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, combine, comments, config, src_default as default, defaultPluginRenaming, disables, effector, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsonc, jsx, markdown,
|
|
2290
|
+
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, combine, comments, config, src_default as default, defaultPluginRenaming, disables, effector, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, reactNative, regexp, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, unocss, vue, yaml };
|