({
eslintrc,
patterns,
}: ESLintTarget)
| 21 | } |
| 22 | |
| 23 | async function executeLint({ |
| 24 | eslintrc, |
| 25 | patterns, |
| 26 | }: ESLintTarget): Promise<ESLint.LintResult[]> { |
| 27 | // running as CLI because ESLint#lintFiles() runs out of memory |
| 28 | const { stdout, stderr, code } = await executeProcess({ |
| 29 | command: 'npx', |
| 30 | args: [ |
| 31 | 'eslint', |
| 32 | ...(eslintrc ? [`--config=${filePathToCliArg(eslintrc)}`] : []), |
| 33 | ...(typeof eslintrc === 'object' ? ['--no-eslintrc'] : []), |
| 34 | '--no-error-on-unmatched-pattern', |
| 35 | '--format=json', |
| 36 | ...toArray(patterns).map(pattern => |
| 37 | // globs need to be escaped on Unix |
| 38 | platform() === 'win32' ? pattern : `'${pattern}'`, |
| 39 | ), |
| 40 | ], |
| 41 | ignoreExitCode: true, |
| 42 | cwd: process.cwd(), |
| 43 | }); |
| 44 | |
| 45 | if (!stdout.trim()) { |
| 46 | throw new Error( |
| 47 | `ESLint produced empty output. Exit code: ${code}, STDERR: ${stderr}`, |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | return JSON.parse(stdout) as ESLint.LintResult[]; |
| 52 | } |
| 53 | |
| 54 | function loadRuleOptionsPerFile( |
| 55 | eslint: ESLint, |
no test coverage detected