@2030/eslint-config 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/cli.cjs +134 -133
- package/dist/cli.js +134 -133
- package/dist/index.cjs +233 -180
- package/dist/index.d.cts +854 -275
- package/dist/index.d.ts +854 -275
- package/dist/index.js +242 -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,7 @@ async function javascript(options = {}) {
|
|
|
843
891
|
"prefer-rest-params": "error",
|
|
844
892
|
"prefer-spread": "error",
|
|
845
893
|
"prefer-template": "error",
|
|
846
|
-
"
|
|
847
|
-
"error",
|
|
848
|
-
{
|
|
849
|
-
allowSeparatedGroups: false,
|
|
850
|
-
ignoreCase: false,
|
|
851
|
-
ignoreDeclarationSort: true,
|
|
852
|
-
ignoreMemberSort: false,
|
|
853
|
-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
|
|
854
|
-
}
|
|
855
|
-
],
|
|
894
|
+
"style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
856
895
|
"symbol-description": "error",
|
|
857
896
|
"unicode-bom": ["error", "never"],
|
|
858
897
|
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
@@ -872,13 +911,6 @@ async function javascript(options = {}) {
|
|
|
872
911
|
"yoda": ["error", "never"],
|
|
873
912
|
...overrides
|
|
874
913
|
}
|
|
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
914
|
}
|
|
883
915
|
];
|
|
884
916
|
}
|
|
@@ -919,23 +951,6 @@ async function jsdoc(options = {}) {
|
|
|
919
951
|
];
|
|
920
952
|
}
|
|
921
953
|
|
|
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
954
|
// src/configs/jsonc.ts
|
|
940
955
|
async function jsonc(options = {}) {
|
|
941
956
|
const {
|
|
@@ -1011,6 +1026,23 @@ async function jsonc(options = {}) {
|
|
|
1011
1026
|
];
|
|
1012
1027
|
}
|
|
1013
1028
|
|
|
1029
|
+
// src/configs/jsx.ts
|
|
1030
|
+
async function jsx() {
|
|
1031
|
+
return [
|
|
1032
|
+
{
|
|
1033
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
1034
|
+
languageOptions: {
|
|
1035
|
+
parserOptions: {
|
|
1036
|
+
ecmaFeatures: {
|
|
1037
|
+
jsx: true
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
name: "jun/jsx/setup"
|
|
1042
|
+
}
|
|
1043
|
+
];
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1014
1046
|
// src/configs/markdown.ts
|
|
1015
1047
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
1016
1048
|
async function markdown(options = {}) {
|
|
@@ -1019,7 +1051,7 @@ async function markdown(options = {}) {
|
|
|
1019
1051
|
files = [GLOB_MARKDOWN],
|
|
1020
1052
|
overrides = {}
|
|
1021
1053
|
} = options;
|
|
1022
|
-
const markdown2 = await interopDefault(import("eslint
|
|
1054
|
+
const markdown2 = await interopDefault(import("@eslint/markdown"));
|
|
1023
1055
|
return [
|
|
1024
1056
|
{
|
|
1025
1057
|
name: "jun/markdown/setup",
|
|
@@ -1061,6 +1093,7 @@ async function markdown(options = {}) {
|
|
|
1061
1093
|
name: "jun/markdown/disables",
|
|
1062
1094
|
rules: {
|
|
1063
1095
|
"import/newline-after-import": "off",
|
|
1096
|
+
"jun/no-top-level-await": "off",
|
|
1064
1097
|
"no-alert": "off",
|
|
1065
1098
|
"no-console": "off",
|
|
1066
1099
|
"no-labels": "off",
|
|
@@ -1074,13 +1107,13 @@ async function markdown(options = {}) {
|
|
|
1074
1107
|
"style/comma-dangle": "off",
|
|
1075
1108
|
"style/eol-last": "off",
|
|
1076
1109
|
"ts/consistent-type-imports": "off",
|
|
1110
|
+
"ts/explicit-function-return-type": "off",
|
|
1077
1111
|
"ts/no-namespace": "off",
|
|
1078
1112
|
"ts/no-redeclare": "off",
|
|
1079
1113
|
"ts/no-require-imports": "off",
|
|
1080
1114
|
"ts/no-unused-expressions": "off",
|
|
1081
1115
|
"ts/no-unused-vars": "off",
|
|
1082
1116
|
"ts/no-use-before-define": "off",
|
|
1083
|
-
"ts/no-var-requires": "off",
|
|
1084
1117
|
"unicode-bom": "off",
|
|
1085
1118
|
"unused-imports/no-unused-imports": "off",
|
|
1086
1119
|
"unused-imports/no-unused-vars": "off",
|
|
@@ -1118,7 +1151,28 @@ async function perfectionist() {
|
|
|
1118
1151
|
{
|
|
1119
1152
|
name: "jun/perfectionist/setup",
|
|
1120
1153
|
plugins: {
|
|
1121
|
-
perfectionist:
|
|
1154
|
+
perfectionist: default5
|
|
1155
|
+
},
|
|
1156
|
+
rules: {
|
|
1157
|
+
"perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
|
|
1158
|
+
"perfectionist/sort-imports": ["error", {
|
|
1159
|
+
groups: [
|
|
1160
|
+
"type",
|
|
1161
|
+
["parent-type", "sibling-type", "index-type"],
|
|
1162
|
+
"builtin",
|
|
1163
|
+
"external",
|
|
1164
|
+
["internal", "internal-type"],
|
|
1165
|
+
["parent", "sibling", "index"],
|
|
1166
|
+
"side-effect",
|
|
1167
|
+
"object",
|
|
1168
|
+
"unknown"
|
|
1169
|
+
],
|
|
1170
|
+
newlinesBetween: "ignore",
|
|
1171
|
+
order: "asc",
|
|
1172
|
+
type: "natural"
|
|
1173
|
+
}],
|
|
1174
|
+
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
1175
|
+
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
1122
1176
|
}
|
|
1123
1177
|
}
|
|
1124
1178
|
];
|
|
@@ -1213,6 +1267,13 @@ async function react(options = {}) {
|
|
|
1213
1267
|
allowConstantExport: isAllowConstantExport,
|
|
1214
1268
|
allowExportNames: [
|
|
1215
1269
|
...isUsingNext ? [
|
|
1270
|
+
"dynamic",
|
|
1271
|
+
"dynamicParams",
|
|
1272
|
+
"revalidate",
|
|
1273
|
+
"fetchCache",
|
|
1274
|
+
"runtime",
|
|
1275
|
+
"preferredRegion",
|
|
1276
|
+
"maxDuration",
|
|
1216
1277
|
"config",
|
|
1217
1278
|
"generateStaticParams",
|
|
1218
1279
|
"metadata",
|
|
@@ -1277,6 +1338,31 @@ async function react(options = {}) {
|
|
|
1277
1338
|
];
|
|
1278
1339
|
}
|
|
1279
1340
|
|
|
1341
|
+
// src/configs/regexp.ts
|
|
1342
|
+
import { configs } from "eslint-plugin-regexp";
|
|
1343
|
+
async function regexp(options = {}) {
|
|
1344
|
+
const config = configs["flat/recommended"];
|
|
1345
|
+
const rules = {
|
|
1346
|
+
...config.rules
|
|
1347
|
+
};
|
|
1348
|
+
if (options.level === "warn") {
|
|
1349
|
+
for (const key in rules) {
|
|
1350
|
+
if (rules[key] === "error")
|
|
1351
|
+
rules[key] = "warn";
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
return [
|
|
1355
|
+
{
|
|
1356
|
+
...config,
|
|
1357
|
+
name: "jun/regexp/rules",
|
|
1358
|
+
rules: {
|
|
1359
|
+
...rules,
|
|
1360
|
+
...options.overrides
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
];
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1280
1366
|
// src/configs/solid.ts
|
|
1281
1367
|
async function solid(options = {}) {
|
|
1282
1368
|
const {
|
|
@@ -1717,14 +1803,19 @@ async function test(options = {}) {
|
|
|
1717
1803
|
files,
|
|
1718
1804
|
name: "jun/test/rules",
|
|
1719
1805
|
rules: {
|
|
1720
|
-
"node/prefer-global/process": "off",
|
|
1721
1806
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1722
1807
|
"test/no-identical-title": "error",
|
|
1723
1808
|
"test/no-import-node-test": "error",
|
|
1724
1809
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1725
1810
|
"test/prefer-hooks-in-order": "error",
|
|
1726
1811
|
"test/prefer-lowercase-title": "error",
|
|
1727
|
-
|
|
1812
|
+
// Disables
|
|
1813
|
+
...{
|
|
1814
|
+
"jun/no-top-level-await": "off",
|
|
1815
|
+
"no-unused-expressions": "off",
|
|
1816
|
+
"node/prefer-global/process": "off",
|
|
1817
|
+
"ts/explicit-function-return-type": "off"
|
|
1818
|
+
},
|
|
1728
1819
|
...overrides
|
|
1729
1820
|
}
|
|
1730
1821
|
}
|
|
@@ -1816,6 +1907,7 @@ async function typescript(options = {}) {
|
|
|
1816
1907
|
"dot-notation": "off",
|
|
1817
1908
|
"no-implied-eval": "off",
|
|
1818
1909
|
"ts/await-thenable": "error",
|
|
1910
|
+
"ts/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
1819
1911
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1820
1912
|
"ts/no-floating-promises": "error",
|
|
1821
1913
|
"ts/no-for-in-array": "error",
|
|
@@ -1869,7 +1961,7 @@ async function typescript(options = {}) {
|
|
|
1869
1961
|
// Install the plugins without globs, so they can be configured separately.
|
|
1870
1962
|
name: "jun/typescript/setup",
|
|
1871
1963
|
plugins: {
|
|
1872
|
-
jun:
|
|
1964
|
+
jun: default3,
|
|
1873
1965
|
ts: pluginTs
|
|
1874
1966
|
}
|
|
1875
1967
|
},
|
|
@@ -1893,7 +1985,6 @@ async function typescript(options = {}) {
|
|
|
1893
1985
|
{ "@typescript-eslint": "ts" }
|
|
1894
1986
|
),
|
|
1895
1987
|
"no-dupe-class-members": "off",
|
|
1896
|
-
"no-loss-of-precision": "off",
|
|
1897
1988
|
"no-redeclare": "off",
|
|
1898
1989
|
"no-use-before-define": "off",
|
|
1899
1990
|
"no-useless-constructor": "off",
|
|
@@ -1912,10 +2003,14 @@ async function typescript(options = {}) {
|
|
|
1912
2003
|
"ts/no-extraneous-class": "off",
|
|
1913
2004
|
"ts/no-import-type-side-effects": "error",
|
|
1914
2005
|
"ts/no-invalid-void-type": "off",
|
|
1915
|
-
"ts/no-loss-of-precision": "error",
|
|
1916
2006
|
"ts/no-non-null-assertion": "off",
|
|
1917
|
-
"ts/no-redeclare": "error",
|
|
2007
|
+
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1918
2008
|
"ts/no-require-imports": "error",
|
|
2009
|
+
"ts/no-unused-expressions": ["error", {
|
|
2010
|
+
allowShortCircuit: true,
|
|
2011
|
+
allowTaggedTemplates: true,
|
|
2012
|
+
allowTernary: true
|
|
2013
|
+
}],
|
|
1919
2014
|
"ts/no-unused-vars": "off",
|
|
1920
2015
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1921
2016
|
"ts/no-useless-constructor": "off",
|
|
@@ -1940,70 +2035,36 @@ async function typescript(options = {}) {
|
|
|
1940
2035
|
...typeAwareRules,
|
|
1941
2036
|
...overridesTypeAware
|
|
1942
2037
|
}
|
|
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
|
-
}
|
|
2038
|
+
}] : []
|
|
1969
2039
|
];
|
|
1970
2040
|
}
|
|
1971
2041
|
|
|
1972
2042
|
// src/configs/unicorn.ts
|
|
1973
|
-
async function unicorn() {
|
|
2043
|
+
async function unicorn(options = {}) {
|
|
1974
2044
|
return [
|
|
1975
2045
|
{
|
|
1976
2046
|
name: "jun/unicorn/rules",
|
|
1977
2047
|
plugins: {
|
|
1978
|
-
unicorn:
|
|
2048
|
+
unicorn: default6
|
|
1979
2049
|
},
|
|
1980
2050
|
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"
|
|
2051
|
+
...options.allRecommended ? default6.configs["flat/recommended"].rules : {
|
|
2052
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
2053
|
+
"unicorn/error-message": "error",
|
|
2054
|
+
"unicorn/escape-case": "error",
|
|
2055
|
+
"unicorn/new-for-builtins": "error",
|
|
2056
|
+
"unicorn/no-instanceof-array": "error",
|
|
2057
|
+
"unicorn/no-new-array": "error",
|
|
2058
|
+
"unicorn/no-new-buffer": "error",
|
|
2059
|
+
"unicorn/number-literal-case": "error",
|
|
2060
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
2061
|
+
"unicorn/prefer-includes": "error",
|
|
2062
|
+
"unicorn/prefer-node-protocol": "error",
|
|
2063
|
+
"unicorn/prefer-number-properties": "error",
|
|
2064
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2065
|
+
"unicorn/prefer-type-error": "error",
|
|
2066
|
+
"unicorn/throw-new-error": "error"
|
|
2067
|
+
}
|
|
2007
2068
|
}
|
|
2008
2069
|
}
|
|
2009
2070
|
];
|
|
@@ -2127,7 +2188,9 @@ async function vue(options = {}) {
|
|
|
2127
2188
|
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
2128
2189
|
...pluginVue.configs["vue3-recommended"].rules
|
|
2129
2190
|
},
|
|
2191
|
+
"jun/no-top-level-await": "off",
|
|
2130
2192
|
"node/prefer-global/process": "off",
|
|
2193
|
+
"ts/explicit-function-return-type": "off",
|
|
2131
2194
|
"vue/block-order": ["error", {
|
|
2132
2195
|
order: ["script", "template", "style"]
|
|
2133
2196
|
}],
|
|
@@ -2185,7 +2248,7 @@ async function vue(options = {}) {
|
|
|
2185
2248
|
multiline: "always",
|
|
2186
2249
|
singleline: "always"
|
|
2187
2250
|
}],
|
|
2188
|
-
"vue/brace-style": ["error", "
|
|
2251
|
+
"vue/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
2189
2252
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
2190
2253
|
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
2191
2254
|
"vue/comma-style": ["error", "last"],
|
|
@@ -2268,36 +2331,9 @@ async function yaml(options = {}) {
|
|
|
2268
2331
|
];
|
|
2269
2332
|
}
|
|
2270
2333
|
|
|
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
2334
|
// src/factory.ts
|
|
2297
2335
|
var flatConfigProps = [
|
|
2298
2336
|
"name",
|
|
2299
|
-
"files",
|
|
2300
|
-
"ignores",
|
|
2301
2337
|
"languageOptions",
|
|
2302
2338
|
"linterOptions",
|
|
2303
2339
|
"processor",
|
|
@@ -2335,6 +2371,7 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2335
2371
|
solid: enableSolid = false,
|
|
2336
2372
|
svelte: enableSvelte = false,
|
|
2337
2373
|
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
2374
|
+
unicorn: enableUnicorn = true,
|
|
2338
2375
|
unocss: enableUnoCSS = false,
|
|
2339
2376
|
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
2340
2377
|
} = options;
|
|
@@ -2350,15 +2387,21 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2350
2387
|
const configs2 = [];
|
|
2351
2388
|
if (enableGitignore) {
|
|
2352
2389
|
if (typeof enableGitignore !== "boolean") {
|
|
2353
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(
|
|
2390
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2391
|
+
name: "jun/gitignore",
|
|
2392
|
+
...enableGitignore
|
|
2393
|
+
})]));
|
|
2354
2394
|
} else {
|
|
2355
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2395
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2396
|
+
name: "jun/gitignore",
|
|
2397
|
+
strict: false
|
|
2398
|
+
})]));
|
|
2356
2399
|
}
|
|
2357
2400
|
}
|
|
2358
2401
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2359
2402
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2360
2403
|
configs2.push(
|
|
2361
|
-
ignores(),
|
|
2404
|
+
ignores(options.ignores),
|
|
2362
2405
|
javascript({
|
|
2363
2406
|
isInEditor,
|
|
2364
2407
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2371,11 +2414,13 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2371
2414
|
imports({
|
|
2372
2415
|
stylistic: stylisticOptions
|
|
2373
2416
|
}),
|
|
2374
|
-
unicorn(),
|
|
2375
2417
|
command(),
|
|
2376
2418
|
// Optional plugins (installed but not enabled by default)
|
|
2377
2419
|
perfectionist()
|
|
2378
2420
|
);
|
|
2421
|
+
if (enableUnicorn) {
|
|
2422
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2423
|
+
}
|
|
2379
2424
|
if (enableVue) {
|
|
2380
2425
|
componentExts.push("vue");
|
|
2381
2426
|
}
|
|
@@ -2484,6 +2529,12 @@ function jun(options = {}, ...userConfigs) {
|
|
|
2484
2529
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2485
2530
|
));
|
|
2486
2531
|
}
|
|
2532
|
+
configs2.push(
|
|
2533
|
+
disables()
|
|
2534
|
+
);
|
|
2535
|
+
if ("files" in options) {
|
|
2536
|
+
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.');
|
|
2537
|
+
}
|
|
2487
2538
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2488
2539
|
if (key in options)
|
|
2489
2540
|
acc[key] = options[key];
|
|
@@ -2552,6 +2603,7 @@ export {
|
|
|
2552
2603
|
comments,
|
|
2553
2604
|
src_default as default,
|
|
2554
2605
|
defaultPluginRenaming,
|
|
2606
|
+
disables,
|
|
2555
2607
|
ensurePackages,
|
|
2556
2608
|
formatters,
|
|
2557
2609
|
getOverrides,
|