@ghettoddos/eslint-config 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/index.d.mts +6301 -5395
- package/dist/index.mjs +213 -235
- package/dist/{lib-D6spnV0Z.mjs → lib-C63e_zBF.mjs} +631 -892
- package/package.json +80 -59
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);
|
|
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,13 +852,38 @@ 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",
|
|
920
889
|
"no-alert": "off",
|
|
@@ -946,7 +915,6 @@ async function markdown(options = {}) {
|
|
|
946
915
|
}
|
|
947
916
|
];
|
|
948
917
|
}
|
|
949
|
-
|
|
950
918
|
//#endregion
|
|
951
919
|
//#region src/configs/nextjs.ts
|
|
952
920
|
async function nextjs(options = {}) {
|
|
@@ -989,13 +957,15 @@ async function nextjs(options = {}) {
|
|
|
989
957
|
settings: { react: { version: "detect" } }
|
|
990
958
|
}];
|
|
991
959
|
}
|
|
992
|
-
|
|
993
960
|
//#endregion
|
|
994
961
|
//#region src/configs/node.ts
|
|
995
962
|
async function node() {
|
|
996
963
|
return [{
|
|
964
|
+
name: "node/setup",
|
|
965
|
+
plugins: { node: pluginNode }
|
|
966
|
+
}, {
|
|
967
|
+
files: [GLOB_SRC],
|
|
997
968
|
name: "node/rules",
|
|
998
|
-
plugins: { node: pluginNode },
|
|
999
969
|
rules: {
|
|
1000
970
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1001
971
|
"node/no-deprecated-api": "error",
|
|
@@ -1008,7 +978,6 @@ async function node() {
|
|
|
1008
978
|
}
|
|
1009
979
|
}];
|
|
1010
980
|
}
|
|
1011
|
-
|
|
1012
981
|
//#endregion
|
|
1013
982
|
//#region src/configs/perfectionist.ts
|
|
1014
983
|
/**
|
|
@@ -1062,27 +1031,25 @@ async function perfectionist() {
|
|
|
1062
1031
|
}
|
|
1063
1032
|
}];
|
|
1064
1033
|
}
|
|
1065
|
-
|
|
1066
1034
|
//#endregion
|
|
1067
1035
|
//#region src/configs/pnpm.ts
|
|
1068
1036
|
async function detectCatalogUsage() {
|
|
1069
1037
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1070
1038
|
if (!workspaceFile) return false;
|
|
1071
|
-
const yaml
|
|
1072
|
-
return yaml
|
|
1039
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1040
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1073
1041
|
}
|
|
1074
1042
|
async function pnpm(options) {
|
|
1075
|
-
const [pluginPnpm, pluginYaml, yamlParser
|
|
1043
|
+
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
1076
1044
|
interopDefault(import("eslint-plugin-pnpm")),
|
|
1077
1045
|
interopDefault(import("eslint-plugin-yml")),
|
|
1078
|
-
interopDefault(import("yaml-eslint-parser"))
|
|
1079
|
-
interopDefault(import("jsonc-eslint-parser"))
|
|
1046
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1080
1047
|
]);
|
|
1081
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1082
|
-
const configs
|
|
1083
|
-
if (json) configs
|
|
1048
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1049
|
+
const configs = [];
|
|
1050
|
+
if (json) configs.push({
|
|
1084
1051
|
files: ["package.json", "**/package.json"],
|
|
1085
|
-
|
|
1052
|
+
language: "jsonc/x",
|
|
1086
1053
|
name: "pnpm/package-json",
|
|
1087
1054
|
plugins: { pnpm: pluginPnpm },
|
|
1088
1055
|
rules: {
|
|
@@ -1094,8 +1061,8 @@ async function pnpm(options) {
|
|
|
1094
1061
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1095
1062
|
}
|
|
1096
1063
|
});
|
|
1097
|
-
if (yaml
|
|
1098
|
-
configs
|
|
1064
|
+
if (yaml) {
|
|
1065
|
+
configs.push({
|
|
1099
1066
|
files: ["pnpm-workspace.yaml"],
|
|
1100
1067
|
languageOptions: { parser: yamlParser },
|
|
1101
1068
|
name: "pnpm/pnpm-workspace-yaml",
|
|
@@ -1109,7 +1076,7 @@ async function pnpm(options) {
|
|
|
1109
1076
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1110
1077
|
}
|
|
1111
1078
|
});
|
|
1112
|
-
if (sort) configs
|
|
1079
|
+
if (sort) configs.push({
|
|
1113
1080
|
files: ["pnpm-workspace.yaml"],
|
|
1114
1081
|
languageOptions: { parser: yamlParser },
|
|
1115
1082
|
name: "pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1188,9 +1155,8 @@ async function pnpm(options) {
|
|
|
1188
1155
|
] }
|
|
1189
1156
|
});
|
|
1190
1157
|
}
|
|
1191
|
-
return configs
|
|
1158
|
+
return configs;
|
|
1192
1159
|
}
|
|
1193
|
-
|
|
1194
1160
|
//#endregion
|
|
1195
1161
|
//#region src/configs/react.ts
|
|
1196
1162
|
async function react(options = {}) {
|
|
@@ -1201,7 +1167,10 @@ async function react(options = {}) {
|
|
|
1201
1167
|
"eslint-plugin-react-refresh"
|
|
1202
1168
|
]);
|
|
1203
1169
|
const isTypeAware = !!tsconfigPath;
|
|
1204
|
-
const typeAwareRules = {
|
|
1170
|
+
const typeAwareRules = {
|
|
1171
|
+
"react/no-leaked-conditional-rendering": "warn",
|
|
1172
|
+
"react/no-implicit-key": "error"
|
|
1173
|
+
};
|
|
1205
1174
|
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1206
1175
|
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1207
1176
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
@@ -1222,6 +1191,7 @@ async function react(options = {}) {
|
|
|
1222
1191
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1223
1192
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1224
1193
|
"react-refresh": pluginReactRefresh,
|
|
1194
|
+
"react-rsc": plugins["@eslint-react/rsc"],
|
|
1225
1195
|
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1226
1196
|
}
|
|
1227
1197
|
},
|
|
@@ -1253,9 +1223,7 @@ async function react(options = {}) {
|
|
|
1253
1223
|
"react/no-create-ref": "error",
|
|
1254
1224
|
"react/no-default-props": "error",
|
|
1255
1225
|
"react/no-direct-mutation-state": "error",
|
|
1256
|
-
"react/no-duplicate-key": "error",
|
|
1257
1226
|
"react/no-forward-ref": "warn",
|
|
1258
|
-
"react/no-implicit-key": "warn",
|
|
1259
1227
|
"react/no-missing-key": "error",
|
|
1260
1228
|
"react/no-nested-component-definitions": "error",
|
|
1261
1229
|
"react/no-nested-lazy-component-declarations": "error",
|
|
@@ -1269,6 +1237,7 @@ async function react(options = {}) {
|
|
|
1269
1237
|
"react/no-unsafe-component-will-mount": "warn",
|
|
1270
1238
|
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1271
1239
|
"react/no-unsafe-component-will-update": "warn",
|
|
1240
|
+
"react/no-unused-class-component-members": "warn",
|
|
1272
1241
|
"react/no-use-context": "warn",
|
|
1273
1242
|
"react/no-useless-forward-ref": "warn",
|
|
1274
1243
|
"react/prefer-use-state-lazy-initialization": "warn",
|
|
@@ -1277,6 +1246,7 @@ async function react(options = {}) {
|
|
|
1277
1246
|
"react/prefer-destructuring-assignment": "warn",
|
|
1278
1247
|
"react/no-missing-context-display-name": "warn",
|
|
1279
1248
|
"react/no-missing-component-display-name": "warn",
|
|
1249
|
+
"react-rsc/function-definition": "error",
|
|
1280
1250
|
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1281
1251
|
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1282
1252
|
"react-dom/no-find-dom-node": "error",
|
|
@@ -1289,6 +1259,14 @@ async function react(options = {}) {
|
|
|
1289
1259
|
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1290
1260
|
"react-dom/no-use-form-state": "error",
|
|
1291
1261
|
"react-dom/no-void-elements-with-children": "error",
|
|
1262
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1263
|
+
"react-naming-convention/context-name": "warn",
|
|
1264
|
+
"react-naming-convention/ref-name": "warn",
|
|
1265
|
+
"react-naming-convention/use-state": "warn",
|
|
1266
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1267
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1268
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1269
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1292
1270
|
"react-hooks/rules-of-hooks": "error",
|
|
1293
1271
|
"react-hooks/exhaustive-deps": "warn",
|
|
1294
1272
|
...reactCompiler ? {
|
|
@@ -1308,14 +1286,7 @@ async function react(options = {}) {
|
|
|
1308
1286
|
"react-hooks/use-memo": "error",
|
|
1309
1287
|
"react-hooks/incompatible-library": "warn"
|
|
1310
1288
|
} : {},
|
|
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", {
|
|
1289
|
+
"react-refresh/only-export-components": ["error", {
|
|
1319
1290
|
allowConstantExport: isAllowConstantExport,
|
|
1320
1291
|
allowExportNames: [...isUsingNext ? [
|
|
1321
1292
|
"dynamic",
|
|
@@ -1325,12 +1296,13 @@ async function react(options = {}) {
|
|
|
1325
1296
|
"runtime",
|
|
1326
1297
|
"preferredRegion",
|
|
1327
1298
|
"maxDuration",
|
|
1328
|
-
"config",
|
|
1329
1299
|
"generateStaticParams",
|
|
1330
1300
|
"metadata",
|
|
1331
1301
|
"generateMetadata",
|
|
1332
1302
|
"viewport",
|
|
1333
|
-
"generateViewport"
|
|
1303
|
+
"generateViewport",
|
|
1304
|
+
"generateImageMetadata",
|
|
1305
|
+
"generateSitemaps"
|
|
1334
1306
|
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1335
1307
|
"meta",
|
|
1336
1308
|
"links",
|
|
@@ -1346,6 +1318,18 @@ async function react(options = {}) {
|
|
|
1346
1318
|
...overrides
|
|
1347
1319
|
}
|
|
1348
1320
|
},
|
|
1321
|
+
{
|
|
1322
|
+
files: filesTypeAware,
|
|
1323
|
+
name: "react/typescript",
|
|
1324
|
+
rules: {
|
|
1325
|
+
"react-dom/no-string-style-prop": "off",
|
|
1326
|
+
"react-dom/no-unknown-property": "off",
|
|
1327
|
+
"react/jsx-no-duplicate-props": "off",
|
|
1328
|
+
"react/jsx-no-undef": "off",
|
|
1329
|
+
"react/jsx-uses-react": "off",
|
|
1330
|
+
"react/jsx-uses-vars": "off"
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1349
1333
|
...isTypeAware ? [{
|
|
1350
1334
|
files: filesTypeAware,
|
|
1351
1335
|
ignores: ignoresTypeAware,
|
|
@@ -1354,7 +1338,6 @@ async function react(options = {}) {
|
|
|
1354
1338
|
}] : []
|
|
1355
1339
|
];
|
|
1356
1340
|
}
|
|
1357
|
-
|
|
1358
1341
|
//#endregion
|
|
1359
1342
|
//#region src/configs/react-native.ts
|
|
1360
1343
|
async function reactNative(options = {}) {
|
|
@@ -1409,7 +1392,7 @@ async function reactNative(options = {}) {
|
|
|
1409
1392
|
"react-native-community/no-single-element-style-arrays": "warn",
|
|
1410
1393
|
"react-native-community/no-unused-styles": "warn",
|
|
1411
1394
|
"react-native/no-deep-imports": "error",
|
|
1412
|
-
"ts/no-require-imports": "
|
|
1395
|
+
"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
1396
|
...expo ? {
|
|
1414
1397
|
"expo/no-dynamic-env-var": "error",
|
|
1415
1398
|
"expo/no-env-var-destructuring": "error",
|
|
@@ -1420,17 +1403,16 @@ async function reactNative(options = {}) {
|
|
|
1420
1403
|
settings: { react: { version: "detect" } }
|
|
1421
1404
|
}];
|
|
1422
1405
|
}
|
|
1423
|
-
|
|
1424
1406
|
//#endregion
|
|
1425
1407
|
//#region src/configs/regexp.ts
|
|
1426
1408
|
async function regexp(options = {}) {
|
|
1427
|
-
const config
|
|
1428
|
-
const rules = { ...config
|
|
1409
|
+
const config = configs["flat/recommended"];
|
|
1410
|
+
const rules = { ...config.rules };
|
|
1429
1411
|
if (options.level === "warn") {
|
|
1430
1412
|
for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
|
|
1431
1413
|
}
|
|
1432
1414
|
return [{
|
|
1433
|
-
...config
|
|
1415
|
+
...config,
|
|
1434
1416
|
name: "regexp/rules",
|
|
1435
1417
|
rules: {
|
|
1436
1418
|
...rules,
|
|
@@ -1438,7 +1420,6 @@ async function regexp(options = {}) {
|
|
|
1438
1420
|
}
|
|
1439
1421
|
}];
|
|
1440
1422
|
}
|
|
1441
|
-
|
|
1442
1423
|
//#endregion
|
|
1443
1424
|
//#region src/configs/sort.ts
|
|
1444
1425
|
/**
|
|
@@ -1672,19 +1653,18 @@ function sortTsconfig() {
|
|
|
1672
1653
|
] }
|
|
1673
1654
|
}];
|
|
1674
1655
|
}
|
|
1675
|
-
|
|
1676
1656
|
//#endregion
|
|
1677
1657
|
//#region src/configs/tailwindcss.ts
|
|
1678
1658
|
async function tailwindcss(options = {}) {
|
|
1679
|
-
const { entryPoint, overrides = {}, stylistic
|
|
1659
|
+
const { entryPoint, overrides = {}, stylistic = true, tsconfigPath } = options;
|
|
1680
1660
|
await ensurePackages(["eslint-plugin-better-tailwindcss"]);
|
|
1681
1661
|
const [pluginTailwindCSS] = await Promise.all([interopDefault(import("eslint-plugin-better-tailwindcss"))]);
|
|
1682
|
-
const { indent = 2 } = typeof stylistic
|
|
1662
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1683
1663
|
return [{
|
|
1684
1664
|
name: "tailwindcss",
|
|
1685
1665
|
plugins: { tailwindcss: pluginTailwindCSS },
|
|
1686
1666
|
rules: {
|
|
1687
|
-
...stylistic
|
|
1667
|
+
...stylistic ? {
|
|
1688
1668
|
"tailwindcss/enforce-canonical-classes": "warn",
|
|
1689
1669
|
"tailwindcss/enforce-consistent-class-order": "warn",
|
|
1690
1670
|
"tailwindcss/enforce-consistent-line-wrapping": ["warn", { indent: typeof indent === "number" ? indent : indent === "tab" ? "tab" : 2 }],
|
|
@@ -1702,7 +1682,6 @@ async function tailwindcss(options = {}) {
|
|
|
1702
1682
|
} }
|
|
1703
1683
|
}];
|
|
1704
1684
|
}
|
|
1705
|
-
|
|
1706
1685
|
//#endregion
|
|
1707
1686
|
//#region src/configs/test.ts
|
|
1708
1687
|
let _pluginTest;
|
|
@@ -1740,12 +1719,11 @@ async function test(options = {}) {
|
|
|
1740
1719
|
}
|
|
1741
1720
|
}];
|
|
1742
1721
|
}
|
|
1743
|
-
|
|
1744
1722
|
//#endregion
|
|
1745
1723
|
//#region src/configs/toml.ts
|
|
1746
1724
|
async function toml(options = {}) {
|
|
1747
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1748
|
-
const { indent = 2 } = typeof stylistic
|
|
1725
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1726
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1749
1727
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1750
1728
|
return [{
|
|
1751
1729
|
name: "toml/setup",
|
|
@@ -1764,7 +1742,7 @@ async function toml(options = {}) {
|
|
|
1764
1742
|
"toml/precision-of-integer": "error",
|
|
1765
1743
|
"toml/tables-order": "error",
|
|
1766
1744
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1767
|
-
...stylistic
|
|
1745
|
+
...stylistic ? {
|
|
1768
1746
|
"toml/array-bracket-newline": "error",
|
|
1769
1747
|
"toml/array-bracket-spacing": "error",
|
|
1770
1748
|
"toml/array-element-newline": "error",
|
|
@@ -1781,18 +1759,17 @@ async function toml(options = {}) {
|
|
|
1781
1759
|
}
|
|
1782
1760
|
}];
|
|
1783
1761
|
}
|
|
1784
|
-
|
|
1785
1762
|
//#endregion
|
|
1786
1763
|
//#region src/configs/typescript.ts
|
|
1787
1764
|
async function typescript(options = {}) {
|
|
1788
1765
|
const { componentExts = [], erasableOnly = false, overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
1789
1766
|
const files = options.files ?? [
|
|
1790
|
-
|
|
1791
|
-
|
|
1767
|
+
"**/*.?([cm])ts",
|
|
1768
|
+
"**/*.?([cm])tsx",
|
|
1792
1769
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1793
1770
|
];
|
|
1794
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
1795
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1771
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
1772
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`];
|
|
1796
1773
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1797
1774
|
const isTypeAware = !!tsconfigPath;
|
|
1798
1775
|
const typeAwareRules = {
|
|
@@ -1822,10 +1799,10 @@ async function typescript(options = {}) {
|
|
|
1822
1799
|
"ts/unbound-method": "error"
|
|
1823
1800
|
};
|
|
1824
1801
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1825
|
-
function makeParser(typeAware, files
|
|
1802
|
+
function makeParser(typeAware, files, ignores) {
|
|
1826
1803
|
return {
|
|
1827
|
-
files
|
|
1828
|
-
...ignores
|
|
1804
|
+
files,
|
|
1805
|
+
...ignores ? { ignores } : {},
|
|
1829
1806
|
languageOptions: {
|
|
1830
1807
|
parser: parserTs,
|
|
1831
1808
|
parserOptions: {
|
|
@@ -1915,7 +1892,7 @@ async function typescript(options = {}) {
|
|
|
1915
1892
|
}] : [],
|
|
1916
1893
|
...erasableOnly ? [{
|
|
1917
1894
|
name: "antfu/typescript/erasable-syntax-only",
|
|
1918
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
1895
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-C63e_zBF.mjs")) },
|
|
1919
1896
|
rules: {
|
|
1920
1897
|
"erasable-syntax-only/enums": "error",
|
|
1921
1898
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -1925,7 +1902,6 @@ async function typescript(options = {}) {
|
|
|
1925
1902
|
}] : []
|
|
1926
1903
|
];
|
|
1927
1904
|
}
|
|
1928
|
-
|
|
1929
1905
|
//#endregion
|
|
1930
1906
|
//#region src/configs/unicorn.ts
|
|
1931
1907
|
async function unicorn(options = {}) {
|
|
@@ -1955,7 +1931,6 @@ async function unicorn(options = {}) {
|
|
|
1955
1931
|
}
|
|
1956
1932
|
}];
|
|
1957
1933
|
}
|
|
1958
|
-
|
|
1959
1934
|
//#endregion
|
|
1960
1935
|
//#region src/configs/unocss.ts
|
|
1961
1936
|
async function unocss(options = {}) {
|
|
@@ -1973,13 +1948,12 @@ async function unocss(options = {}) {
|
|
|
1973
1948
|
}
|
|
1974
1949
|
}];
|
|
1975
1950
|
}
|
|
1976
|
-
|
|
1977
1951
|
//#endregion
|
|
1978
1952
|
//#region src/configs/vue.ts
|
|
1979
1953
|
async function vue(options = {}) {
|
|
1980
|
-
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic
|
|
1954
|
+
const { a11y = false, files = [GLOB_VUE], overrides = {}, stylistic = true, vueVersion = 3 } = options;
|
|
1981
1955
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1982
|
-
const { indent = 2 } = typeof stylistic
|
|
1956
|
+
const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1983
1957
|
await ensurePackages([
|
|
1984
1958
|
"eslint-plugin-vue",
|
|
1985
1959
|
"vue-eslint-parser",
|
|
@@ -2112,7 +2086,7 @@ async function vue(options = {}) {
|
|
|
2112
2086
|
nonwords: false,
|
|
2113
2087
|
words: true
|
|
2114
2088
|
}],
|
|
2115
|
-
...stylistic
|
|
2089
|
+
...stylistic ? {
|
|
2116
2090
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2117
2091
|
"vue/arrow-spacing": ["error", {
|
|
2118
2092
|
after: true,
|
|
@@ -2184,12 +2158,11 @@ async function vue(options = {}) {
|
|
|
2184
2158
|
}
|
|
2185
2159
|
}];
|
|
2186
2160
|
}
|
|
2187
|
-
|
|
2188
2161
|
//#endregion
|
|
2189
2162
|
//#region src/configs/yaml.ts
|
|
2190
2163
|
async function yaml(options = {}) {
|
|
2191
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2192
|
-
const { indent = 2, quotes = "single" } = typeof stylistic
|
|
2164
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2165
|
+
const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2193
2166
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2194
2167
|
return [{
|
|
2195
2168
|
name: "yaml/setup",
|
|
@@ -2207,7 +2180,7 @@ async function yaml(options = {}) {
|
|
|
2207
2180
|
"yaml/no-irregular-whitespace": "error",
|
|
2208
2181
|
"yaml/plain-scalar": "error",
|
|
2209
2182
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2210
|
-
...stylistic
|
|
2183
|
+
...stylistic ? {
|
|
2211
2184
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2212
2185
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2213
2186
|
"yaml/flow-mapping-curly-newline": "error",
|
|
@@ -2227,7 +2200,22 @@ async function yaml(options = {}) {
|
|
|
2227
2200
|
}
|
|
2228
2201
|
}];
|
|
2229
2202
|
}
|
|
2230
|
-
|
|
2203
|
+
//#endregion
|
|
2204
|
+
//#region src/configs/e18e.ts
|
|
2205
|
+
async function e18e(options = {}) {
|
|
2206
|
+
const { isInEditor = false, modernization = true, moduleReplacements = isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
2207
|
+
const configs = pluginE18e.configs;
|
|
2208
|
+
return [{
|
|
2209
|
+
name: "antfu/e18e/rules",
|
|
2210
|
+
plugins: { e18e: pluginE18e },
|
|
2211
|
+
rules: {
|
|
2212
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
2213
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
2214
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
2215
|
+
...overrides
|
|
2216
|
+
}
|
|
2217
|
+
}];
|
|
2218
|
+
}
|
|
2231
2219
|
//#endregion
|
|
2232
2220
|
//#region src/factory.ts
|
|
2233
2221
|
const flatConfigProps = [
|
|
@@ -2264,7 +2252,7 @@ const defaultPluginRenaming = {
|
|
|
2264
2252
|
* The merged ESLint configurations.
|
|
2265
2253
|
*/
|
|
2266
2254
|
function config(options = {}, ...userConfigs) {
|
|
2267
|
-
const { autoRenamePlugins = true, componentExts = [],
|
|
2255
|
+
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"), typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = isPackageExists("unocss"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2268
2256
|
let isInEditor = options.isInEditor;
|
|
2269
2257
|
if (isInEditor == null) {
|
|
2270
2258
|
isInEditor = isInEditorEnv();
|
|
@@ -2272,111 +2260,111 @@ function config(options = {}, ...userConfigs) {
|
|
|
2272
2260
|
}
|
|
2273
2261
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2274
2262
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = typeof enableJsx === "object" ? true : enableJsx;
|
|
2275
|
-
const configs
|
|
2276
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
2263
|
+
const configs = [];
|
|
2264
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2277
2265
|
name: "gitignore",
|
|
2278
2266
|
...enableGitignore
|
|
2279
2267
|
})]));
|
|
2280
|
-
else configs
|
|
2268
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2281
2269
|
name: "gitignore",
|
|
2282
2270
|
strict: false
|
|
2283
2271
|
})]));
|
|
2284
2272
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2285
2273
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2286
|
-
configs
|
|
2274
|
+
configs.push(ignores(userIgnores, !enableTypeScript), javascript({
|
|
2287
2275
|
isInEditor,
|
|
2288
2276
|
overrides: getOverrides(options, "javascript")
|
|
2289
2277
|
}), comments(), command(), perfectionist());
|
|
2290
|
-
if (enableNode) configs
|
|
2291
|
-
if (enableJsdoc) configs
|
|
2292
|
-
if (enableImports) configs
|
|
2278
|
+
if (enableNode) configs.push(node());
|
|
2279
|
+
if (enableJsdoc) configs.push(jsdoc({ stylistic: stylisticOptions }));
|
|
2280
|
+
if (enableImports) configs.push(imports({
|
|
2293
2281
|
stylistic: stylisticOptions,
|
|
2294
2282
|
...resolveSubOptions(options, "imports")
|
|
2295
2283
|
}));
|
|
2296
|
-
if (
|
|
2284
|
+
if (enableE18e) configs.push(e18e({
|
|
2285
|
+
isInEditor,
|
|
2286
|
+
...enableE18e === true ? {} : enableE18e
|
|
2287
|
+
}));
|
|
2288
|
+
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2297
2289
|
if (enableVue) componentExts.push("vue");
|
|
2298
|
-
if (enableJsx) configs
|
|
2299
|
-
if (enableTypeScript) configs
|
|
2290
|
+
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
2291
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2300
2292
|
...typescriptOptions,
|
|
2301
2293
|
componentExts,
|
|
2302
2294
|
overrides: getOverrides(options, "typescript"),
|
|
2303
2295
|
type: options.type
|
|
2304
2296
|
}));
|
|
2305
|
-
if (stylisticOptions) configs
|
|
2297
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2306
2298
|
...stylisticOptions,
|
|
2307
2299
|
overrides: getOverrides(options, "stylistic")
|
|
2308
2300
|
}));
|
|
2309
|
-
if (enableRegexp) configs
|
|
2310
|
-
if (options.test ?? true) configs
|
|
2301
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2302
|
+
if (options.test ?? true) configs.push(test({
|
|
2311
2303
|
isInEditor,
|
|
2312
2304
|
overrides: getOverrides(options, "test")
|
|
2313
2305
|
}));
|
|
2314
|
-
if (enableVue) configs
|
|
2306
|
+
if (enableVue) configs.push(vue({
|
|
2315
2307
|
...resolveSubOptions(options, "vue"),
|
|
2316
2308
|
overrides: getOverrides(options, "vue"),
|
|
2317
2309
|
stylistic: stylisticOptions,
|
|
2318
2310
|
typescript: !!enableTypeScript
|
|
2319
2311
|
}));
|
|
2320
|
-
if (enableReact) configs
|
|
2312
|
+
if (enableReact) configs.push(react({
|
|
2321
2313
|
...typescriptOptions,
|
|
2322
2314
|
...resolveSubOptions(options, "react"),
|
|
2323
2315
|
overrides: getOverrides(options, "react"),
|
|
2324
2316
|
tsconfigPath
|
|
2325
2317
|
}));
|
|
2326
|
-
if (enableReactNative) configs
|
|
2318
|
+
if (enableReactNative) configs.push(reactNative({
|
|
2327
2319
|
...resolveSubOptions(options, "reactNative"),
|
|
2328
2320
|
overrides: getOverrides(options, "reactNative")
|
|
2329
2321
|
}));
|
|
2330
|
-
if (enableNext) configs
|
|
2331
|
-
if (
|
|
2332
|
-
...resolveSubOptions(options, "effector"),
|
|
2333
|
-
overrides: getOverrides(options, "effector")
|
|
2334
|
-
}));
|
|
2335
|
-
if (enableUnoCSS) configs$1.push(unocss({
|
|
2322
|
+
if (enableNext) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2323
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2336
2324
|
...resolveSubOptions(options, "unocss"),
|
|
2337
2325
|
overrides: getOverrides(options, "unocss")
|
|
2338
2326
|
}));
|
|
2339
|
-
if (enableTailwindCSS) configs
|
|
2327
|
+
if (enableTailwindCSS) configs.push(tailwindcss({
|
|
2340
2328
|
...typescriptOptions,
|
|
2341
2329
|
...resolveSubOptions(options, "tailwindcss"),
|
|
2342
2330
|
overrides: getOverrides(options, "tailwindcss"),
|
|
2343
2331
|
stylistic: stylisticOptions
|
|
2344
2332
|
}));
|
|
2345
|
-
if (options.jsonc ?? true) configs
|
|
2333
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2346
2334
|
overrides: getOverrides(options, "jsonc"),
|
|
2347
2335
|
stylistic: stylisticOptions
|
|
2348
2336
|
}), sortPackageJson(), sortTsconfig());
|
|
2349
2337
|
if (enableCatalogs) {
|
|
2350
2338
|
const optionsPnpm = resolveSubOptions(options, "pnpm");
|
|
2351
|
-
configs
|
|
2339
|
+
configs.push(pnpm({
|
|
2352
2340
|
isInEditor,
|
|
2353
2341
|
json: options.jsonc !== false,
|
|
2354
2342
|
yaml: options.yaml !== false,
|
|
2355
2343
|
...optionsPnpm
|
|
2356
2344
|
}));
|
|
2357
2345
|
}
|
|
2358
|
-
if (options.yaml ?? true) configs
|
|
2346
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2359
2347
|
overrides: getOverrides(options, "yaml"),
|
|
2360
2348
|
stylistic: stylisticOptions
|
|
2361
2349
|
}));
|
|
2362
|
-
if (options.toml ?? true) configs
|
|
2350
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2363
2351
|
overrides: getOverrides(options, "toml"),
|
|
2364
2352
|
stylistic: stylisticOptions
|
|
2365
2353
|
}));
|
|
2366
|
-
if (options.markdown ?? true) configs
|
|
2354
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2367
2355
|
componentExts,
|
|
2368
2356
|
overrides: getOverrides(options, "markdown")
|
|
2369
2357
|
}));
|
|
2370
|
-
if (options.formatters) configs
|
|
2371
|
-
configs
|
|
2358
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2359
|
+
configs.push(disables());
|
|
2372
2360
|
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
2361
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2374
2362
|
if (key in options) acc[key] = options[key];
|
|
2375
2363
|
return acc;
|
|
2376
2364
|
}, {});
|
|
2377
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2365
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2378
2366
|
let composer = new FlatConfigComposer();
|
|
2379
|
-
composer = composer.append(...configs
|
|
2367
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2380
2368
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2381
2369
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2382
2370
|
"unused-imports/no-unused-imports",
|
|
@@ -2385,16 +2373,9 @@ function config(options = {}, ...userConfigs) {
|
|
|
2385
2373
|
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
2386
2374
|
return composer;
|
|
2387
2375
|
}
|
|
2388
|
-
|
|
2389
2376
|
//#endregion
|
|
2390
2377
|
//#region src/config-presets.ts
|
|
2391
2378
|
const CONFIG_PRESET_FULL_ON = {
|
|
2392
|
-
effector: {
|
|
2393
|
-
future: true,
|
|
2394
|
-
patronum: true,
|
|
2395
|
-
react: true,
|
|
2396
|
-
scope: true
|
|
2397
|
-
},
|
|
2398
2379
|
formatters: true,
|
|
2399
2380
|
gitignore: true,
|
|
2400
2381
|
imports: true,
|
|
@@ -2422,7 +2403,6 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2422
2403
|
yaml: true
|
|
2423
2404
|
};
|
|
2424
2405
|
const CONFIG_PRESET_FULL_OFF = {
|
|
2425
|
-
effector: false,
|
|
2426
2406
|
formatters: false,
|
|
2427
2407
|
gitignore: false,
|
|
2428
2408
|
imports: false,
|
|
@@ -2446,10 +2426,8 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2446
2426
|
vue: false,
|
|
2447
2427
|
yaml: false
|
|
2448
2428
|
};
|
|
2449
|
-
|
|
2450
2429
|
//#endregion
|
|
2451
2430
|
//#region src/index.ts
|
|
2452
2431
|
var src_default = config;
|
|
2453
|
-
|
|
2454
2432
|
//#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,
|
|
2433
|
+
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 };
|