Skip to content

Commit d2b1c2d

Browse files
committedMar 27, 2024
feat: integrate with eslint-typegen
1 parent 3127d3f commit d2b1c2d

File tree

5 files changed

+57
-11
lines changed

5 files changed

+57
-11
lines changed
 

Diff for: ‎packages/eslint-config/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
"dependencies": {
3030
"@eslint/js": "^8.57.0",
3131
"@nuxt/eslint-plugin": "workspace:*",
32-
"@rushstack/eslint-patch": "^1.8.0",
32+
"@rushstack/eslint-patch": "^1.9.0",
3333
"@stylistic/eslint-plugin": "^1.7.0",
3434
"@typescript-eslint/eslint-plugin": "^7.4.0",
3535
"@typescript-eslint/parser": "^7.4.0",
36+
"eslint-flat-config-utils": "^0.1.0",
3637
"eslint-plugin-vue": "^9.24.0",
3738
"globals": "^15.0.0",
3839
"pathe": "^1.1.2",
39-
"eslint-flat-config-utils": "^0.1.0",
4040
"vue-eslint-parser": "^9.4.2"
4141
},
4242
"devDependencies": {

Diff for: ‎packages/module/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"eslint-flat-config-utils": "^0.1.0",
5252
"eslint-flat-config-viewer": "^0.1.14",
5353
"get-port-please": "^3.1.2",
54+
"eslint-typegen": "^0.1.4",
5455
"pathe": "^1.1.2",
5556
"unimport": "^3.7.1"
5657
},

Diff for: ‎packages/module/src/modules/config.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -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',

Diff for: ‎playground/eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// @ts-check
22
import withNuxt from './.nuxt/eslint.config.mjs'
33

4-
export default withNuxt()
4+
export default withNuxt({})

Diff for: ‎pnpm-lock.yaml

+40-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.