Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 11, 2024
1 parent 3ab8232 commit d439df2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ ${dts}`.trim()}\n`
return currentContent
}

async function parseESLint() {
if (eslintrc.filepath!.endsWith('js'))
return {} as Record<string, ESLintGlobalsPropValue>
const configStr = existsSync(eslintrc.filepath!) ? await fs.readFile(eslintrc.filepath!, 'utf-8') : ''
async function parseESLint(): Promise<Record<string, ESLintGlobalsPropValue>> {
if (!eslintrc.filepath)
return {}
if (eslintrc.filepath.match(/\.[cm]?[jt]sx?$/)) // Skip JavaScript-like files
return {}
const configStr = existsSync(eslintrc.filepath!)
? await fs.readFile(eslintrc.filepath!, 'utf-8')
: ''
const config = JSON.parse(configStr || '{ "globals": {} }')
return config.globals as Record<string, ESLintGlobalsPropValue>
return config.globals
}

async function generateESLint() {
Expand Down

0 comments on commit d439df2

Please sign in to comment.