-
-
Notifications
You must be signed in to change notification settings - Fork 387
/
typegen.ts
48 lines (43 loc) · 1.07 KB
/
typegen.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
45
46
47
48
import fs from 'node:fs/promises'
import { flatConfigsToRulesDTS } from 'eslint-typegen/core'
import { builtinRules } from 'eslint/use-at-your-own-risk'
import { astro, combine, comments, formatters, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, solid, sortPackageJson, stylistic, svelte, test, toml, typescript, unicorn, unocss, vue, yaml } from '../src'
const configs = await combine(
{
plugins: {
'': {
rules: Object.fromEntries(builtinRules.entries()),
},
},
},
astro(),
comments(),
formatters(),
imports(),
javascript(),
jsdoc(),
jsonc(),
markdown(),
node(),
perfectionist(),
react(),
solid(),
sortPackageJson(),
stylistic(),
svelte(),
test(),
toml(),
typescript(),
unicorn(),
unocss(),
vue(),
yaml(),
)
const configNames = configs.map(i => i.name).filter(Boolean) as string[]
let dts = await flatConfigsToRulesDTS(configs, {
includeAugmentation: false,
})
dts = `
type ConfigNames = ${configNames.map(i => `'${i}'`).join(' | ')}
${dts}`
await fs.writeFile('src/typegen.d.ts', dts)