From b41d5f6cb3f09ef7b71cad2e95451607a037b574 Mon Sep 17 00:00:00 2001 From: Byron Wall Date: Sun, 22 Nov 2026 15:17:15 -0500 Subject: [PATCH] fix(findings): explain when ESLint ignores the selected scope --- server/app/services/findings/typescript.py | 9 +++++- server/tests/test_findings.py | 36 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/server/app/services/findings/typescript.py b/server/app/services/findings/typescript.py index baea563c..f973e429 100644 --- a/server/app/services/findings/typescript.py +++ b/server/app/services/findings/typescript.py @@ -162,6 +162,9 @@ def check(self): # -- eslint ------------------------------------------------------------------ +_ESLINT_ALL_IGNORED = re.compile(r"\ball of the files matching\s+the glob pattern [^\r\n]+ are ignored\.") + + def eslint_configs(root: Path, stop: Optional[Path]) -> list[Path]: found = find_within(root, ESLINT_CONFIGS) if not found: @@ -235,7 +238,11 @@ def check(self): target = str(self.root) if self.root != cwd and cwd in self.root.parents else "." out = run_process([str(self.binary), "--format", "json", target], cwd, self.timeout) if out.returncode not in (0, 1): - raise ToolFailed(first_line(out.stderr or out.stdout) or f"exit code {out.returncode}") + # ESLint's generic banner precedes the real error, which can contain + # absolute paths. Only return fixed summaries to the Findings UI. + if any(_ESLINT_ALL_IGNORED.search(stream) for stream in (out.stderr, out.stdout)): + raise ToolFailed("all selected files are ignored; check ignore and file patterns in the ESLint config") + raise ToolFailed(f"exit code {out.returncode}; run ESLint directly for details") findings, files = parse_eslint(out.stdout or "[]", self.id) scope = str(self.root) return [f for f in findings if f.path.startswith(scope)], [f for f in files if f.startswith(scope)] diff --git a/server/tests/test_findings.py b/server/tests/test_findings.py index bd4fe19a..7ef37485 100644 --- a/server/tests/test_findings.py +++ b/server/tests/test_findings.py @@ -19,7 +19,7 @@ from app.services.findings import builtin_ts, ruff, typescript from app.services.findings.model import Finding from app.services.findings.runner import FindingsCache, collect, plan_tools, run_tools -from app.services.findings.tools import Tool, ToolFailed, run_process +from app.services.findings.tools import ProcessOutput, Tool, ToolFailed, run_process PY_SOURCE = textwrap.dedent( """\ @@ -261,6 +261,40 @@ def test_tsc_global_config_error_is_a_failure() -> None: # -- failures: never zero ------------------------------------------------------- +@pytest.mark.parametrize("stream", ["stderr", "stdout"]) +def test_eslint_ignored_files_explain_unassessed_result( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, stream: str, +) -> None: + config = tmp_path / "eslint.config.js" + tool = typescript.EslintTool(tmp_path, config, tmp_path / "eslint", tmp_path) + output = textwrap.dedent("""\ + Oops! Something went wrong! :( + + ESLint: 9.39.5 + + You are linting "/private/project/src", but all of the files matching + the glob pattern "/private/project/src" are ignored. + """) + process = ProcessOutput(2, output if stream == "stdout" else "", output if stream == "stderr" else "") + monkeypatch.setattr(typescript, "run_process", lambda *_: process) + run, checked = findings.tools.run(tool) + assert run.status == "na" and not run.ok and run.files is None and checked == [] + assert run.reason == ( + "eslint (eslint.config.js) failed: all selected files are ignored; " + "check ignore and file patterns in the ESLint config" + ) + + +def test_eslint_unknown_failure_reports_exit_without_raw_output(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + config = tmp_path / "eslint.config.js" + tool = typescript.EslintTool(tmp_path, config, tmp_path / "eslint", tmp_path) + process = ProcessOutput(2, "", "Error loading /private/project/unknown-plugin.js") + monkeypatch.setattr(typescript, "run_process", lambda *_: process) + run, checked = findings.tools.run(tool) + assert run.status == "na" and not run.ok and run.files is None and checked == [] + assert run.reason == "eslint (eslint.config.js) failed: exit code 2; run ESLint directly for details" + + class _SlowTool(Tool): def __init__(self, root: Path, timeout: float) -> None: super().__init__(id="slow", tool="slow", label="slow-lint", source="project", root=root, extensions=(".py",), timeout=timeout)