|
1 |
| -import { fileURLToPath, pathToFileURL } from 'node:url' |
| 1 | +import { fileURLToPath } from 'node:url' |
2 | 2 | import { builtinModules } from 'node:module'
|
3 | 3 | import fs from 'node:fs/promises'
|
4 | 4 | import { addTemplate, createResolver, logger } from '@nuxt/kit'
|
@@ -112,6 +112,8 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
|
112 | 112 | const importLines: Import[] = []
|
113 | 113 | const configItems: string[] = []
|
114 | 114 |
|
| 115 | + const configDir = nuxt.options.buildDir |
| 116 | + |
115 | 117 | const config: ConfigGenOptions = {
|
116 | 118 | standalone: true,
|
117 | 119 | ...typeof options.config !== 'boolean' ? options.config || {} : {},
|
@@ -156,12 +158,17 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
|
156 | 158 | configItems.push(...resolved.configs)
|
157 | 159 | }
|
158 | 160 |
|
| 161 | + function relativeWithDot(path: string) { |
| 162 | + const r = relative(configDir, path) |
| 163 | + return r.startsWith('.') ? r : './' + r |
| 164 | + } |
| 165 | + |
159 | 166 | const imports = await Promise.all(importLines.map(async (line): Promise<Import> => {
|
160 | 167 | return {
|
161 | 168 | ...line,
|
162 | 169 | from: (line.from.match(/^\w+:/) || builtinModules.includes(line.from))
|
163 | 170 | ? line.from
|
164 |
| - : pathToFileURL(await r.resolvePath(line.from)).toString(), |
| 171 | + : relativeWithDot(await r.resolvePath(line.from)), |
165 | 172 | }
|
166 | 173 | }))
|
167 | 174 |
|
|
0 commit comments