File tree 3 files changed +34
-3
lines changed
3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 8
8
SupportedTestingFramework ,
9
9
} from '../utils' ;
10
10
11
- export type LinterConfigRules = Record < string , TSESLint . Linter . RuleEntry > ;
11
+ export type LinterConfigRules = Pick < Required < TSESLint . Linter . Config > , 'rules' > ;
12
12
13
13
const configsDir = __dirname ;
14
14
Original file line number Diff line number Diff line change
1
+ import type { TSESLint } from '@typescript-eslint/utils' ;
2
+
1
3
import configs from './configs' ;
2
4
import rules from './rules' ;
5
+ import { SupportedTestingFramework } from './utils' ;
3
6
4
7
// we can't natively import package.json as tsc will copy it into dist/
5
8
const {
@@ -8,11 +11,34 @@ const {
8
11
// eslint-disable-next-line @typescript-eslint/no-var-requires
9
12
} = require ( '../package.json' ) as { name : string ; version : string } ;
10
13
11
- export = {
14
+ const plugin = {
12
15
meta : {
13
16
name : packageName ,
14
17
version : packageVersion ,
15
18
} ,
16
- configs,
19
+ // ugly cast for now to keep TypeScript happy since
20
+ // we don't have types for flat config yet
21
+ configs : { } as Record <
22
+ SupportedTestingFramework | `flat/${SupportedTestingFramework } `,
23
+ Pick < Required < TSESLint . Linter . Config > , 'rules' >
24
+ > ,
17
25
rules,
18
26
} ;
27
+
28
+ plugin . configs = {
29
+ ...configs ,
30
+ ...( Object . fromEntries (
31
+ Object . entries ( configs ) . map ( ( [ framework , config ] ) => [
32
+ `flat/${ framework } ` ,
33
+ {
34
+ plugins : { 'testing-library' : plugin } ,
35
+ rules : config . rules ,
36
+ } ,
37
+ ] )
38
+ ) as Record <
39
+ `flat/${SupportedTestingFramework } `,
40
+ Pick < Required < TSESLint . Linter . Config > , 'rules' > & { plugins : unknown }
41
+ > ) ,
42
+ } ;
43
+
44
+ export = plugin ;
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ it('should export configs that refer to actual rules', () => {
52
52
'react' ,
53
53
'vue' ,
54
54
'marko' ,
55
+ 'flat/dom' ,
56
+ 'flat/angular' ,
57
+ 'flat/react' ,
58
+ 'flat/vue' ,
59
+ 'flat/marko' ,
55
60
] ) ;
56
61
const allConfigRules = Object . values ( allConfigs )
57
62
. map ( ( config ) => Object . keys ( config . rules ) )
You can’t perform that action at this time.
0 commit comments