@2030/eslint-config 1.0.0-beta.2 → 2.0.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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/cli.cjs +134 -133
- package/dist/cli.js +134 -133
- package/dist/index.cjs +231 -180
- package/dist/index.d.cts +854 -275
- package/dist/index.d.ts +854 -275
- package/dist/index.js +240 -190
- package/package.json +53 -54
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
|
-
import { isPackageExists as isPackageExists4 } from "local-pkg";
|
|
3
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
|
+
import { isPackageExists as isPackageExists4 } from "local-pkg";
|
|
4
4
|
|
|
5
5
|
// src/globs.ts
|
|
6
6
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -88,7 +88,7 @@ import process from "node:process";
|
|
|
88
88
|
import { fileURLToPath } from "node:url";
|
|
89
89
|
import { isPackageExists } from "local-pkg";
|
|
90
90
|
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
91
|
-
var isCwdInScope = isPackageExists("@
|
|
91
|
+
var isCwdInScope = isPackageExists("@jun2030/eslint-config");
|
|
92
92
|
var parserPlain = {
|
|
93
93
|
meta: {
|
|
94
94
|
name: "parser-plain"
|
|
@@ -169,10 +169,10 @@ function isInEditorEnv() {
|
|
|
169
169
|
return false;
|
|
170
170
|
if (isInGitHooksOrLintStaged())
|
|
171
171
|
return false;
|
|
172
|
-
return !!process.env.VSCODE_PID ||
|
|
172
|
+
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
173
173
|
}
|
|
174
174
|
function isInGitHooksOrLintStaged() {
|
|
175
|
-
return !!process.env.GIT_PARAMS ||
|
|
175
|
+
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
// src/configs/astro.ts
|
|
@@ -226,7 +226,6 @@ async function astro(options = {}) {
|
|
|
226
226
|
...stylistic2 ? {
|
|
227
227
|
"style/indent": "off",
|
|
228
228
|
"style/jsx-closing-tag-location": "off",
|
|
229
|
-
"style/jsx-indent": "off",
|
|
230
229
|
"style/jsx-one-expression-per-line": "off",
|
|
231
230
|
"style/no-multiple-empty-lines": "off"
|
|
232
231
|
} : {},
|
|
@@ -248,13 +247,13 @@ async function command() {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
// src/plugins.ts
|
|
251
|
-
import { default as default2 } from "eslint-plugin-
|
|
252
|
-
import { default as default3 } from "
|
|
250
|
+
import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
251
|
+
import { default as default3 } from "eslint-plugin-antfu";
|
|
253
252
|
import * as pluginImport from "eslint-plugin-import-x";
|
|
254
253
|
import { default as default4 } from "eslint-plugin-n";
|
|
255
|
-
import { default as default5 } from "eslint-plugin-
|
|
256
|
-
import { default as default6 } from "eslint-plugin-
|
|
257
|
-
import { default as default7 } from "eslint-plugin-
|
|
254
|
+
import { default as default5 } from "eslint-plugin-perfectionist";
|
|
255
|
+
import { default as default6 } from "eslint-plugin-unicorn";
|
|
256
|
+
import { default as default7 } from "eslint-plugin-unused-imports";
|
|
258
257
|
|
|
259
258
|
// src/configs/comments.ts
|
|
260
259
|
async function comments() {
|
|
@@ -262,7 +261,7 @@ async function comments() {
|
|
|
262
261
|
{
|
|
263
262
|
name: "jun/eslint-comments/rules",
|
|
264
263
|
plugins: {
|
|
265
|
-
"eslint-comments":
|
|
264
|
+
"eslint-comments": default2
|
|
266
265
|
},
|
|
267
266
|
rules: {
|
|
268
267
|
"eslint-comments/no-aggregating-enable": "error",
|
|
@@ -274,6 +273,63 @@ async function comments() {
|
|
|
274
273
|
];
|
|
275
274
|
}
|
|
276
275
|
|
|
276
|
+
// src/configs/disables.ts
|
|
277
|
+
async function disables() {
|
|
278
|
+
return [
|
|
279
|
+
{
|
|
280
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
281
|
+
name: "jun/disables/scripts",
|
|
282
|
+
rules: {
|
|
283
|
+
"jun/no-top-level-await": "off",
|
|
284
|
+
"no-console": "off",
|
|
285
|
+
"ts/explicit-function-return-type": "off"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
290
|
+
name: "jun/disables/cli",
|
|
291
|
+
rules: {
|
|
292
|
+
"jun/no-top-level-await": "off",
|
|
293
|
+
"no-console": "off"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
298
|
+
name: "jun/disables/bin",
|
|
299
|
+
rules: {
|
|
300
|
+
"jun/no-import-dist": "off",
|
|
301
|
+
"jun/no-import-node-modules-by-path": "off"
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
files: ["**/*.d.?([cm])ts"],
|
|
306
|
+
name: "jun/disables/dts",
|
|
307
|
+
rules: {
|
|
308
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
309
|
+
"import/no-duplicates": "off",
|
|
310
|
+
"no-restricted-syntax": "off",
|
|
311
|
+
"unused-imports/no-unused-vars": "off"
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
316
|
+
name: "jun/disables/cjs",
|
|
317
|
+
rules: {
|
|
318
|
+
"ts/no-require-imports": "off"
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
323
|
+
name: "jun/disables/config-files",
|
|
324
|
+
rules: {
|
|
325
|
+
"jun/no-top-level-await": "off",
|
|
326
|
+
"no-console": "off",
|
|
327
|
+
"ts/explicit-function-return-type": "off"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
];
|
|
331
|
+
}
|
|
332
|
+
|
|
277
333
|
// src/configs/formatters.ts
|
|
278
334
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
279
335
|
|
|
@@ -309,11 +365,12 @@ async function stylistic(options = {}) {
|
|
|
309
365
|
{
|
|
310
366
|
name: "jun/stylistic/rules",
|
|
311
367
|
plugins: {
|
|
312
|
-
jun:
|
|
368
|
+
jun: default3,
|
|
313
369
|
style: pluginStylistic
|
|
314
370
|
},
|
|
315
371
|
rules: {
|
|
316
372
|
...config.rules,
|
|
373
|
+
"jun/consistent-chaining": "error",
|
|
317
374
|
"jun/consistent-list-newline": "error",
|
|
318
375
|
...lessOpinionated ? {
|
|
319
376
|
curly: ["error", "all"]
|
|
@@ -329,6 +386,16 @@ async function stylistic(options = {}) {
|
|
|
329
386
|
}
|
|
330
387
|
|
|
331
388
|
// src/configs/formatters.ts
|
|
389
|
+
function mergePrettierOptions(options, overrides = {}) {
|
|
390
|
+
return {
|
|
391
|
+
...options,
|
|
392
|
+
...overrides,
|
|
393
|
+
plugins: [
|
|
394
|
+
...overrides.plugins || [],
|
|
395
|
+
...options.plugins || []
|
|
396
|
+
]
|
|
397
|
+
};
|
|
398
|
+
}
|
|
332
399
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
333
400
|
if (options === true) {
|
|
334
401
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
@@ -405,10 +472,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
405
472
|
rules: {
|
|
406
473
|
"format/prettier": [
|
|
407
474
|
"error",
|
|
408
|
-
{
|
|
409
|
-
...prettierOptions,
|
|
475
|
+
mergePrettierOptions(prettierOptions, {
|
|
410
476
|
parser: "css"
|
|
411
|
-
}
|
|
477
|
+
})
|
|
412
478
|
]
|
|
413
479
|
}
|
|
414
480
|
},
|
|
@@ -421,10 +487,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
421
487
|
rules: {
|
|
422
488
|
"format/prettier": [
|
|
423
489
|
"error",
|
|
424
|
-
{
|
|
425
|
-
...prettierOptions,
|
|
490
|
+
mergePrettierOptions(prettierOptions, {
|
|
426
491
|
parser: "scss"
|
|
427
|
-
}
|
|
492
|
+
})
|
|
428
493
|
]
|
|
429
494
|
}
|
|
430
495
|
},
|
|
@@ -437,10 +502,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
437
502
|
rules: {
|
|
438
503
|
"format/prettier": [
|
|
439
504
|
"error",
|
|
440
|
-
{
|
|
441
|
-
...prettierOptions,
|
|
505
|
+
mergePrettierOptions(prettierOptions, {
|
|
442
506
|
parser: "less"
|
|
443
|
-
}
|
|
507
|
+
})
|
|
444
508
|
]
|
|
445
509
|
}
|
|
446
510
|
}
|
|
@@ -456,10 +520,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
456
520
|
rules: {
|
|
457
521
|
"format/prettier": [
|
|
458
522
|
"error",
|
|
459
|
-
{
|
|
460
|
-
...prettierOptions,
|
|
523
|
+
mergePrettierOptions(prettierOptions, {
|
|
461
524
|
parser: "html"
|
|
462
|
-
}
|
|
525
|
+
})
|
|
463
526
|
]
|
|
464
527
|
}
|
|
465
528
|
});
|
|
@@ -474,14 +537,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
474
537
|
rules: {
|
|
475
538
|
"format/prettier": [
|
|
476
539
|
"error",
|
|
477
|
-
{
|
|
478
|
-
...prettierXmlOptions,
|
|
479
|
-
...prettierOptions,
|
|
540
|
+
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
|
|
480
541
|
parser: "xml",
|
|
481
542
|
plugins: [
|
|
482
543
|
"@prettier/plugin-xml"
|
|
483
544
|
]
|
|
484
|
-
}
|
|
545
|
+
})
|
|
485
546
|
]
|
|
486
547
|
}
|
|
487
548
|
});
|
|
@@ -496,14 +557,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
496
557
|
rules: {
|
|
497
558
|
"format/prettier": [
|
|
498
559
|
"error",
|
|
499
|
-
{
|
|
500
|
-
...prettierXmlOptions,
|
|
501
|
-
...prettierOptions,
|
|
560
|
+
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
|
|
502
561
|
parser: "xml",
|
|
503
562
|
plugins: [
|
|
504
563
|
"@prettier/plugin-xml"
|
|
505
564
|
]
|
|
506
|
-
}
|
|
565
|
+
})
|
|
507
566
|
]
|
|
508
567
|
}
|
|
509
568
|
});
|
|
@@ -521,11 +580,10 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
521
580
|
rules: {
|
|
522
581
|
[`format/${formater}`]: [
|
|
523
582
|
"error",
|
|
524
|
-
formater === "prettier" ? {
|
|
525
|
-
...prettierOptions,
|
|
583
|
+
formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
526
584
|
embeddedLanguageFormatting: "off",
|
|
527
585
|
parser: "markdown"
|
|
528
|
-
} : {
|
|
586
|
+
}) : {
|
|
529
587
|
...dprintOptions,
|
|
530
588
|
language: "markdown"
|
|
531
589
|
}
|
|
@@ -542,14 +600,13 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
542
600
|
rules: {
|
|
543
601
|
"format/prettier": [
|
|
544
602
|
"error",
|
|
545
|
-
{
|
|
546
|
-
...prettierOptions,
|
|
603
|
+
mergePrettierOptions(prettierOptions, {
|
|
547
604
|
embeddedLanguageFormatting: "off",
|
|
548
605
|
parser: "slidev",
|
|
549
606
|
plugins: [
|
|
550
607
|
"prettier-plugin-slidev"
|
|
551
608
|
]
|
|
552
|
-
}
|
|
609
|
+
})
|
|
553
610
|
]
|
|
554
611
|
}
|
|
555
612
|
});
|
|
@@ -565,13 +622,12 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
565
622
|
rules: {
|
|
566
623
|
"format/prettier": [
|
|
567
624
|
"error",
|
|
568
|
-
{
|
|
569
|
-
...prettierOptions,
|
|
625
|
+
mergePrettierOptions(prettierOptions, {
|
|
570
626
|
parser: "astro",
|
|
571
627
|
plugins: [
|
|
572
628
|
"prettier-plugin-astro"
|
|
573
629
|
]
|
|
574
|
-
}
|
|
630
|
+
})
|
|
575
631
|
]
|
|
576
632
|
}
|
|
577
633
|
});
|
|
@@ -599,10 +655,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
599
655
|
rules: {
|
|
600
656
|
"format/prettier": [
|
|
601
657
|
"error",
|
|
602
|
-
{
|
|
603
|
-
...prettierOptions,
|
|
658
|
+
mergePrettierOptions(prettierOptions, {
|
|
604
659
|
parser: "graphql"
|
|
605
|
-
}
|
|
660
|
+
})
|
|
606
661
|
]
|
|
607
662
|
}
|
|
608
663
|
});
|
|
@@ -611,10 +666,14 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
611
666
|
}
|
|
612
667
|
|
|
613
668
|
// src/configs/ignores.ts
|
|
614
|
-
async function ignores() {
|
|
669
|
+
async function ignores(userIgnores = []) {
|
|
615
670
|
return [
|
|
616
671
|
{
|
|
617
|
-
ignores:
|
|
672
|
+
ignores: [
|
|
673
|
+
...GLOB_EXCLUDE,
|
|
674
|
+
...userIgnores
|
|
675
|
+
],
|
|
676
|
+
name: "jun/ignores"
|
|
618
677
|
}
|
|
619
678
|
];
|
|
620
679
|
}
|
|
@@ -629,7 +688,7 @@ async function imports(options = {}) {
|
|
|
629
688
|
name: "jun/imports/rules",
|
|
630
689
|
plugins: {
|
|
631
690
|
import: pluginImport,
|
|
632
|
-
jun:
|
|
691
|
+
jun: default3
|
|
633
692
|
},
|
|
634
693
|
rules: {
|
|
635
694
|
"import/first": "error",
|
|
@@ -638,7 +697,6 @@ async function imports(options = {}) {
|
|
|
638
697
|
"import/no-named-default": "error",
|
|
639
698
|
"import/no-self-import": "error",
|
|
640
699
|
"import/no-webpack-loader-syntax": "error",
|
|
641
|
-
"import/order": "error",
|
|
642
700
|
"jun/import-dedupe": "error",
|
|
643
701
|
"jun/no-import-dist": "error",
|
|
644
702
|
"jun/no-import-node-modules-by-path": "error",
|
|
@@ -646,14 +704,6 @@ async function imports(options = {}) {
|
|
|
646
704
|
"import/newline-after-import": ["error", { count: 1 }]
|
|
647
705
|
} : {}
|
|
648
706
|
}
|
|
649
|
-
},
|
|
650
|
-
{
|
|
651
|
-
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
652
|
-
name: "jun/imports/disables/bin",
|
|
653
|
-
rules: {
|
|
654
|
-
"jun/no-import-dist": "off",
|
|
655
|
-
"jun/no-import-node-modules-by-path": "off"
|
|
656
|
-
}
|
|
657
707
|
}
|
|
658
708
|
];
|
|
659
709
|
}
|
|
@@ -694,8 +744,8 @@ async function javascript(options = {}) {
|
|
|
694
744
|
{
|
|
695
745
|
name: "jun/javascript/rules",
|
|
696
746
|
plugins: {
|
|
697
|
-
"jun":
|
|
698
|
-
"unused-imports":
|
|
747
|
+
"jun": default3,
|
|
748
|
+
"unused-imports": default7
|
|
699
749
|
},
|
|
700
750
|
rules: {
|
|
701
751
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
@@ -705,6 +755,7 @@ async function javascript(options = {}) {
|
|
|
705
755
|
"default-case-last": "error",
|
|
706
756
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
707
757
|
"eqeqeq": ["error", "smart"],
|
|
758
|
+
"jun/no-top-level-await": "error",
|
|
708
759
|
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
709
760
|
"no-alert": "error",
|
|
710
761
|
"no-array-constructor": "error",
|
|
@@ -770,9 +821,6 @@ async function javascript(options = {}) {
|
|
|
770
821
|
],
|
|
771
822
|
"no-restricted-syntax": [
|
|
772
823
|
"error",
|
|
773
|
-
"DebuggerStatement",
|
|
774
|
-
"LabeledStatement",
|
|
775
|
-
"WithStatement",
|
|
776
824
|
"TSEnumDeclaration[const=true]",
|
|
777
825
|
"TSExportAssignment"
|
|
778
826
|
],
|
|
@@ -843,16 +891,6 @@ async function javascript(options = {}) {
|
|
|
843
891
|
"prefer-rest-params": "error",
|
|
844
892
|
"prefer-spread": "error",
|
|
845
893
|
"prefer-template": "error",
|
|
846
|
-
"sort-imports": [
|
|
847
|
-
"error",
|
|
848
|
-
{
|
|
849
|
-
allowSeparatedGroups: false,
|
|
850
|
-
ignoreCase: false,
|
|
851
|
-
ignoreDeclarationSort: true,
|
|
852
|
-
ignoreMemberSort: false,
|
|
853
|
-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
|
|
854
|
-
}
|
|
855
|
-
],
|
|
856
894
|
"symbol-description": "error",
|
|
857
895
|
"unicode-bom": ["error", "never"],
|
|
858
896
|
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
@@ -872,13 +910,6 @@ async function javascript(options = {}) {
|
|
|
872
910
|
"yoda": ["error", "never"],
|
|
873
911
|
...overrides
|
|
874
912
|
}
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
878
|
-
name: "jun/javascript/disables/cli",
|
|
879
|
-
rules: {
|
|
880
|
-
"no-console": "off"
|
|
881
|
-
}
|
|
882
913
|
}
|
|
883
914
|
];
|
|
884
915
|
}
|
|
@@ -919,23 +950,6 @@ async function jsdoc(options = {}) {
|
|
|
919
950
|
];
|
|
920
951
|
}
|
|
921
952
|
|
|
922
|
-
// src/configs/jsx.ts
|
|
923
|
-
async function jsx() {
|
|
924
|
-
return [
|
|
925
|
-
{
|
|
926
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
927
|
-
languageOptions: {
|
|
928
|
-
parserOptions: {
|
|
929
|
-
ecmaFeatures: {
|
|
930
|
-
jsx: true
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
},
|
|
934
|
-
name: "jun/jsx/setup"
|
|
935
|
-
}
|
|
936
|
-
];
|
|
937
|
-
}
|
|
938
|
-
|
|
939
953
|
// src/configs/jsonc.ts
|
|
940
954
|
async function jsonc(options = {}) {
|
|
941
955
|
const {
|
|
@@ -1011,6 +1025,23 @@ async function jsonc(options = {}) {
|
|
|
1011
1025
|
];
|
|
1012
1026
|
}
|
|
1013
1027
|
|
|
1028
|
+
// src/configs/jsx.ts
|
|
1029
|
+
async function jsx() {
|
|
1030
|
+
return [
|
|
1031
|
+
{
|
|
1032
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
1033
|
+
languageOptions: {
|
|
1034
|
+
parserOptions: {
|
|
1035
|
+
ecmaFeatures: {
|
|
1036
|
+
jsx: true
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
name: "jun/jsx/setup"
|
|
1041
|
+
}
|
|
1042
|
+
];
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1014
1045
|
// src/configs/markdown.ts
|
|
1015
1046
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
1016
1047
|
async function markdown(options = {}) {
|
|
@@ -1019,7 +1050,7 @@ async function markdown(options = {}) {
|
|
|
1019
1050
|
files = [GLOB_MARKDOWN],
|
|
1020
1051
|
overrides = {}
|
|
1021
1052
|
} = options;
|
|
1022
|
-
const markdown2 = await interopDefault(import("eslint
|
|
1053
|
+
const markdown2 = await interopDefault(import("@eslint/markdown"));
|
|
1023
1054
|
return [
|
|
1024
1055
|
{
|
|
1025
1056
|
name: "jun/markdown/setup",
|
|
@@ -1061,6 +1092,7 @@ async function markdown(options = {}) {
|
|
|
1061
1092
|
name: "jun/markdown/disables",
|
|
1062
1093
|
rules: {
|
|
1063
1094
|
"import/newline-after-import": "off",
|
|
1095
|
+
"jun/no-top-level-await": "off",
|
|
1064
1096
|
"no-alert": "off",
|
|
1065
1097
|
"no-console": "off",
|
|
1066
1098
|
"no-labels": "off",
|
|
@@ -1074,13 +1106,13 @@ async function markdown(options = {}) {
|
|
|
1074
1106
|
"style/comma-dangle": "off",
|
|
1075
1107
|
"style/eol-last": "off",
|
|
1076
1108
|
"ts/consistent-type-imports": "off",
|
|
1109
|
+
"ts/explicit-function-return-type": "off",
|
|
1077
1110
|
"ts/no-namespace": "off",
|
|
1078
1111
|
"ts/no-redeclare": "off",
|
|
1079
1112
|
"ts/no-require-imports": "off",
|
|
1080
1113
|
"ts/no-unused-expressions": "off",
|
|
1081
1114
|
"ts/no-unused-vars": "off",
|
|
1082
1115
|
"ts/no-use-before-define": "off",
|
|
1083
|
-
"ts/no-var-requires": "off",
|
|
1084
1116
|
"unicode-bom": "off",
|
|
1085
1117
|
"unused-imports/no-unused-imports": "off",
|
|
1086
1118
|
"unused-imports/no-unused-vars": "off",
|
|
@@ -1118,7 +1150,28 @@ async function perfectionist() {
|
|
|
1118
1150
|
{
|
|
1119
1151
|
name: "jun/perfectionist/setup",
|
|
1120
1152
|
plugins: {
|
|
1121
|
-
perfectionist:
|
|
1153
|
+
perfectionist: default5
|
|
1154
|
+
},
|
|
1155
|
+
rules: {
|
|
1156
|
+
"perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
|
|
1157
|
+
"perfectionist/sort-imports": ["error", {
|
|
1158
|
+
groups: [
|
|
1159
|
+
"type",
|
|
1160
|
+
["parent-type", "sibling-type", "index-type"],
|
|
1161
|
+
"builtin",
|
|
1162
|
+
"external",
|
|
1163
|
+
["internal", "internal-type"],
|
|
1164
|
+
["parent", "sibling", "index"],
|
|
1165
|
+
"side-effect",
|
|
1166
|
+
"object",
|
|
1167
|
+
"unknown"
|
|
1168
|
+
],
|
|
1169
|
+
newlinesBetween: "ignore",
|
|
1170
|
+
order: "asc",
|
|
1171
|
+
type: "natural"
|
|
1172
|
+
}],
|
|
1173
|
+
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
1174
|
+
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
1122
1175
|
}
|
|
1123
1176
|
}
|
|
1124
1177
|
];
|
|
@@ -1213,6 +1266,13 @@ async function react(options = {}) {
|
|
|
1213
1266
|
allowConstantExport: isAllowConstantExport,
|
|
1214
1267
|
allowExportNames: [
|
|
1215
1268
|
...isUsingNext ? [
|
|
1269
|
+
"dynamic",
|
|
1270
|
+
"dynamicParams",
|
|
1271
|
+
"revalidate",
|
|
1272
|
+
"fetchCache",
|
|
1273
|
+
"runtime",
|
|
1274
|
+
"preferredRegion",
|
|
1275
|
+
"maxDuration",
|
|
1216
1276
|
"config",
|
|
1217
1277
|
"generateStaticParams",
|
|
1218
1278
|
"metadata",
|
|
@@ -1277,6 +1337,31 @@ async function react(options = {}) {
|
|
|
1277
1337
|
];
|
|
1278
1338
|
}
|
|
1279
1339
|
|
|
1340
|
+
// src/configs/regexp.ts
|
|
1341
|
+
import { configs } from "eslint-plugin-regexp";
|
|
1342
|
+
async function regexp(options = {}) {
|
|
1343
|
+
const config = configs["flat/recommended"];
|
|
1344
|
+
const rules = {
|
|
1345
|
+
...config.rules
|
|
1346
|
+
};
|
|
1347
|
+
if (options.level === "warn") {
|
|
1348
|
+
for (const key in rules) {
|
|
1349
|
+
if (rules[key] === "error")
|
|
1350
|
+
rules[key] = "warn";
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return [
|
|
1354
|
+
{
|
|
1355
|
+
...config,
|
|
1356
|
+
name: "jun/regexp/rules",
|
|
1357
|
+
rules: {
|
|
1358
|
+
...rules,
|
|
1359
|
+
...options.overrides
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
];
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1280
1365
|
// src/configs/solid.ts
|
|
1281
1366
|
async function solid(options = {}) {
|
|
1282
1367
|
const {
|
|
@@ -1717,14 +1802,19 @@ async function test(options = {}) {
|
|
|
1717
1802
|
files,
|
|
1718
1803
|
name: "jun/test/rules",
|
|
1719
1804
|
rules: {
|
|
1720
|
-
"node/prefer-global/process": "off",
|
|
1721
1805
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1722
1806
|
"test/no-identical-title": "error",
|
|
1723
1807
|
"test/no-import-node-test": "error",
|
|
1724
1808
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1725
1809
|
"test/prefer-hooks-in-order": "error",
|
|
1726
1810
|
"test/prefer-lowercase-title": "error",
|
|
1727
|
-
|
|
1811
|
+
// Disables
|
|
1812
|
+
...{
|
|
1813
|
+
"jun/no-top-level-await": "off",
|
|
1814
|
+
"no-unused-expressions": "off",
|
|
1815
|
+
"node/prefer-global/process": "off",
|
|
1816
|
+
"ts/explicit-function-return-type": "off"
|
|
1817
|
+
},
|
|
1728
1818
|
...overrides
|
|
1729
1819
|
}
|
|
1730
1820
|
}
|
|
@@ -1869,7 +1959,7 @@ async function typescript(options = {}) {
|
|
|
1869
1959
|
// Install the plugins without globs, so they can be configured separately.
|
|
1870
1960
|
name: "jun/typescript/setup",
|
|
1871
1961
|
plugins: {
|
|
1872
|
-
jun:
|
|
1962
|
+
jun: default3,
|
|
1873
1963
|
ts: pluginTs
|
|
1874
1964
|
}
|
|
1875
1965
|
},
|
|
@@ -1893,7 +1983,6 @@ async function typescript(options = {}) {
|
|
|
1893
1983
|
{ "@typescript-eslint": "ts" }
|
|
1894
1984
|
),
|
|
1895
1985
|
"no-dupe-class-members": "off",
|
|
1896
|
-
"no-loss-of-precision": "off",
|
|
1897
1986
|
"no-redeclare": "off",
|
|
1898
1987
|
"no-use-before-define": "off",
|
|
1899
1988
|
"no-useless-constructor": "off",
|
|
@@ -1912,10 +2001,14 @@ async function typescript(options = {}) {
|
|
|
1912
2001
|
"ts/no-extraneous-class": "off",
|
|
1913
2002
|
"ts/no-import-type-side-effects": "error",
|
|
1914
2003
|
"ts/no-invalid-void-type": "off",
|
|
1915
|
-
"ts/no-loss-of-precision": "error",
|
|
1916
2004
|
"ts/no-non-null-assertion": "off",
|
|
1917
|
-
"ts/no-redeclare": "error",
|
|
2005
|
+
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1918
2006
|
"ts/no-require-imports": "error",
|
|
2007
|
+
"ts/no-unused-expressions": ["error", {
|
|
2008
|
+
allowShortCircuit: true,
|
|
2009
|
+
allowTaggedTemplates: true,
|
|
2010
|
+
allowTernary: true
|
|
2011
|
+
}],
|
|
1919
2012
|
"ts/no-unused-vars": "off",
|
|
1920
2013
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1921
2014
|
"ts/no-useless-constructor": "off",
|
|
@@ -1940,70 +2033,36 @@ async function typescript(options = {}) {
|
|
|
1940
2033
|
...typeAwareRules,
|
|
1941
2034
|
...overridesTypeAware
|
|
1942
2035
|
}
|
|
1943
|
-
}] : []
|
|
1944
|
-
{
|
|
1945
|
-
files: ["**/*.d.?([cm])ts"],
|
|
1946
|
-
name: "jun/typescript/disables/dts",
|
|
1947
|
-
rules: {
|
|
1948
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
1949
|
-
"import/no-duplicates": "off",
|
|
1950
|
-
"no-restricted-syntax": "off",
|
|
1951
|
-
"unused-imports/no-unused-vars": "off"
|
|
1952
|
-
}
|
|
1953
|
-
},
|
|
1954
|
-
{
|
|
1955
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1956
|
-
name: "jun/typescript/disables/test",
|
|
1957
|
-
rules: {
|
|
1958
|
-
"no-unused-expressions": "off"
|
|
1959
|
-
}
|
|
1960
|
-
},
|
|
1961
|
-
{
|
|
1962
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
1963
|
-
name: "jun/typescript/disables/cjs",
|
|
1964
|
-
rules: {
|
|
1965
|
-
"ts/no-require-imports": "off",
|
|
1966
|
-
"ts/no-var-requires": "off"
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
2036
|
+
}] : []
|
|
1969
2037
|
];
|
|
1970
2038
|
}
|
|
1971
2039
|
|
|
1972
2040
|
// src/configs/unicorn.ts
|
|
1973
|
-
async function unicorn() {
|
|
2041
|
+
async function unicorn(options = {}) {
|
|
1974
2042
|
return [
|
|
1975
2043
|
{
|
|
1976
2044
|
name: "jun/unicorn/rules",
|
|
1977
2045
|
plugins: {
|
|
1978
|
-
unicorn:
|
|
2046
|
+
unicorn: default6
|
|
1979
2047
|
},
|
|
1980
2048
|
rules: {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
"unicorn/prefer-node-protocol": "error",
|
|
1999
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
2000
|
-
"unicorn/prefer-number-properties": "error",
|
|
2001
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
2002
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2003
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
2004
|
-
"unicorn/prefer-type-error": "error",
|
|
2005
|
-
// Use new when throwing error
|
|
2006
|
-
"unicorn/throw-new-error": "error"
|
|
2049
|
+
...options.allRecommended ? default6.configs["flat/recommended"].rules : {
|
|
2050
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
2051
|
+
"unicorn/error-message": "error",
|
|
2052
|
+
"unicorn/escape-case": "error",
|
|
2053
|
+
"unicorn/new-for-builtins": "error",
|
|
2054
|
+
"unicorn/no-instanceof-array": "error",
|
|
2055
|
+
"unicorn/no-new-array": "error",
|
|
2056
|
+
"unicorn/no-new-buffer": "error",
|
|
2057
|
+
"unicorn/number-literal-case": "error",
|
|
2058
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
2059
|
+
"unicorn/prefer-includes": "error",
|
|
2060
|
+
"unicorn/prefer-node-protocol": "error",
|
|
2061
|
+
"unicorn/prefer-number-properties": "error",
|
|
2062
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2063
|
+
"unicorn/prefer-type-error": "error",
|
|
2064
|
+
"unicorn/throw-new-error": "error"
|
|
2065
|
+
}
|
|
2007
2066
|
}
|
|
2008
2067
|
}
|
|
2009
2068
|
];
|
|
@@ -2127,7 +2186,9 @@ async function vue(options = {}) {
|
|
|
2127
2186
|
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2128
2187
|
...pluginVue.configs["vue3-recommended"].rules
|
|
2129
2188
|
},
|
|
2189
|
+
"jun/no-top-level-await": "off",
|
|
2130
2190
|
"node/prefer-global/process": "off",
|
|
2191
|
+
"ts/explicit-function-return-type": "off",
|
|
2131
2192
|
"vue/block-order": ["error", {
|
|
2132
2193
|
order: ["script", "template", "style"]
|
|
2133
2194
|
}],
|
|
@@ -2185,7 +2246,7 @@ async function vue(options = {}) {
|
|
|
2185
2246
|
multiline: "always",
|
|
2186
2247
|
singleline: "always"
|
|
2187
2248
|
}],
|
|
2188
|
-
"vue/brace-style": ["error", "
|
|
2249
|
+
"vue/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
2189
2250
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
2190
2251
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
2191
2252
|
"vue/comma-style": ["error", "last"],
|
|
@@ -2268,36 +2329,9 @@ async function yaml(options = {}) {
|
|
|
2268
2329
|
];
|
|
2269
2330
|
}
|
|
2270
2331
|
|
|
2271
|
-
// src/configs/regexp.ts
|
|
2272
|
-
import { configs } from "eslint-plugin-regexp";
|
|
2273
|
-
async function regexp(options = {}) {
|
|
2274
|
-
const config = configs["flat/recommended"];
|
|
2275
|
-
const rules = {
|
|
2276
|
-
...config.rules
|
|
2277
|
-
};
|
|
2278
|
-
if (options.level === "warn") {
|
|
2279
|
-
for (const key in rules) {
|
|
2280
|
-
if (rules[key] === "error")
|
|
2281
|
-
rules[key] = "warn";
|
|
2282
|
-
}
|
|
2283
|
-
}
|
|
2284
|
-
return [
|
|
2285
|
-
{
|
|
2286
|
-
...config,
|
|
2287
|
-
name: "jun/regexp/rules",
|
|
2288
|
-
rules: {
|
|
2289
|
-
...rules,
|
|
2290
|
-
...options.overrides
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
];
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
2332
|
// src/factory.ts
|
|
2297
2333
|
var flatConfigProps = [
|
|
2298
2334
|
"name",
|
|
2299
|
-
"files",
|
|
2300
|
-
"ignores",
|
|
2301
2335
|
"languageOptions",
|
|
2302
2336
|
"linterOptions",
|
|
2303
2337
|
"processor",
|
|
@@ -2335,6 +2369,7 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2335
2369
|
solid: enableSolid = false,
|
|
2336
2370
|
svelte: enableSvelte = false,
|
|
2337
2371
|
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
2372
|
+
unicorn: enableUnicorn = true,
|
|
2338
2373
|
unocss: enableUnoCSS = false,
|
|
2339
2374
|
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
2340
2375
|
} = options;
|
|
@@ -2350,15 +2385,21 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2350
2385
|
const configs2 = [];
|
|
2351
2386
|
if (enableGitignore) {
|
|
2352
2387
|
if (typeof enableGitignore !== "boolean") {
|
|
2353
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(
|
|
2388
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2389
|
+
name: "jun/gitignore",
|
|
2390
|
+
...enableGitignore
|
|
2391
|
+
})]));
|
|
2354
2392
|
} else {
|
|
2355
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2393
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2394
|
+
name: "jun/gitignore",
|
|
2395
|
+
strict: false
|
|
2396
|
+
})]));
|
|
2356
2397
|
}
|
|
2357
2398
|
}
|
|
2358
2399
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2359
2400
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2360
2401
|
configs2.push(
|
|
2361
|
-
ignores(),
|
|
2402
|
+
ignores(options.ignores),
|
|
2362
2403
|
javascript({
|
|
2363
2404
|
isInEditor,
|
|
2364
2405
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2371,11 +2412,13 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2371
2412
|
imports({
|
|
2372
2413
|
stylistic: stylisticOptions
|
|
2373
2414
|
}),
|
|
2374
|
-
unicorn(),
|
|
2375
2415
|
command(),
|
|
2376
2416
|
// Optional plugins (installed but not enabled by default)
|
|
2377
2417
|
perfectionist()
|
|
2378
2418
|
);
|
|
2419
|
+
if (enableUnicorn) {
|
|
2420
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2421
|
+
}
|
|
2379
2422
|
if (enableVue) {
|
|
2380
2423
|
componentExts.push("vue");
|
|
2381
2424
|
}
|
|
@@ -2484,6 +2527,12 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2484
2527
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2485
2528
|
));
|
|
2486
2529
|
}
|
|
2530
|
+
configs2.push(
|
|
2531
|
+
disables()
|
|
2532
|
+
);
|
|
2533
|
+
if ("files" in options) {
|
|
2534
|
+
throw new Error('[@jun2030/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.');
|
|
2535
|
+
}
|
|
2487
2536
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2488
2537
|
if (key in options)
|
|
2489
2538
|
acc[key] = options[key];
|
|
@@ -2552,6 +2601,7 @@ export {
|
|
|
2552
2601
|
comments,
|
|
2553
2602
|
src_default as default,
|
|
2554
2603
|
defaultPluginRenaming,
|
|
2604
|
+
disables,
|
|
2555
2605
|
ensurePackages,
|
|
2556
2606
|
formatters,
|
|
2557
2607
|
getOverrides,
|