MCPcopy Create free account
hub / github.com/code-pushup/cli / executeLint

Function executeLint

packages/plugin-eslint/src/lib/runner/lint.ts:23–52  ·  view source on GitHub ↗
({
  eslintrc,
  patterns,
}: ESLintTarget)

Source from the content-addressed store, hash-verified

21}
22
23async 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
54function loadRuleOptionsPerFile(
55 eslint: ESLint,

Callers 1

lintFunction · 0.85

Calls 3

executeProcessFunction · 0.90
filePathToCliArgFunction · 0.90
toArrayFunction · 0.90

Tested by

no test coverage detected