1
1
import {
2
2
type ClassicConfig ,
3
3
type FlatConfig ,
4
- type Linter ,
5
4
} from "@typescript-eslint/utils/ts-eslint" ;
6
5
7
6
import all from "#eslint-plugin-functional/configs/all" ;
@@ -26,59 +25,72 @@ const functional = {
26
25
meta : {
27
26
name : "eslint-plugin-functional" ,
28
27
version : __VERSION__ ,
29
- } ,
28
+ } as const ,
30
29
rules,
31
30
} satisfies Omit < FlatConfig . Plugin , "configs" > ;
32
31
33
- const createConfig = (
34
- rules : NonNullable < FlatConfig . Config [ "rules" ] > ,
35
- isLegacyConfig = false ,
36
- ) =>
37
- isLegacyConfig
38
- ? ( { plugins : [ ruleNameScope ] , rules } satisfies ClassicConfig . Config )
39
- : ( { plugins : { functional } , rules } satisfies FlatConfig . Config ) ;
32
+ const classicConfigs = {
33
+ all : { plugins : [ ruleNameScope ] , rules : all } ,
34
+ lite : { plugins : [ ruleNameScope ] , rules : lite } ,
35
+ recommended : { plugins : [ ruleNameScope ] , rules : recommended } ,
36
+ strict : { plugins : [ ruleNameScope ] , rules : strict } ,
37
+ off : { plugins : [ ruleNameScope ] , rules : off } ,
38
+ "disable-type-checked" : {
39
+ plugins : [ ruleNameScope ] ,
40
+ rules : disableTypeChecked ,
41
+ } ,
42
+ "external-vanilla-recommended" : {
43
+ plugins : [ ruleNameScope ] ,
44
+ rules : externalVanillaRecommended ,
45
+ } ,
46
+ "external-typescript-recommended" : {
47
+ plugins : [ ruleNameScope ] ,
48
+ rules : externalTypeScriptRecommended ,
49
+ } ,
50
+ currying : { plugins : [ ruleNameScope ] , rules : currying } ,
51
+ "no-exceptions" : { plugins : [ ruleNameScope ] , rules : noExceptions } ,
52
+ "no-mutations" : { plugins : [ ruleNameScope ] , rules : noMutations } ,
53
+ "no-other-paradigms" : { plugins : [ ruleNameScope ] , rules : noOtherParadigms } ,
54
+ "no-statements" : { plugins : [ ruleNameScope ] , rules : noStatements } ,
55
+ stylistic : { plugins : [ ruleNameScope ] , rules : stylistic } ,
56
+ } satisfies Record < string , ClassicConfig . Config > ;
40
57
41
- const configs = Object . fromEntries (
42
- (
43
- [
44
- [ false , "flat/" ] ,
45
- [ true , "" ] ,
46
- ] as Array < [ boolean , string ] >
47
- ) . flatMap (
48
- ( [ isLegacyConfig , prefix ] ) : Array <
49
- [ string , FlatConfig . Config | ClassicConfig . Config ]
50
- > => [
51
- [ `${ prefix } all` , createConfig ( all , isLegacyConfig ) ] ,
52
- [ `${ prefix } lite` , createConfig ( lite , isLegacyConfig ) ] ,
53
- [ `${ prefix } recommended` , createConfig ( recommended , isLegacyConfig ) ] ,
54
- [ `${ prefix } strict` , createConfig ( strict , isLegacyConfig ) ] ,
55
- [ `${ prefix } off` , createConfig ( off , isLegacyConfig ) ] ,
56
- [
57
- `${ prefix } disable-type-checked` ,
58
- createConfig ( disableTypeChecked , isLegacyConfig ) ,
59
- ] ,
60
- [
61
- `${ prefix } external-vanilla-recommended` ,
62
- createConfig ( externalVanillaRecommended , isLegacyConfig ) ,
63
- ] ,
64
- [
65
- `${ prefix } external-typescript-recommended` ,
66
- createConfig ( externalTypeScriptRecommended , isLegacyConfig ) ,
67
- ] ,
68
- [ `${ prefix } currying` , createConfig ( currying , isLegacyConfig ) ] ,
69
- [ `${ prefix } no-exceptions` , createConfig ( noExceptions , isLegacyConfig ) ] ,
70
- [ `${ prefix } no-mutations` , createConfig ( noMutations , isLegacyConfig ) ] ,
71
- [
72
- `${ prefix } no-other-paradigms` ,
73
- createConfig ( noOtherParadigms , isLegacyConfig ) ,
74
- ] ,
75
- [ `${ prefix } no-statements` , createConfig ( noStatements , isLegacyConfig ) ] ,
76
- [ `${ prefix } stylistic` , createConfig ( stylistic , isLegacyConfig ) ] ,
77
- ] ,
78
- ) ,
79
- ) satisfies Record < string , FlatConfig . Config | ClassicConfig . Config > ;
58
+ const flatConfigs = {
59
+ "flat/all" : { plugins : { functional } , rules : all } ,
60
+ "flat/lite" : { plugins : { functional } , rules : lite } ,
61
+ "flat/recommended" : { plugins : { functional } , rules : recommended } ,
62
+ "flat/strict" : { plugins : { functional } , rules : strict } ,
63
+ "flat/off" : { plugins : { functional } , rules : off } ,
64
+ "flat/disable-type-checked" : {
65
+ plugins : { functional } ,
66
+ rules : disableTypeChecked ,
67
+ } ,
68
+ "flat/external-vanilla-recommended" : {
69
+ plugins : { functional } ,
70
+ rules : externalVanillaRecommended ,
71
+ } ,
72
+ "flat/external-typescript-recommended" : {
73
+ plugins : { functional } ,
74
+ rules : externalTypeScriptRecommended ,
75
+ } ,
76
+ "flat/currying" : { plugins : { functional } , rules : currying } ,
77
+ "flat/no-exceptions" : { plugins : { functional } , rules : noExceptions } ,
78
+ "flat/no-mutations" : { plugins : { functional } , rules : noMutations } ,
79
+ "flat/no-other-paradigms" : {
80
+ plugins : { functional } ,
81
+ rules : noOtherParadigms ,
82
+ } ,
83
+ "flat/no-statements" : { plugins : { functional } , rules : noStatements } ,
84
+ "flat/stylistic" : { plugins : { functional } , rules : stylistic } ,
85
+ } satisfies Record < string , FlatConfig . Config > ;
80
86
81
87
export default {
82
88
...functional ,
83
- configs,
84
- } as Linter . Plugin ;
89
+ configs : {
90
+ ...( flatConfigs as Record < keyof typeof flatConfigs , FlatConfig . Config > ) ,
91
+ ...( classicConfigs as Record <
92
+ keyof typeof classicConfigs ,
93
+ ClassicConfig . Config
94
+ > ) ,
95
+ } as const ,
96
+ } as const ;
0 commit comments