Skip to content

Commit

Permalink
fix: Ignore unknown extensions when running ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufkandemir authored and fi3ework committed Oct 9, 2022
1 parent ff5ee39 commit 712fb31
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/vite-plugin-checker/src/checkers/eslint/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ const createDiagnostic: CreateDiagnostic<'eslint'> = (pluginConfig) => {
return userLogLevel.map((l) => map[l])
})()

const eslint = new ESLint({
const eslintOptions: ESLint.Options = {
cwd: root,
...translatedOptions,
...pluginConfig.eslint.dev?.overrideConfig,
})
}
const eslint = new ESLint(eslintOptions)

const dispatchDiagnostics = () => {
const diagnostics = filterLogLevel(manager.getDiagnostics(), logLevel)
Expand All @@ -82,11 +83,16 @@ const createDiagnostic: CreateDiagnostic<'eslint'> = (pluginConfig) => {
}

const handleFileChange = async (filePath: string, type: 'change' | 'unlink') => {
const absPath = path.resolve(root, filePath)
const isChangedFileIgnored = await eslint.isPathIgnored(filePath)
// See: https://github.com/eslint/eslint/pull/4465
const extension = path.extname(filePath)
const { extensions } = eslintOptions
const hasExtensionsConfig = Array.isArray(extensions)
if (hasExtensionsConfig && !extensions.includes(extension)) return

const isChangedFileIgnored = await eslint.isPathIgnored(filePath)
if (isChangedFileIgnored) return

const absPath = path.resolve(root, filePath)
if (type === 'unlink') {
manager.updateByFileId(absPath, [])
} else if (type === 'change') {
Expand Down

0 comments on commit 712fb31

Please sign in to comment.