Skip to content

Commit

Permalink
fix: skip parseESlint if eslint filepath is a js file (#510)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
yy4382 and antfu authored Jul 11, 2024
1 parent f4d8066 commit 10079b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,16 @@ ${dts}`.trim()}\n`
return currentContent
}

async function parseESLint() {
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 10079b2

Please sign in to comment.