1
1
import { dirname } from 'node:path'
2
2
import fs from 'node:fs/promises'
3
- import { addTemplate } from '@nuxt/kit'
4
3
import type { Nuxt } from '@nuxt/schema'
5
4
import type { ESLintConfigGenAddon } from '../../types'
6
5
import type { ModuleOptions } from '../../module'
@@ -9,18 +8,6 @@ import { setupDevToolsIntegration } from './devtools'
9
8
import { initRootESLintConfig } from './init'
10
9
import { generateESLintConfig } from './generate'
11
10
12
- const ESLINT_CONFIG_DTS = [
13
- 'import type { FlatConfigComposer } from "eslint-flat-config-utils"' ,
14
- 'import { defineFlatConfigs } from "@nuxt/eslint-config/flat"' ,
15
- 'import type { NuxtESLintConfigOptionsResolved } from "@nuxt/eslint-config/flat"' ,
16
- '' ,
17
- 'declare const configs: FlatConfigComposer' ,
18
- 'declare const options: NuxtESLintConfigOptionsResolved' ,
19
- 'declare const withNuxt: typeof defineFlatConfigs' ,
20
- 'export default withNuxt' ,
21
- 'export { withNuxt, defineFlatConfigs, configs, options }' ,
22
- ] . join ( '\n' )
23
-
24
11
export async function setupConfigGen ( options : ModuleOptions , nuxt : Nuxt ) {
25
12
const {
26
13
autoInit = true ,
@@ -41,20 +28,13 @@ export async function setupConfigGen(options: ModuleOptions, nuxt: Nuxt) {
41
28
...defaultAddons ,
42
29
]
43
30
await nuxt . callHook ( 'eslint:config:addons' , addons )
44
- const { code, configFile } = await generateESLintConfig ( options , nuxt , addons )
31
+ const { code, codeDts , configFile } = await generateESLintConfig ( options , nuxt , addons )
45
32
await fs . mkdir ( dirname ( configFile ) , { recursive : true } )
46
33
await fs . writeFile ( configFile , code , 'utf-8' )
34
+ await fs . writeFile ( configFile . replace ( / \. m j s $ / , '.d.mts' ) , codeDts , 'utf-8' )
47
35
_configFile = configFile
48
36
}
49
37
50
- addTemplate ( {
51
- filename : 'eslint.config.d.mts' ,
52
- write : true ,
53
- getContents ( ) {
54
- return ESLINT_CONFIG_DTS
55
- } ,
56
- } )
57
-
58
38
setupDevToolsIntegration ( options , nuxt )
59
39
60
40
await writeConfigFile ( )
0 commit comments