import type { WorkerMessage , WorkerExecResult } from "./worker" ; export async function lint ( message ) { const oldArgv = process . argv ; const oldCwd = process . cwd ( ) ; try { const eslintPath = require . resolve ( "eslint/lib/cli" , { paths : [ message . cwd ] } ) ; const eslint = require ( eslintPath ) ; const argv = message . command . split ( " " ) ; process . argv = [ process . argv0 , eslintPath , ... argv . slice ( 1 ) ] ; process . chdir ( message . cwd ) ; return { code : await eslint . execute ( process . argv ) } ; } finally { process . argv = oldArgv ; process . chdir ( oldCwd ) ; } }