Skip to content

Commit cd966e1

Browse files
authored
fix: always regenerate .eslintrc to prevent stale entries (#574)
1 parent acd5328 commit cd966e1

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/core/ctx.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Import, InlinePreset } from 'unimport'
2-
import type { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, Options } from '../types'
2+
import type { BiomeLintrc, ESLintrc, ImportExtended, Options } from '../types'
33
import { existsSync, promises as fs } from 'node:fs'
44
import { dirname, isAbsolute, relative, resolve } from 'node:path'
55
import process from 'node:process'
@@ -164,20 +164,8 @@ ${dts}`.trim()}\n`
164164
return currentContent
165165
}
166166

167-
async function parseESLint(): Promise<Record<string, ESLintGlobalsPropValue>> {
168-
if (!eslintrc.filepath)
169-
return {}
170-
if (eslintrc.filepath.match(/\.[cm]?[jt]sx?$/)) // Skip JavaScript-like files
171-
return {}
172-
const configStr = existsSync(eslintrc.filepath!)
173-
? await fs.readFile(eslintrc.filepath!, 'utf-8')
174-
: ''
175-
const config = JSON.parse(configStr || '{ "globals": {} }')
176-
return config.globals
177-
}
178-
179167
async function generateESLint() {
180-
return generateESLintConfigs(await unimport.getImports(), eslintrc, await parseESLint())
168+
return generateESLintConfigs(await unimport.getImports(), eslintrc)
181169
}
182170

183171
async function generateBiomeLint() {

src/core/eslintrc.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { Import } from 'unimport'
2-
import type { ESLintGlobalsPropValue, ESLintrc } from '../types'
2+
import type { ESLintrc } from '../types'
33

44
export function generateESLintConfigs(
55
imports: Import[],
66
eslintrc: ESLintrc,
7-
globals: Record<string, ESLintGlobalsPropValue> = {},
87
) {
9-
const eslintConfigs: any = { globals }
8+
const eslintConfigs: any = { globals: {} }
109

1110
imports
1211
.map(i => i.as ?? i.name)

0 commit comments

Comments
 (0)