@@ -14,6 +14,10 @@ export async function setupConfigGen(options: ModuleOptions, nuxt: Nuxt) {
1414 createAddonGlobals ( nuxt ) ,
1515 ]
1616
17+ nuxt . hook ( 'prepare:types' , ( { declarations } ) => {
18+ declarations . push ( '/// <reference path="./eslint-typegen.d.ts" />' )
19+ } )
20+
1721 addTemplate ( {
1822 filename : 'eslint.config.mjs' ,
1923 write : true ,
@@ -65,6 +69,11 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
6569 {
6670 from : '@nuxt/eslint-config/flat' ,
6771 name : 'defineFlatConfigs' ,
72+ } ,
73+ {
74+ from : 'eslint-typegen' ,
75+ name : 'default' ,
76+ as : 'typegen'
6877 }
6978 )
7079
@@ -88,7 +97,10 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
8897
8998 return [
9099 '// ESLint config generated by Nuxt' ,
100+ '/// <reference path="./eslint-typegen.d.ts" />' ,
101+ '' ,
91102 stringifyImports ( importLines , false ) ,
103+ '' ,
92104 'export { defineFlatConfigs }' ,
93105 '' ,
94106 `export const configs = pipe()` ,
@@ -98,7 +110,7 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
98110 `)` ,
99111 '' ,
100112 'export function withNuxt(...customs) {' ,
101- ' return configs.append(...customs)' ,
113+ ' return configs.append(...customs).onResolved(configs => typegen(configs, { dtsPath: new URL("./eslint-typegen.d.ts", import.meta.url) })) ' ,
102114 '}' ,
103115 '' ,
104116 'export default withNuxt' ,
0 commit comments