-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathindex.ts
44 lines (39 loc) · 1.1 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { TSESLint } from '@typescript-eslint/utils';
import configs from './configs';
import rules from './rules';
import { SupportedTestingFramework } from './utils';
// we can't natively import package.json as tsc will copy it into dist/
const {
name: packageName,
version: packageVersion,
// eslint-disable-next-line @typescript-eslint/no-require-imports
} = require('../package.json') as { name: string; version: string };
const plugin = {
meta: {
name: packageName,
version: packageVersion,
},
// ugly cast for now to keep TypeScript happy since
// we don't have types for flat config yet
configs: {} as Record<
SupportedTestingFramework | `flat/${SupportedTestingFramework}`,
TSESLint.SharedConfig.RulesRecord
>,
rules,
};
plugin.configs = {
...configs,
...(Object.fromEntries(
Object.entries(configs).map(([framework, config]) => [
`flat/${framework}`,
{
plugins: { 'testing-library': plugin },
rules: config.rules,
},
])
) as unknown as Record<
`flat/${SupportedTestingFramework}`,
TSESLint.SharedConfig.RulesRecord & { plugins: unknown }
>),
};
export = plugin;