1111 * provides ESLint-compatible linting with significantly better performance.
1212 */
1313
14+ import { existsSync } from 'node:fs' ;
1415import { dirname , join } from 'node:path' ;
1516import { relative } from 'node:path/win32' ;
1617import { fileURLToPath } from 'node:url' ;
@@ -33,22 +34,28 @@ export async function lint(): Promise<{
3334} > {
3435 // Resolve the oxlint binary directly (it's a native executable)
3536 const binPath = resolve ( 'oxlint/bin/oxlint' ) ;
36- const oxlintTsgolintPath = join (
37- dirname ( fileURLToPath ( import . meta. url ) ) ,
38- '..' ,
39- 'node_modules' ,
40- '.bin' ,
41- `tsgolint${ process . platform === 'win32' ? '.cmd' : '' } ` ,
42- ) ;
37+ let oxlintTsgolintPath = resolve ( 'oxlint-tsgolint/bin/tsgolint' ) ;
38+ if ( process . platform === 'win32' ) {
39+ // If on Windows, resolve the tsgolint binary from the local node_modules
40+ oxlintTsgolintPath = join (
41+ dirname ( fileURLToPath ( import . meta. url ) ) ,
42+ '..' ,
43+ 'node_modules' ,
44+ '.bin' ,
45+ 'tsgolint.cmd' ,
46+ ) ;
47+ if ( ! existsSync ( oxlintTsgolintPath ) ) {
48+ // Fallback to the cwd node_modules
49+ oxlintTsgolintPath = join ( process . cwd ( ) , 'node_modules' , '.bin' , 'tsgolint.cmd' ) ;
50+ }
51+ oxlintTsgolintPath = `.\\${ relative ( process . cwd ( ) , oxlintTsgolintPath ) } ` ;
52+ }
4353 const result = {
4454 binPath,
4555 // TODO: provide envs inference API
4656 envs : {
4757 ...DEFAULT_ENVS ,
48- OXLINT_TSGOLINT_PATH :
49- process . platform !== 'win32'
50- ? oxlintTsgolintPath
51- : `.\\${ relative ( process . cwd ( ) , oxlintTsgolintPath ) } ` ,
58+ OXLINT_TSGOLINT_PATH : oxlintTsgolintPath ,
5259 } ,
5360 } ;
5461 return result ;
0 commit comments