11import type { ESLint , Linter } from 'eslint' ;
22import { platform } from 'node:os' ;
3- import { join } from 'node:path' ;
43import {
54 distinct ,
65 executeProcess ,
@@ -11,21 +10,20 @@ import type { ESLintTarget } from '../config.js';
1110import { setupESLint } from '../setup.js' ;
1211import type { LinterOutput , RuleOptionsPerFile } from './types.js' ;
1312
14- export async function lint (
15- { eslintrc, patterns } : ESLintTarget ,
16- opt ?: { cwd ?: string } ,
17- ) : Promise < LinterOutput > {
18- const results = await executeLint ( { eslintrc, patterns } , opt ) ;
13+ export async function lint ( {
14+ eslintrc,
15+ patterns ,
16+ } : ESLintTarget ) : Promise < LinterOutput > {
17+ const results = await executeLint ( { eslintrc, patterns } ) ;
1918 const eslint = await setupESLint ( eslintrc ) ;
2019 const ruleOptionsPerFile = await loadRuleOptionsPerFile ( eslint , results ) ;
2120 return { results, ruleOptionsPerFile } ;
2221}
2322
24- async function executeLint (
25- { eslintrc, patterns } : ESLintTarget ,
26- opt ?: { cwd ?: string } ,
27- ) : Promise < ESLint . LintResult [ ] > {
28- const { cwd = process . cwd ( ) } = opt ?? { } ;
23+ async function executeLint ( {
24+ eslintrc,
25+ patterns,
26+ } : ESLintTarget ) : Promise < ESLint . LintResult [ ] > {
2927 // running as CLI because ESLint#lintFiles() runs out of memory
3028 const { stdout } = await executeProcess ( {
3129 command : 'npx' ,
@@ -35,14 +33,13 @@ async function executeLint(
3533 ...( typeof eslintrc === 'object' ? [ '--no-eslintrc' ] : [ ] ) ,
3634 '--no-error-on-unmatched-pattern' ,
3735 '--format=json' ,
38- `--output-file=${ join ( cwd , '.eslint-results.json' ) } ` ,
3936 ...toArray ( patterns ) . map ( pattern =>
4037 // globs need to be escaped on Unix
4138 platform ( ) === 'win32' ? pattern : `'${ pattern } '` ,
4239 ) ,
4340 ] ,
4441 ignoreExitCode : true ,
45- cwd,
42+ cwd : process . cwd ( ) ,
4643 } ) ;
4744
4845 return JSON . parse ( stdout ) as ESLint . LintResult [ ] ;
0 commit comments