@ghettoddos/eslint-config 4.0.0 → 4.1.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 +2 -3
- package/dist/index.d.mts +6301 -5395
- package/dist/index.mjs +216 -236
- package/dist/{lib-D6spnV0Z.mjs → lib-C63e_zBF.mjs} +631 -892
- package/package.json +82 -61
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import fs$1 from "node:fs";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { isPackageExists } from "local-pkg";
|
|
8
8
|
import createCommand from "eslint-plugin-command/config";
|
|
9
|
+
import pluginE18e from "@e18e/eslint-plugin";
|
|
9
10
|
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
10
11
|
import pluginAntfu from "eslint-plugin-antfu";
|
|
11
12
|
import pluginImportLite from "eslint-plugin-import-lite";
|
|
@@ -13,11 +14,9 @@ import pluginNode from "eslint-plugin-n";
|
|
|
13
14
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
14
15
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
15
16
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
16
|
-
import { fixupPluginRules } from "@eslint/compat";
|
|
17
17
|
import globals from "globals";
|
|
18
18
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
19
19
|
import { configs } from "eslint-plugin-regexp";
|
|
20
|
-
|
|
21
20
|
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
22
21
|
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
23
22
|
async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
@@ -50,7 +49,6 @@ function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
|
50
49
|
directory = path.dirname(directory);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
|
-
|
|
54
52
|
//#endregion
|
|
55
53
|
//#region src/configs/command.ts
|
|
56
54
|
async function command() {
|
|
@@ -59,7 +57,6 @@ async function command() {
|
|
|
59
57
|
name: "command/rules"
|
|
60
58
|
}];
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
//#endregion
|
|
64
61
|
//#region src/configs/comments.ts
|
|
65
62
|
async function comments() {
|
|
@@ -74,7 +71,6 @@ async function comments() {
|
|
|
74
71
|
}
|
|
75
72
|
}];
|
|
76
73
|
}
|
|
77
|
-
|
|
78
74
|
//#endregion
|
|
79
75
|
//#region src/globs.ts
|
|
80
76
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -149,7 +145,6 @@ const GLOB_EXCLUDE = [
|
|
|
149
145
|
"**/auto-import?(s).d.ts",
|
|
150
146
|
"**/components.d.ts"
|
|
151
147
|
];
|
|
152
|
-
|
|
153
148
|
//#endregion
|
|
154
149
|
//#region src/configs/disables.ts
|
|
155
150
|
async function disables() {
|
|
@@ -179,39 +174,6 @@ async function disables() {
|
|
|
179
174
|
}
|
|
180
175
|
];
|
|
181
176
|
}
|
|
182
|
-
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/constants.ts
|
|
185
|
-
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
186
|
-
const RemixPackages = [
|
|
187
|
-
"@remix-run/node",
|
|
188
|
-
"@remix-run/react",
|
|
189
|
-
"@remix-run/serve",
|
|
190
|
-
"@remix-run/dev"
|
|
191
|
-
];
|
|
192
|
-
const ReactRouterPackages = [
|
|
193
|
-
"@react-router/node",
|
|
194
|
-
"@react-router/react",
|
|
195
|
-
"@react-router/serve",
|
|
196
|
-
"@react-router/dev"
|
|
197
|
-
];
|
|
198
|
-
const NextJsPackages = ["next"];
|
|
199
|
-
const ReactNativePackages = ["react-native", "expo"];
|
|
200
|
-
const ReactPackages = [
|
|
201
|
-
...RemixPackages,
|
|
202
|
-
...ReactRouterPackages,
|
|
203
|
-
...NextJsPackages,
|
|
204
|
-
...ReactNativePackages,
|
|
205
|
-
"react"
|
|
206
|
-
];
|
|
207
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
208
|
-
const VuePackages = [
|
|
209
|
-
"vue",
|
|
210
|
-
"nuxt",
|
|
211
|
-
"vitepress",
|
|
212
|
-
"@slidev/cli"
|
|
213
|
-
];
|
|
214
|
-
|
|
215
177
|
//#endregion
|
|
216
178
|
//#region src/utils.ts
|
|
217
179
|
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -238,8 +200,8 @@ const parserPlain = {
|
|
|
238
200
|
/**
|
|
239
201
|
* Combine array and non-array configs into a single array.
|
|
240
202
|
*/
|
|
241
|
-
async function combine(...configs
|
|
242
|
-
return (await Promise.all(configs
|
|
203
|
+
async function combine(...configs) {
|
|
204
|
+
return (await Promise.all(configs)).flat();
|
|
243
205
|
}
|
|
244
206
|
/**
|
|
245
207
|
* Rename plugin prefixes in a rule object.
|
|
@@ -281,7 +243,7 @@ async function ensurePackages(packages) {
|
|
|
281
243
|
function isInEditorEnv() {
|
|
282
244
|
if (process.env.CI) return false;
|
|
283
245
|
if (isInGitHooksOrLintStaged()) return false;
|
|
284
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
246
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || process.env.ZED_ENVIRONMENT && !process.env.ZED_TERM);
|
|
285
247
|
}
|
|
286
248
|
function isInGitHooksOrLintStaged() {
|
|
287
249
|
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
@@ -296,50 +258,6 @@ function getOverrides(options, key) {
|
|
|
296
258
|
..."overrides" in sub ? sub.overrides : {}
|
|
297
259
|
};
|
|
298
260
|
}
|
|
299
|
-
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region src/configs/effector.ts
|
|
302
|
-
async function effector(options = {}) {
|
|
303
|
-
const { future = false, overrides = {}, patronum = isPackageExists("patronum"), react: react$1 = ReactPackages.some((i) => isPackageExists(i)), scope = false } = options;
|
|
304
|
-
await ensurePackages(["eslint-plugin-effector"]);
|
|
305
|
-
const [pluginEffector] = await Promise.all([interopDefault(import("eslint-plugin-effector"))]);
|
|
306
|
-
return [{
|
|
307
|
-
name: "effector/setup",
|
|
308
|
-
plugins: { effector: fixupPluginRules(pluginEffector) }
|
|
309
|
-
}, {
|
|
310
|
-
name: "effector/rules",
|
|
311
|
-
rules: {
|
|
312
|
-
"effector/enforce-effect-naming-convention": "error",
|
|
313
|
-
"effector/enforce-store-naming-convention": "error",
|
|
314
|
-
"effector/keep-options-order": "warn",
|
|
315
|
-
"effector/no-ambiguity-target": "warn",
|
|
316
|
-
"effector/no-duplicate-on": "error",
|
|
317
|
-
"effector/no-getState": "error",
|
|
318
|
-
"effector/no-unnecessary-combination": "warn",
|
|
319
|
-
"effector/no-unnecessary-duplication": "warn",
|
|
320
|
-
"effector/no-useless-methods": "error",
|
|
321
|
-
"effector/no-watch": "warn",
|
|
322
|
-
"effector/prefer-sample-over-forward-with-mapping": "warn",
|
|
323
|
-
...react$1 ? {
|
|
324
|
-
"effector/enforce-gate-naming-convention": "error",
|
|
325
|
-
"effector/mandatory-scope-binding": "error",
|
|
326
|
-
"effector/prefer-useUnit": "warn"
|
|
327
|
-
} : {},
|
|
328
|
-
...patronum ? { "effector/no-patronum-debug": "error" } : {},
|
|
329
|
-
...scope ? {
|
|
330
|
-
"effector/require-pickup-in-persist": "error",
|
|
331
|
-
"effector/strict-effect-handlers": "error"
|
|
332
|
-
} : {},
|
|
333
|
-
...future ? {
|
|
334
|
-
"effector/no-forward": "warn",
|
|
335
|
-
"effector/no-guard": "warn",
|
|
336
|
-
"effector/prefer-sample-over-forward-with-mapping": "off"
|
|
337
|
-
} : {},
|
|
338
|
-
...overrides
|
|
339
|
-
}
|
|
340
|
-
}];
|
|
341
|
-
}
|
|
342
|
-
|
|
343
261
|
//#endregion
|
|
344
262
|
//#region src/configs/stylistic.ts
|
|
345
263
|
const StylisticConfigDefaults = {
|
|
@@ -350,15 +268,15 @@ const StylisticConfigDefaults = {
|
|
|
350
268
|
semi: false
|
|
351
269
|
};
|
|
352
270
|
async function stylistic(options = {}) {
|
|
353
|
-
const { experimental, indent, jsx
|
|
271
|
+
const { experimental, indent, jsx, overrides = {}, quotes, semi } = {
|
|
354
272
|
...StylisticConfigDefaults,
|
|
355
273
|
...options
|
|
356
274
|
};
|
|
357
275
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
358
|
-
const config
|
|
276
|
+
const config = pluginStylistic.configs.customize({
|
|
359
277
|
experimental,
|
|
360
278
|
indent,
|
|
361
|
-
jsx
|
|
279
|
+
jsx,
|
|
362
280
|
pluginName: "style",
|
|
363
281
|
quotes,
|
|
364
282
|
semi
|
|
@@ -370,7 +288,7 @@ async function stylistic(options = {}) {
|
|
|
370
288
|
style: pluginStylistic
|
|
371
289
|
},
|
|
372
290
|
rules: {
|
|
373
|
-
...config
|
|
291
|
+
...config.rules,
|
|
374
292
|
...experimental ? {} : { "antfu/consistent-list-newline": "error" },
|
|
375
293
|
"antfu/consistent-chaining": "error",
|
|
376
294
|
"antfu/curly": "error",
|
|
@@ -388,17 +306,16 @@ async function stylistic(options = {}) {
|
|
|
388
306
|
}
|
|
389
307
|
}];
|
|
390
308
|
}
|
|
391
|
-
|
|
392
309
|
//#endregion
|
|
393
310
|
//#region src/configs/formatters.ts
|
|
394
|
-
function mergePrettierOptions(options, overrides
|
|
311
|
+
function mergePrettierOptions(options, overrides) {
|
|
395
312
|
return {
|
|
396
313
|
...options,
|
|
397
314
|
...overrides,
|
|
398
315
|
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
399
316
|
};
|
|
400
317
|
}
|
|
401
|
-
async function formatters(options = {}, stylistic
|
|
318
|
+
async function formatters(options = {}, stylistic = {}) {
|
|
402
319
|
if (options === true) {
|
|
403
320
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
404
321
|
options = {
|
|
@@ -412,7 +329,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
412
329
|
await ensurePackages(["eslint-plugin-format", options.xml || options.svg ? "@prettier/plugin-xml" : void 0]);
|
|
413
330
|
const { indent, quotes, semi } = {
|
|
414
331
|
...StylisticConfigDefaults,
|
|
415
|
-
...stylistic
|
|
332
|
+
...stylistic
|
|
416
333
|
};
|
|
417
334
|
const prettierOptions = Object.assign({
|
|
418
335
|
endOfLine: "auto",
|
|
@@ -429,11 +346,11 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
429
346
|
xmlSortAttributesByKey: false,
|
|
430
347
|
xmlWhitespaceSensitivity: "ignore"
|
|
431
348
|
};
|
|
432
|
-
const configs
|
|
349
|
+
const configs = [{
|
|
433
350
|
name: "formatter/setup",
|
|
434
351
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
435
352
|
}];
|
|
436
|
-
if (options.css) configs
|
|
353
|
+
if (options.css) configs.push({
|
|
437
354
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
438
355
|
languageOptions: { parser: parserPlain },
|
|
439
356
|
name: "formatter/css",
|
|
@@ -444,13 +361,13 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
444
361
|
name: "formatter/scss",
|
|
445
362
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
|
|
446
363
|
});
|
|
447
|
-
if (options.html) configs
|
|
364
|
+
if (options.html) configs.push({
|
|
448
365
|
files: [GLOB_HTML],
|
|
449
366
|
languageOptions: { parser: parserPlain },
|
|
450
367
|
name: "formatter/html",
|
|
451
368
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
452
369
|
});
|
|
453
|
-
if (options.xml) configs
|
|
370
|
+
if (options.xml) configs.push({
|
|
454
371
|
files: [GLOB_XML],
|
|
455
372
|
languageOptions: { parser: parserPlain },
|
|
456
373
|
name: "formatter/xml",
|
|
@@ -462,7 +379,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
462
379
|
plugins: ["@prettier/plugin-xml"]
|
|
463
380
|
})] }
|
|
464
381
|
});
|
|
465
|
-
if (options.svg) configs
|
|
382
|
+
if (options.svg) configs.push({
|
|
466
383
|
files: [GLOB_SVG],
|
|
467
384
|
languageOptions: { parser: parserPlain },
|
|
468
385
|
name: "formatter/svg",
|
|
@@ -474,7 +391,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
474
391
|
plugins: ["@prettier/plugin-xml"]
|
|
475
392
|
})] }
|
|
476
393
|
});
|
|
477
|
-
if (options.markdown) configs
|
|
394
|
+
if (options.markdown) configs.push({
|
|
478
395
|
files: [GLOB_MARKDOWN],
|
|
479
396
|
languageOptions: { parser: parserPlain },
|
|
480
397
|
name: "formatter/markdown",
|
|
@@ -483,13 +400,13 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
483
400
|
parser: "markdown"
|
|
484
401
|
})] }
|
|
485
402
|
});
|
|
486
|
-
return configs
|
|
403
|
+
return configs;
|
|
487
404
|
}
|
|
488
|
-
|
|
489
405
|
//#endregion
|
|
490
406
|
//#region src/configs/ignores.ts
|
|
491
|
-
async function ignores(userIgnores = []) {
|
|
407
|
+
async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
492
408
|
let ignores = [...GLOB_EXCLUDE];
|
|
409
|
+
if (ignoreTypeScript) ignores.push(GLOB_TS, GLOB_TSX);
|
|
493
410
|
if (typeof userIgnores === "function") ignores = userIgnores(ignores);
|
|
494
411
|
else ignores = [...ignores, ...userIgnores];
|
|
495
412
|
return [{
|
|
@@ -497,11 +414,10 @@ async function ignores(userIgnores = []) {
|
|
|
497
414
|
name: "ignores"
|
|
498
415
|
}];
|
|
499
416
|
}
|
|
500
|
-
|
|
501
417
|
//#endregion
|
|
502
418
|
//#region src/configs/imports.ts
|
|
503
419
|
async function imports(options = {}) {
|
|
504
|
-
const { overrides = {}, stylistic
|
|
420
|
+
const { overrides = {}, stylistic = true } = options;
|
|
505
421
|
return [{
|
|
506
422
|
name: "imports/rules",
|
|
507
423
|
plugins: {
|
|
@@ -517,12 +433,11 @@ async function imports(options = {}) {
|
|
|
517
433
|
"import/no-duplicates": "error",
|
|
518
434
|
"import/no-mutable-exports": "error",
|
|
519
435
|
"import/no-named-default": "error",
|
|
520
|
-
...stylistic
|
|
436
|
+
...stylistic ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
|
|
521
437
|
...overrides
|
|
522
438
|
}
|
|
523
439
|
}];
|
|
524
440
|
}
|
|
525
|
-
|
|
526
441
|
//#endregion
|
|
527
442
|
//#region src/configs/javascript.ts
|
|
528
443
|
async function javascript(options = {}) {
|
|
@@ -747,14 +662,16 @@ async function javascript(options = {}) {
|
|
|
747
662
|
}
|
|
748
663
|
}];
|
|
749
664
|
}
|
|
750
|
-
|
|
751
665
|
//#endregion
|
|
752
666
|
//#region src/configs/jsdoc.ts
|
|
753
667
|
async function jsdoc(options = {}) {
|
|
754
|
-
const { stylistic
|
|
668
|
+
const { stylistic = true } = options;
|
|
755
669
|
return [{
|
|
670
|
+
name: "jsdoc/setup",
|
|
671
|
+
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
672
|
+
}, {
|
|
673
|
+
files: [GLOB_SRC],
|
|
756
674
|
name: "jsdoc/rules",
|
|
757
|
-
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
758
675
|
rules: {
|
|
759
676
|
"jsdoc/check-access": "warn",
|
|
760
677
|
"jsdoc/check-param-names": "warn",
|
|
@@ -771,14 +688,13 @@ async function jsdoc(options = {}) {
|
|
|
771
688
|
"jsdoc/require-returns-check": "warn",
|
|
772
689
|
"jsdoc/require-returns-description": "warn",
|
|
773
690
|
"jsdoc/require-yields-check": "warn",
|
|
774
|
-
...stylistic
|
|
691
|
+
...stylistic ? {
|
|
775
692
|
"jsdoc/check-alignment": "warn",
|
|
776
693
|
"jsdoc/multiline-blocks": "warn"
|
|
777
694
|
} : {}
|
|
778
695
|
}
|
|
779
696
|
}];
|
|
780
697
|
}
|
|
781
|
-
|
|
782
698
|
//#endregion
|
|
783
699
|
//#region src/configs/jsonc.ts
|
|
784
700
|
async function jsonc(options = {}) {
|
|
@@ -786,15 +702,14 @@ async function jsonc(options = {}) {
|
|
|
786
702
|
GLOB_JSON,
|
|
787
703
|
GLOB_JSON5,
|
|
788
704
|
GLOB_JSONC
|
|
789
|
-
], overrides = {}, stylistic
|
|
790
|
-
const { indent = 2 } = typeof stylistic
|
|
791
|
-
const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
705
|
+
], overrides = {}, stylistic = true } = options;
|
|
706
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
792
707
|
return [{
|
|
793
708
|
name: "jsonc/setup",
|
|
794
|
-
plugins: { jsonc:
|
|
709
|
+
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
795
710
|
}, {
|
|
796
711
|
files,
|
|
797
|
-
|
|
712
|
+
language: "jsonc/x",
|
|
798
713
|
name: "jsonc/rules",
|
|
799
714
|
rules: {
|
|
800
715
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -823,7 +738,7 @@ async function jsonc(options = {}) {
|
|
|
823
738
|
"jsonc/space-unary-ops": "error",
|
|
824
739
|
"jsonc/valid-json-number": "error",
|
|
825
740
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
826
|
-
...stylistic
|
|
741
|
+
...stylistic ? {
|
|
827
742
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
828
743
|
"jsonc/comma-dangle": ["error", "never"],
|
|
829
744
|
"jsonc/comma-style": ["error", "last"],
|
|
@@ -845,7 +760,37 @@ async function jsonc(options = {}) {
|
|
|
845
760
|
}
|
|
846
761
|
}];
|
|
847
762
|
}
|
|
848
|
-
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/constants.ts
|
|
765
|
+
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
766
|
+
const RemixPackages = [
|
|
767
|
+
"@remix-run/node",
|
|
768
|
+
"@remix-run/react",
|
|
769
|
+
"@remix-run/serve",
|
|
770
|
+
"@remix-run/dev"
|
|
771
|
+
];
|
|
772
|
+
const ReactRouterPackages = [
|
|
773
|
+
"@react-router/node",
|
|
774
|
+
"@react-router/react",
|
|
775
|
+
"@react-router/serve",
|
|
776
|
+
"@react-router/dev"
|
|
777
|
+
];
|
|
778
|
+
const NextJsPackages = ["next"];
|
|
779
|
+
const ReactNativePackages = ["react-native", "expo"];
|
|
780
|
+
const ReactPackages = [
|
|
781
|
+
...RemixPackages,
|
|
782
|
+
...ReactRouterPackages,
|
|
783
|
+
...NextJsPackages,
|
|
784
|
+
...ReactNativePackages,
|
|
785
|
+
"react"
|
|
786
|
+
];
|
|
787
|
+
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
788
|
+
const VuePackages = [
|
|
789
|
+
"vue",
|
|
790
|
+
"nuxt",
|
|
791
|
+
"vitepress",
|
|
792
|
+
"@slidev/cli"
|
|
793
|
+
];
|
|
849
794
|
//#endregion
|
|
850
795
|
//#region src/configs/jsx.ts
|
|
851
796
|
async function jsx(options = {}) {
|
|
@@ -889,11 +834,10 @@ async function jsx(options = {}) {
|
|
|
889
834
|
}
|
|
890
835
|
}];
|
|
891
836
|
}
|
|
892
|
-
|
|
893
837
|
//#endregion
|
|
894
838
|
//#region src/configs/markdown.ts
|
|
895
839
|
async function markdown(options = {}) {
|
|
896
|
-
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
|
|
840
|
+
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
897
841
|
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
898
842
|
return [
|
|
899
843
|
{
|
|
@@ -908,15 +852,41 @@ async function markdown(options = {}) {
|
|
|
908
852
|
},
|
|
909
853
|
{
|
|
910
854
|
files,
|
|
911
|
-
|
|
855
|
+
language: gfm ? "markdown/gfm" : "markdown/commonmark",
|
|
912
856
|
name: "markdown/parser"
|
|
913
857
|
},
|
|
858
|
+
{
|
|
859
|
+
files,
|
|
860
|
+
name: "markdown/rules",
|
|
861
|
+
rules: {
|
|
862
|
+
...markdown.configs.recommended.at(0)?.rules,
|
|
863
|
+
"markdown/fenced-code-language": "off",
|
|
864
|
+
"markdown/no-missing-label-refs": "off",
|
|
865
|
+
...overridesMarkdown
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
files,
|
|
870
|
+
name: "markdown/disables/markdown",
|
|
871
|
+
rules: {
|
|
872
|
+
"command/command": "off",
|
|
873
|
+
"no-irregular-whitespace": "off",
|
|
874
|
+
"perfectionist/sort-exports": "off",
|
|
875
|
+
"perfectionist/sort-imports": "off",
|
|
876
|
+
"regexp/no-legacy-features": "off",
|
|
877
|
+
"regexp/no-missing-g-flag": "off",
|
|
878
|
+
"regexp/no-useless-dollar-replacements": "off",
|
|
879
|
+
"regexp/no-useless-flag": "off",
|
|
880
|
+
"style/indent": "off"
|
|
881
|
+
}
|
|
882
|
+
},
|
|
914
883
|
{
|
|
915
884
|
files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
|
|
916
885
|
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
917
|
-
name: "markdown/disables",
|
|
886
|
+
name: "markdown/disables/code",
|
|
918
887
|
rules: {
|
|
919
888
|
"antfu/no-top-level-await": "off",
|
|
889
|
+
"e18e/prefer-static-regex": "off",
|
|
920
890
|
"no-alert": "off",
|
|
921
891
|
"no-console": "off",
|
|
922
892
|
"no-labels": "off",
|
|
@@ -946,7 +916,6 @@ async function markdown(options = {}) {
|
|
|
946
916
|
}
|
|
947
917
|
];
|
|
948
918
|
}
|
|
949
|
-
|
|
950
919
|
//#endregion
|
|
951
920
|
//#region src/configs/nextjs.ts
|
|
952
921
|
async function nextjs(options = {}) {
|
|
@@ -989,13 +958,15 @@ async function nextjs(options = {}) {
|
|
|
989
958
|
settings: { react: { version: "detect" } }
|
|
990
959
|
}];
|
|
991
960
|
}
|
|
992
|
-
|
|
993
961
|
//#endregion
|
|
994
962
|
//#region src/configs/node.ts
|
|
995
963
|
async function node() {
|
|
996
964
|
return [{
|
|
965
|
+
name: "node/setup",
|
|
966
|
+
plugins: { node: pluginNode }
|
|
967
|
+
}, {
|
|
968
|
+
files: [GLOB_SRC],
|
|
997
969
|
name: "node/rules",
|
|
998
|
-
plugins: { node: pluginNode },
|
|
999
970
|
rules: {
|
|
1000
971
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1001
972
|
"node/no-deprecated-api": "error",
|
|
@@ -1008,7 +979,6 @@ async function node() {
|
|
|
1008
979
|
}
|
|
1009
980
|
}];
|
|
1010
981
|
}
|
|
1011
|
-
|
|
1012
982
|
//#endregion
|
|
1013
983
|
//#region src/configs/perfectionist.ts
|
|
1014
984
|
/**
|
|
@@ -1062,27 +1032,25 @@ async function perfectionist() {
|
|
|
1062
1032
|
}
|
|
1063
1033
|
}];
|
|
1064
1034
|
}
|
|
1065
|
-
|
|
1066
1035
|
//#endregion
|
|
1067
1036
|
//#region src/configs/pnpm.ts
|
|
1068
1037
|
async function detectCatalogUsage() {
|
|
1069
1038
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1070
1039
|
if (!workspaceFile) return false;
|
|
1071
|
-
const yaml
|
|
1072
|
-
return yaml
|
|
1040
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1041
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1073
1042
|
}
|
|
1074
1043
|
async function pnpm(options) {
|
|
1075
|
-
const [pluginPnpm, pluginYaml, yamlParser
|
|
1044
|
+
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
1076
1045
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1077
1046
|
interopDefault(import("eslint-plugin-yml")),
|
|
1078
|
-
interopDefault(import("yaml-eslint-parser"))
|
|
1079
|
-
interopDefault(import("jsonc-eslint-parser"))
|
|
1047
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1080
1048
|
]);
|
|
1081
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1082
|
-
const configs
|
|
1083
|
-
if (json) configs
|
|
1049
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1050
|
+
const configs = [];
|
|
1051
|
+
if (json) configs.push({
|
|
1084
1052
|
files: ["package.json", "**/package.json"],
|
|
1085
|
-
|
|
1053
|
+
language: "jsonc/x",
|
|
1086
1054
|
name: "pnpm/package-json",
|
|
1087
1055
|
plugins: { pnpm: pluginPnpm },
|
|
1088
1056
|
rules: {
|
|
@@ -1094,8 +1062,8 @@ async function pnpm(options) {
|
|
|
1094
1062
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1095
1063
|
}
|
|
1096
1064
|
});
|
|
1097
|
-
if (yaml
|
|
1098
|
-
configs
|
|
1065
|
+
if (yaml) {
|
|
1066
|
+
configs.push({
|
|
1099
1067
|
files: ["pnpm-workspace.yaml"],
|
|
1100
1068
|
languageOptions: { parser: yamlParser },
|
|
1101
1069
|
name: "pnpm/pnpm-workspace-yaml",
|
|
@@ -1109,7 +1077,7 @@ async function pnpm(options) {
|
|
|
1109
1077
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1110
1078
|
}
|
|
1111
1079
|
});
|
|
1112
|
-
if (sort) configs
|
|
1080
|
+
if (sort) configs.push({
|
|
1113
1081
|
files: ["pnpm-workspace.yaml"],
|
|
1114
1082
|
languageOptions: { parser: yamlParser },
|
|
1115
1083
|
name: "pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1188,9 +1156,8 @@ async function pnpm(options) {
|
|
|
1188
1156
|
] }
|
|
1189
1157
|
});
|
|
1190
1158
|
}
|
|
1191
|
-
return configs
|
|
1159
|
+
return configs;
|
|
1192
1160
|
}
|
|
1193
|
-
|
|
1194
1161
|
//#endregion
|
|
1195
1162
|
//#region src/configs/react.ts
|
|
1196
1163
|
async function react(options = {}) {
|
|
@@ -1201,7 +1168,10 @@ async function react(options = {}) {
|
|
|
1201
1168
|
"eslint-plugin-react-refresh"
|
|
1202
1169
|
]);
|
|
1203
1170
|
const isTypeAware = !!tsconfigPath;
|
|
1204
|
-
const typeAwareRules = {
|
|
1171
|
+
const typeAwareRules = {
|
|
1172
|
+
"react/no-leaked-conditional-rendering": "warn",
|
|
1173
|
+
"react/no-implicit-key": "error"
|
|
1174
|
+
};
|
|
1205
1175
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1206
1176
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1207
1177
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
@@ -1222,6 +1192,7 @@ async function react(options = {}) {
|
|
|
1222
1192
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1223
1193
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1224
1194
|
"react-refresh": pluginReactRefresh,
|
|
1195
|
+
"react-rsc": plugins["@eslint-react/rsc"],
|
|
1225
1196
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1226
1197
|
}
|
|
1227
1198
|
},
|
|
@@ -1253,9 +1224,7 @@ async function react(options = {}) {
|
|
|
1253
1224
|
"react/no-create-ref": "error",
|
|
1254
1225
|
"react/no-default-props": "error",
|
|
1255
1226
|
"react/no-direct-mutation-state": "error",
|
|
1256
|
-
"react/no-duplicate-key": "error",
|
|
1257
1227
|
"react/no-forward-ref": "warn",
|
|
1258
|
-
"react/no-implicit-key": "warn",
|
|
1259
1228
|
"react/no-missing-key": "error",
|
|
1260
1229
|
"react/no-nested-component-definitions": "error",
|
|
1261
1230
|
"react/no-nested-lazy-component-declarations": "error",
|
|
@@ -1269,6 +1238,7 @@ async function react(options = {}) {
|
|
|
1269
1238
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1270
1239
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1271
1240
|
"react/no-unsafe-component-will-update": "warn",
|
|
1241
|
+
"react/no-unused-class-component-members": "warn",
|
|
1272
1242
|
"react/no-use-context": "warn",
|
|
1273
1243
|
"react/no-useless-forward-ref": "warn",
|
|
1274
1244
|
"react/prefer-use-state-lazy-initialization": "warn",
|
|
@@ -1277,6 +1247,7 @@ async function react(options = {}) {
|
|
|
1277
1247
|
"react/prefer-destructuring-assignment": "warn",
|
|
1278
1248
|
"react/no-missing-context-display-name": "warn",
|
|
1279
1249
|
"react/no-missing-component-display-name": "warn",
|
|
1250
|
+
"react-rsc/function-definition": "error",
|
|
1280
1251
|
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1281
1252
|
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1282
1253
|
"react-dom/no-find-dom-node": "error",
|
|
@@ -1289,6 +1260,14 @@ async function react(options = {}) {
|
|
|
1289
1260
|
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1290
1261
|
"react-dom/no-use-form-state": "error",
|
|
1291
1262
|
"react-dom/no-void-elements-with-children": "error",
|
|
1263
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1264
|
+
"react-naming-convention/context-name": "warn",
|
|
1265
|
+
"react-naming-convention/ref-name": "warn",
|
|
1266
|
+
"react-naming-convention/use-state": "warn",
|
|
1267
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1268
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1269
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1270
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1292
1271
|
"react-hooks/rules-of-hooks": "error",
|
|
1293
1272
|
"react-hooks/exhaustive-deps": "warn",
|
|
1294
1273
|
...reactCompiler ? {
|
|
@@ -1308,14 +1287,7 @@ async function react(options = {}) {
|
|
|
1308
1287
|
"react-hooks/use-memo": "error",
|
|
1309
1288
|
"react-hooks/incompatible-library": "warn"
|
|
1310
1289
|
} : {},
|
|
1311
|
-
"react-
|
|
1312
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1313
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1314
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1315
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1316
|
-
"react-naming-convention/context-name": "warn",
|
|
1317
|
-
"react-naming-convention/use-state": "warn",
|
|
1318
|
-
"react-refresh/only-export-components": ["warn", {
|
|
1290
|
+
"react-refresh/only-export-components": ["error", {
|
|
1319
1291
|
allowConstantExport: isAllowConstantExport,
|
|
1320
1292
|
allowExportNames: [...isUsingNext ? [
|
|
1321
1293
|
"dynamic",
|
|
@@ -1325,12 +1297,13 @@ async function react(options = {}) {
|
|
|
1325
1297
|
"runtime",
|
|
1326
1298
|
"preferredRegion",
|
|
1327
1299
|
"maxDuration",
|
|
1328
|
-
"config",
|
|
1329
1300
|
"generateStaticParams",
|
|
1330
1301
|
"metadata",
|
|
1331
1302
|
"generateMetadata",
|
|
1332
1303
|
"viewport",
|
|
1333
|
-
"generateViewport"
|
|
1304
|
+
"generateViewport",
|
|
1305
|
+
"generateImageMetadata",
|
|
1306
|
+
"generateSitemaps"
|
|
1334
1307
|
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1335
1308
|
"meta",
|
|
1336
1309
|
"links",
|
|
@@ -1346,6 +1319,18 @@ async function react(options = {}) {
|
|
|
1346
1319
|
...overrides
|
|
1347
1320
|
}
|
|
1348
1321
|
},
|
|
1322
|
+
{
|
|
1323
|
+
files: filesTypeAware,
|
|
1324
|
+
name: "react/typescript",
|
|
1325
|
+
rules: {
|
|
1326
|
+
"react-dom/no-string-style-prop": "off",
|
|
1327
|
+
"react-dom/no-unknown-property": "off",
|
|
1328
|
+
"react/jsx-no-duplicate-props": "off",
|
|
1329
|
+
"react/jsx-no-undef": "off",
|
|
1330
|
+
"react/jsx-uses-react": "off",
|
|
1331
|
+
"react/jsx-uses-vars": "off"
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1349
1334
|
...isTypeAware ? [{
|
|
1350
1335
|
files: filesTypeAware,
|
|
1351
1336
|
ignores: ignoresTypeAware,
|
|
@@ -1354,7 +1339,6 @@ async function react(options = {}) {
|
|
|
1354
1339
|
}] : []
|
|
1355
1340
|
];
|
|
1356
1341
|
}
|
|
1357
|
-
|
|
1358
1342
|
//#endregion
|
|
1359
1343
|
//#region src/configs/react-native.ts
|
|
1360
1344
|
async function reactNative(options = {}) {
|
|
@@ -1409,7 +1393,7 @@ async function reactNative(options = {}) {
|
|
|
1409
1393
|
"react-native-community/no-single-element-style-arrays": "warn",
|
|
1410
1394
|
"react-native-community/no-unused-styles": "warn",
|
|
1411
1395
|
"react-native/no-deep-imports": "error",
|
|
1412
|
-
"ts/no-require-imports": "
|
|
1396
|
+
"ts/no-require-imports": ["warn", { allow: ["\\.(aac|aiff|avif|bmp|caf|db|gif|heic|html|jpeg|jpg|json|m4a|m4v|mov|mp3|mp4|mpeg|mpg|otf|pdf|png|psd|svg|ttf|wav|webm|webp|xml|yaml|yml|zip)$"] }],
|
|
1413
1397
|
...expo ? {
|
|
1414
1398
|
"expo/no-dynamic-env-var": "error",
|
|
1415
1399
|
"expo/no-env-var-destructuring": "error",
|
|
@@ -1420,17 +1404,16 @@ async function reactNative(options = {}) {
|
|
|
1420
1404
|
settings: { react: { version: "detect" } }
|
|
1421
1405
|
}];
|
|
1422
1406
|
}
|
|
1423
|
-
|
|
1424
1407
|
//#endregion
|
|
1425
1408
|
//#region src/configs/regexp.ts
|
|
1426
1409
|
async function regexp(options = {}) {
|
|
1427
|
-
const config
|
|
1428
|
-
const rules = { ...config
|
|
1410
|
+
const config = configs["flat/recommended"];
|
|
1411
|
+
const rules = { ...config.rules };
|
|
1429
1412
|
if (options.level === "warn") {
|
|
1430
1413
|
for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
|
|
1431
1414
|
}
|
|
1432
1415
|
return [{
|
|
1433
|
-
...config
|
|
1416
|
+
...config,
|
|
1434
1417
|
name: "regexp/rules",
|
|
1435
1418
|
rules: {
|
|
1436
1419
|
...rules,
|
|
@@ -1438,7 +1421,6 @@ async function regexp(options = {}) {
|
|
|
1438
1421
|
}
|
|
1439
1422
|
}];
|
|
1440
1423
|
}
|
|
1441
|
-
|
|
1442
1424
|
//#endregion
|
|
1443
1425
|
//#region src/configs/sort.ts
|
|
1444
1426
|
/**
|
|
@@ -1672,19 +1654,18 @@ function sortTsconfig() {
|
|
|
1672
1654
|
] }
|
|
1673
1655
|
}];
|
|
1674
1656
|
}
|
|
1675
|
-
|
|
1676
1657
|
//#endregion
|
|
1677
1658
|
//#region src/configs/tailwindcss.ts
|
|
1678
1659
|
async function tailwindcss(options = {}) {
|
|
1679
|
-
const { entryPoint, overrides = {}, stylistic
|
|
1660
|
+
const { entryPoint, overrides = {}, stylistic = true, tsconfigPath } = options;
|
|
1680
1661
|
await ensurePackages(["eslint-plugin-better-tailwindcss"]);
|
|
1681
1662
|
const [pluginTailwindCSS] = await Promise.all([interopDefault(import("eslint-plugin-better-tailwindcss"))]);
|
|
1682
|
-
const { indent = 2 } = typeof stylistic
|
|
1663
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1683
1664
|
return [{
|
|
1684
1665
|
name: "tailwindcss",
|
|
1685
1666
|
plugins: { tailwindcss: pluginTailwindCSS },
|
|
1686
1667
|
rules: {
|
|
1687
|
-
...stylistic
|
|
1668
|
+
...stylistic ? {
|
|
1688
1669
|
"tailwindcss/enforce-canonical-classes": "warn",
|
|
1689
1670
|
"tailwindcss/enforce-consistent-class-order": "warn",
|
|
1690
1671
|
"tailwindcss/enforce-consistent-line-wrapping": ["warn", { indent: typeof indent === "number" ? indent : indent === "tab" ? "tab" : 2 }],
|
|
@@ -1702,7 +1683,6 @@ async function tailwindcss(options = {}) {
|
|
|
1702
1683
|
} }
|
|
1703
1684
|
}];
|
|
1704
1685
|
}
|
|
1705
|
-
|
|
1706
1686
|
//#endregion
|
|
1707
1687
|
//#region src/configs/test.ts
|
|
1708
1688
|
let _pluginTest;
|
|
@@ -1733,6 +1713,7 @@ async function test(options = {}) {
|
|
|
1733
1713
|
"test/prefer-hooks-in-order": "error",
|
|
1734
1714
|
"test/prefer-lowercase-title": "error",
|
|
1735
1715
|
"antfu/no-top-level-await": "off",
|
|
1716
|
+
"e18e/prefer-static-regex": "off",
|
|
1736
1717
|
"no-unused-expressions": "off",
|
|
1737
1718
|
"node/prefer-global/process": "off",
|
|
1738
1719
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1740,12 +1721,11 @@ async function test(options = {}) {
|
|
|
1740
1721
|
}
|
|
1741
1722
|
}];
|
|
1742
1723
|
}
|
|
1743
|
-
|
|
1744
1724
|
//#endregion
|
|
1745
1725
|
//#region src/configs/toml.ts
|
|
1746
1726
|
async function toml(options = {}) {
|
|
1747
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1748
|
-
const { indent = 2 } = typeof stylistic
|
|
1727
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1728
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1749
1729
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1750
1730
|
return [{
|
|
1751
1731
|
name: "toml/setup",
|
|
@@ -1764,7 +1744,7 @@ async function toml(options = {}) {
|
|
|
1764
1744
|
"toml/precision-of-integer": "error",
|
|
1765
1745
|
"toml/tables-order": "error",
|
|
1766
1746
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1767
|
-
...stylistic
|
|
1747
|
+
...stylistic ? {
|
|
1768
1748
|
"toml/array-bracket-newline": "error",
|
|
1769
1749
|
"toml/array-bracket-spacing": "error",
|
|
1770
1750
|
"toml/array-element-newline": "error",
|
|
@@ -1781,18 +1761,17 @@ async function toml(options = {}) {
|
|
|
1781
1761
|
}
|
|
1782
1762
|
}];
|
|
1783
1763
|
}
|
|
1784
|
-
|
|
1785
1764
|
//#endregion
|
|
1786
1765
|
//#region src/configs/typescript.ts
|
|
1787
1766
|
async function typescript(options = {}) {
|
|
1788
1767
|
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
1789
1768
|
const files = options.files ?? [
|
|
1790
|
-
|
|
1791
|
-
|
|
1769
|
+
"**/*.?([cm])ts",
|
|
1770
|
+
"**/*.?([cm])tsx",
|
|
1792
1771
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1793
1772
|
];
|
|
1794
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
1795
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1773
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
1774
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`];
|
|
1796
1775
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1797
1776
|
const isTypeAware = !!tsconfigPath;
|
|
1798
1777
|
const typeAwareRules = {
|
|
@@ -1822,10 +1801,10 @@ async function typescript(options = {}) {
|
|
|
1822
1801
|
"ts/unbound-method": "error"
|
|
1823
1802
|
};
|
|
1824
1803
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1825
|
-
function makeParser(typeAware, files
|
|
1804
|
+
function makeParser(typeAware, files, ignores) {
|
|
1826
1805
|
return {
|
|
1827
|
-
files
|
|
1828
|
-
...ignores
|
|
1806
|
+
files,
|
|
1807
|
+
...ignores ? { ignores } : {},
|
|
1829
1808
|
languageOptions: {
|
|
1830
1809
|
parser: parserTs,
|
|
1831
1810
|
parserOptions: {
|
|
@@ -1915,7 +1894,7 @@ async function typescript(options = {}) {
|
|
|
1915
1894
|
}] : [],
|
|
1916
1895
|
...erasableOnly ? [{
|
|
1917
1896
|
name: "antfu/typescript/erasable-syntax-only",
|
|
1918
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
1897
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-C63e_zBF.mjs")) },
|
|
1919
1898
|
rules: {
|
|
1920
1899
|
"erasable-syntax-only/enums": "error",
|
|
1921
1900
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -1925,7 +1904,6 @@ async function typescript(options = {}) {
|
|
|
1925
1904
|
}] : []
|
|
1926
1905
|
];
|
|
1927
1906
|
}
|
|
1928
|
-
|
|
1929
1907
|
//#endregion
|
|
1930
1908
|
//#region src/configs/unicorn.ts
|
|
1931
1909
|
async function unicorn(options = {}) {
|
|
@@ -1955,7 +1933,6 @@ async function unicorn(options = {}) {
|
|
|
1955
1933
|
}
|
|
1956
1934
|
}];
|
|
1957
1935
|
}
|
|
1958
|
-
|
|
1959
1936
|
//#endregion
|
|
1960
1937
|
//#region src/configs/unocss.ts
|
|
1961
1938
|
async function unocss(options = {}) {
|
|
@@ -1973,13 +1950,12 @@ async function unocss(options = {}) {
|
|
|
1973
1950
|
}
|
|
1974
1951
|
}];
|
|
1975
1952
|
}
|
|
1976
|
-
|
|
1977
1953
|
//#endregion
|
|
1978
1954
|
//#region src/configs/vue.ts
|
|
1979
1955
|
async function vue(options = {}) {
|
|
1980
|
-
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic
|
|
1956
|
+
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic = true, vueVersion = 3 } = options;
|
|
1981
1957
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1982
|
-
const { indent = 2 } = typeof stylistic
|
|
1958
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1983
1959
|
await ensurePackages([
|
|
1984
1960
|
"eslint-plugin-vue",
|
|
1985
1961
|
"vue-eslint-parser",
|
|
@@ -2112,7 +2088,7 @@ async function vue(options = {}) {
|
|
|
2112
2088
|
nonwords: false,
|
|
2113
2089
|
words: true
|
|
2114
2090
|
}],
|
|
2115
|
-
...stylistic
|
|
2091
|
+
...stylistic ? {
|
|
2116
2092
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2117
2093
|
"vue/arrow-spacing": ["error", {
|
|
2118
2094
|
after: true,
|
|
@@ -2184,12 +2160,11 @@ async function vue(options = {}) {
|
|
|
2184
2160
|
}
|
|
2185
2161
|
}];
|
|
2186
2162
|
}
|
|
2187
|
-
|
|
2188
2163
|
//#endregion
|
|
2189
2164
|
//#region src/configs/yaml.ts
|
|
2190
2165
|
async function yaml(options = {}) {
|
|
2191
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2192
|
-
const { indent = 2, quotes = "single" } = typeof stylistic
|
|
2166
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2167
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2193
2168
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2194
2169
|
return [{
|
|
2195
2170
|
name: "yaml/setup",
|
|
@@ -2207,7 +2182,7 @@ async function yaml(options = {}) {
|
|
|
2207
2182
|
"yaml/no-irregular-whitespace": "error",
|
|
2208
2183
|
"yaml/plain-scalar": "error",
|
|
2209
2184
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2210
|
-
...stylistic
|
|
2185
|
+
...stylistic ? {
|
|
2211
2186
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2212
2187
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2213
2188
|
"yaml/flow-mapping-curly-newline": "error",
|
|
@@ -2227,7 +2202,22 @@ async function yaml(options = {}) {
|
|
|
2227
2202
|
}
|
|
2228
2203
|
}];
|
|
2229
2204
|
}
|
|
2230
|
-
|
|
2205
|
+
//#endregion
|
|
2206
|
+
//#region src/configs/e18e.ts
|
|
2207
|
+
async function e18e(options = {}) {
|
|
2208
|
+
const { isInEditor = false, modernization = true, type = "app", moduleReplacements = type === "lib" && isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
2209
|
+
const configs = pluginE18e.configs;
|
|
2210
|
+
return [{
|
|
2211
|
+
name: "antfu/e18e/rules",
|
|
2212
|
+
plugins: { e18e: pluginE18e },
|
|
2213
|
+
rules: {
|
|
2214
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
2215
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
2216
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
2217
|
+
...overrides
|
|
2218
|
+
}
|
|
2219
|
+
}];
|
|
2220
|
+
}
|
|
2231
2221
|
//#endregion
|
|
2232
2222
|
//#region src/factory.ts
|
|
2233
2223
|
const flatConfigProps = [
|
|
@@ -2264,7 +2254,7 @@ const defaultPluginRenaming = {
|
|
|
2264
2254
|
* The merged ESLint configurations.
|
|
2265
2255
|
*/
|
|
2266
2256
|
function config(options = {}, ...userConfigs) {
|
|
2267
|
-
const { autoRenamePlugins = true, componentExts = [],
|
|
2257
|
+
const { autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNext = NextJsPackages.some((i) => isPackageExists(i)), node: enableNode = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = ReactPackages.some((i) => isPackageExists(i)), reactNative: enableReactNative = ReactNativePackages.some((i) => isPackageExists(i)), regexp: enableRegexp = true, tailwindcss: enableTailwindCSS = isPackageExists("tailwindcss"), type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = isPackageExists("unocss"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2268
2258
|
let isInEditor = options.isInEditor;
|
|
2269
2259
|
if (isInEditor == null) {
|
|
2270
2260
|
isInEditor = isInEditorEnv();
|
|
@@ -2272,111 +2262,111 @@ function config(options = {}, ...userConfigs) {
|
|
|
2272
2262
|
}
|
|
2273
2263
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2274
2264
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = typeof enableJsx === "object" ? true : enableJsx;
|
|
2275
|
-
const configs
|
|
2276
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
2265
|
+
const configs = [];
|
|
2266
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2277
2267
|
name: "gitignore",
|
|
2278
2268
|
...enableGitignore
|
|
2279
2269
|
})]));
|
|
2280
|
-
else configs
|
|
2270
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2281
2271
|
name: "gitignore",
|
|
2282
2272
|
strict: false
|
|
2283
2273
|
})]));
|
|
2284
2274
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2285
2275
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2286
|
-
configs
|
|
2276
|
+
configs.push(ignores(userIgnores, !enableTypeScript), javascript({
|
|
2287
2277
|
isInEditor,
|
|
2288
2278
|
overrides: getOverrides(options, "javascript")
|
|
2289
2279
|
}), comments(), command(), perfectionist());
|
|
2290
|
-
if (enableNode) configs
|
|
2291
|
-
if (enableJsdoc) configs
|
|
2292
|
-
if (enableImports) configs
|
|
2280
|
+
if (enableNode) configs.push(node());
|
|
2281
|
+
if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2282
|
+
if (enableImports) configs.push(imports({
|
|
2293
2283
|
stylistic: stylisticOptions,
|
|
2294
2284
|
...resolveSubOptions(options, "imports")
|
|
2295
2285
|
}));
|
|
2296
|
-
if (
|
|
2286
|
+
if (enableE18e) configs.push(e18e({
|
|
2287
|
+
isInEditor,
|
|
2288
|
+
...enableE18e === true ? {} : enableE18e
|
|
2289
|
+
}));
|
|
2290
|
+
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2297
2291
|
if (enableVue) componentExts.push("vue");
|
|
2298
|
-
if (enableJsx) configs
|
|
2299
|
-
if (enableTypeScript) configs
|
|
2292
|
+
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
2293
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2300
2294
|
...typescriptOptions,
|
|
2301
2295
|
componentExts,
|
|
2302
2296
|
overrides: getOverrides(options, "typescript"),
|
|
2303
|
-
type:
|
|
2297
|
+
type: appType
|
|
2304
2298
|
}));
|
|
2305
|
-
if (stylisticOptions) configs
|
|
2299
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2306
2300
|
...stylisticOptions,
|
|
2307
2301
|
overrides: getOverrides(options, "stylistic")
|
|
2308
2302
|
}));
|
|
2309
|
-
if (enableRegexp) configs
|
|
2310
|
-
if (options.test ?? true) configs
|
|
2303
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2304
|
+
if (options.test ?? true) configs.push(test({
|
|
2311
2305
|
isInEditor,
|
|
2312
2306
|
overrides: getOverrides(options, "test")
|
|
2313
2307
|
}));
|
|
2314
|
-
if (enableVue) configs
|
|
2308
|
+
if (enableVue) configs.push(vue({
|
|
2315
2309
|
...resolveSubOptions(options, "vue"),
|
|
2316
2310
|
overrides: getOverrides(options, "vue"),
|
|
2317
2311
|
stylistic: stylisticOptions,
|
|
2318
2312
|
typescript: !!enableTypeScript
|
|
2319
2313
|
}));
|
|
2320
|
-
if (enableReact) configs
|
|
2314
|
+
if (enableReact) configs.push(react({
|
|
2321
2315
|
...typescriptOptions,
|
|
2322
2316
|
...resolveSubOptions(options, "react"),
|
|
2323
2317
|
overrides: getOverrides(options, "react"),
|
|
2324
2318
|
tsconfigPath
|
|
2325
2319
|
}));
|
|
2326
|
-
if (enableReactNative) configs
|
|
2320
|
+
if (enableReactNative) configs.push(reactNative({
|
|
2327
2321
|
...resolveSubOptions(options, "reactNative"),
|
|
2328
2322
|
overrides: getOverrides(options, "reactNative")
|
|
2329
2323
|
}));
|
|
2330
|
-
if (enableNext) configs
|
|
2331
|
-
if (
|
|
2332
|
-
...resolveSubOptions(options, "effector"),
|
|
2333
|
-
overrides: getOverrides(options, "effector")
|
|
2334
|
-
}));
|
|
2335
|
-
if (enableUnoCSS) configs$1.push(unocss({
|
|
2324
|
+
if (enableNext) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2325
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2336
2326
|
...resolveSubOptions(options, "unocss"),
|
|
2337
2327
|
overrides: getOverrides(options, "unocss")
|
|
2338
2328
|
}));
|
|
2339
|
-
if (enableTailwindCSS) configs
|
|
2329
|
+
if (enableTailwindCSS) configs.push(tailwindcss({
|
|
2340
2330
|
...typescriptOptions,
|
|
2341
2331
|
...resolveSubOptions(options, "tailwindcss"),
|
|
2342
2332
|
overrides: getOverrides(options, "tailwindcss"),
|
|
2343
2333
|
stylistic: stylisticOptions
|
|
2344
2334
|
}));
|
|
2345
|
-
if (options.jsonc ?? true) configs
|
|
2335
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2346
2336
|
overrides: getOverrides(options, "jsonc"),
|
|
2347
2337
|
stylistic: stylisticOptions
|
|
2348
2338
|
}), sortPackageJson(), sortTsconfig());
|
|
2349
2339
|
if (enableCatalogs) {
|
|
2350
2340
|
const optionsPnpm = resolveSubOptions(options, "pnpm");
|
|
2351
|
-
configs
|
|
2341
|
+
configs.push(pnpm({
|
|
2352
2342
|
isInEditor,
|
|
2353
2343
|
json: options.jsonc !== false,
|
|
2354
2344
|
yaml: options.yaml !== false,
|
|
2355
2345
|
...optionsPnpm
|
|
2356
2346
|
}));
|
|
2357
2347
|
}
|
|
2358
|
-
if (options.yaml ?? true) configs
|
|
2348
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2359
2349
|
overrides: getOverrides(options, "yaml"),
|
|
2360
2350
|
stylistic: stylisticOptions
|
|
2361
2351
|
}));
|
|
2362
|
-
if (options.toml ?? true) configs
|
|
2352
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2363
2353
|
overrides: getOverrides(options, "toml"),
|
|
2364
2354
|
stylistic: stylisticOptions
|
|
2365
2355
|
}));
|
|
2366
|
-
if (options.markdown ?? true) configs
|
|
2356
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2367
2357
|
componentExts,
|
|
2368
2358
|
overrides: getOverrides(options, "markdown")
|
|
2369
2359
|
}));
|
|
2370
|
-
if (options.formatters) configs
|
|
2371
|
-
configs
|
|
2360
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2361
|
+
configs.push(disables());
|
|
2372
2362
|
if ("files" in options) throw new Error("[@ghettoddos/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
2373
2363
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2374
2364
|
if (key in options) acc[key] = options[key];
|
|
2375
2365
|
return acc;
|
|
2376
2366
|
}, {});
|
|
2377
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2367
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2378
2368
|
let composer = new FlatConfigComposer();
|
|
2379
|
-
composer = composer.append(...configs
|
|
2369
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2380
2370
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2381
2371
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2382
2372
|
"unused-imports/no-unused-imports",
|
|
@@ -2385,16 +2375,9 @@ function config(options = {}, ...userConfigs) {
|
|
|
2385
2375
|
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
2386
2376
|
return composer;
|
|
2387
2377
|
}
|
|
2388
|
-
|
|
2389
2378
|
//#endregion
|
|
2390
2379
|
//#region src/config-presets.ts
|
|
2391
2380
|
const CONFIG_PRESET_FULL_ON = {
|
|
2392
|
-
effector: {
|
|
2393
|
-
future: true,
|
|
2394
|
-
patronum: true,
|
|
2395
|
-
react: true,
|
|
2396
|
-
scope: true
|
|
2397
|
-
},
|
|
2398
2381
|
formatters: true,
|
|
2399
2382
|
gitignore: true,
|
|
2400
2383
|
imports: true,
|
|
@@ -2422,7 +2405,6 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2422
2405
|
yaml: true
|
|
2423
2406
|
};
|
|
2424
2407
|
const CONFIG_PRESET_FULL_OFF = {
|
|
2425
|
-
effector: false,
|
|
2426
2408
|
formatters: false,
|
|
2427
2409
|
gitignore: false,
|
|
2428
2410
|
imports: false,
|
|
@@ -2446,10 +2428,8 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2446
2428
|
vue: false,
|
|
2447
2429
|
yaml: false
|
|
2448
2430
|
};
|
|
2449
|
-
|
|
2450
2431
|
//#endregion
|
|
2451
2432
|
//#region src/index.ts
|
|
2452
2433
|
var src_default = config;
|
|
2453
|
-
|
|
2454
2434
|
//#endregion
|
|
2455
|
-
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, 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, command, comments, config, src_default as default, defaultPluginRenaming, disables,
|
|
2435
|
+
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, 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, command, comments, config, src_default as default, defaultPluginRenaming, disables, 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, tailwindcss, test, toml, typescript, unicorn, unocss, vue, yaml };
|