Skip to content

Commit 3db86dc

Browse files
committed
fix: add regex for eslint report
1 parent 690ba8e commit 3db86dc

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

packages/plugin-eslint/src/lib/runner/lint.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import type { ESLintTarget } from '../config.js';
1313
import { setupESLint } from '../setup.js';
1414
import type { LinterOutput, RuleOptionsPerFile } from './types.js';
1515

16+
/**
17+
* Regex pattern to match ESLint report filename format with OS-agnostic path separators.
18+
* Matches: eslint-report.json or eslint-report-{number}.json
19+
* Handles both forward slashes (/) and backslashes (\) for cross-platform compatibility
20+
*/
21+
export const ESLINT_REPORT_FILENAME_PATTERN =
22+
/--output-file="\.code-pushup[/\\]eslint[/\\]eslint-report(?:-\d+)?\.json"/; // eslint-disable-line unicorn/better-regex
23+
1624
export async function lint({
1725
eslintrc,
1826
patterns,

packages/plugin-eslint/src/lib/runner/lint.unit.test.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@ import { ESLint, type Linter } from 'eslint';
22
import { expect } from 'vitest';
33
import { executeProcess } from '@code-pushup/utils';
44
import type { ESLintPluginConfig } from '../config.js';
5-
import { lint } from './lint.js';
6-
7-
/**
8-
* Regex pattern to match ESLint report filename format.
9-
* Matches: eslint-report.json or eslint-report-{number}.json
10-
* - No number: eslint-report.json (no dash)
11-
* - With number: eslint-report-123.json (with dash and digits)
12-
*/
13-
const ESLINT_REPORT_FILENAME_PATTERN =
14-
/--output-file="\.code-pushup\/eslint\/eslint-report(?:-\d+)?\.json"/;
5+
import { ESLINT_REPORT_FILENAME_PATTERN, lint } from './lint.js';
156

167
class MockESLint {
178
calculateConfigForFile = vi.fn().mockImplementation(

0 commit comments

Comments
 (0)