Skip to content

Commit

Permalink
fix: cache outdate.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Mar 5, 2023
1 parent f8f3a44 commit a83ee61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { exec } from 'node:child_process'
import { ESLint, Linter } from 'eslint'
import path from 'node:path'
import { type ExtensionContext } from 'vscode'
import { existFile } from './utils'

type PKG_MANAGERS = { agent: 'pnpm' | 'npm' | 'yarn', path: string }
const resolveESLintPath = () => Files.resolve('eslint', workspacePath, workspacePath, message => { /**/ })
Expand Down Expand Up @@ -39,13 +40,12 @@ const resolveESLintPath = () => Files.resolve('eslint', workspacePath, workspace
})

export const getESLintInstance = async (options: ESLint.Options = {}, context: ExtensionContext) => {

let eslintPath = context.workspaceState.get<string>('eslintPath')
if (!eslintPath) {
if (eslintPath && await existFile(eslintPath)) {
log('ESLint path found from storage')
} else {
eslintPath = await resolveESLintPath()
void context.workspaceState.update('eslintPath', eslintPath)
} else {
log('ESLint path found from storage.')
}

const eslintModule = await import(path.join(eslintPath)) as { ESLint: typeof ESLint }
Expand All @@ -54,7 +54,7 @@ export const getESLintInstance = async (options: ESLint.Options = {}, context: E
return new eslintModule.ESLint(options)
}

export const getESLintLinterInstance = async (options?: ESLint.Options) => {
export const getESLintLinterInstance = async () => {
const eslintPath = await resolveESLintPath()
const eslintModule = await import(path.join(eslintPath)) as { Linter: typeof Linter }

Expand Down

0 comments on commit a83ee61

Please sign in to comment.