Skip to content

[eslint-miner] eslint-factory: add no-empty-catch-block rule - #52681

Open
github-actions[bot] wants to merge 3 commits into
mainfrom
eslint-miner/no-empty-catch-block-20260814-d2323b537de1d5e7
Open

[eslint-miner] eslint-factory: add no-empty-catch-block rule#52681
github-actions[bot] wants to merge 3 commits into
mainfrom
eslint-miner/no-empty-catch-block-20260814-d2323b537de1d5e7

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Daily ESLint Miner run for github/gh-aw. Adds one net-new custom rule: no-empty-catch-block.

Evidence

Scanned actions/setup/js/**/*.cjs for empty catch {} / catch (err) {} blocks that swallow errors with no logging, fallback value, or explanatory comment. Found 3 real occurrences:

  • fuzz_template_substitution_harness.cjs (cleanup-on-error path, no log)
  • load_experiment_state_from_repo.cjs (silent fallback parsing state file)
  • pick_experiment.cjs (silent fallback parsing experiment state JSON)

These hide real failures (corrupted state files, cleanup errors) that are otherwise invisible in CI logs.

Rule design

  • Flags CatchClause nodes whose body has zero statements.
  • Allows empty catch blocks that contain a comment documenting the intentional no-op (e.g. catch { /* best-effort cleanup, ignore */ }), avoiding false positives on already-documented intentional swallows.
  • Low false-positive risk: purely structural (empty block + no comment), no heuristics on variable names or call patterns.

Validation

  • cd eslint-factory && npm install — OK
  • cd eslint-factory && npm run build — OK
  • cd eslint-factory && npm test — new rule's 3 tests pass; 1 pre-existing unrelated failure in require-fs-io-try-catch.test.ts (not touched by this change)
  • cd eslint-factory && npm run lint:setup-js — new rule fires exactly 3 times, matching the 3 occurrences found during manual scanning; no other files triggered it (no false positives observed)

Scope

  • eslint-factory/src/rules/no-empty-catch-block.ts (new rule)
  • eslint-factory/src/rules/no-empty-catch-block.test.ts (new tests)
  • eslint-factory/src/index.ts (registration)
  • eslint-factory/eslint.config.cjs (enable as warn)

No changes outside eslint-factory; no fixes applied to actions/setup/js source files themselves (out of scope for rule-authoring PRs — follow-up fix PRs can address the 3 flagged sites).

Generated by ESLint Miner · auto · 140.6 AIC · ⌖ 6.47 AIC · ⊞ 6.3K ·

  • expires on Aug 21, 2026, 1:14 AM UTC-08:00

Run: https://github.com/github/gh-aw/actions/runs/31795158705> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.47 AIC · ⌖ 7.2 AIC · ⊞ 8.5K ·

Comment /souschef to run again

Adds a new custom ESLint rule that flags empty catch blocks
(`catch {}` / `catch (err) {}`) in actions/setup/js scripts.
An empty catch silently swallows the original error with no
logging, fallback assignment, or explanatory comment, making
failures (corrupted state files, cleanup errors) hard to diagnose
from CI logs.

The rule allows catch blocks that contain a comment documenting
the intentional no-op, keeping false positives at zero.

Scanning actions/setup/js confirmed 3 real occurrences with this
exact pattern (fuzz_template_substitution_harness.cjs,
load_experiment_state_from_repo.cjs, pick_experiment.cjs), and
lint:setup-js now reports exactly those 3 with no other matches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation cookie Issue Monster Loves Cookies! eslint labels Aug 14, 2026
@pelikhan
pelikhan marked this pull request as ready for review August 14, 2026 11:02
Copilot AI balanced review requested due to automatic review settings August 14, 2026 11:02
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Ponytail Reviewer completed successfully!

Reviewed PR #52681 (eslint-factory: new no-empty-catch-block rule) against the ponytail-review skill. The rule is ~38 lines with a single structural check (empty catch body + no comment), no speculative options, no unused abstractions, and the test file is proportionate. Lean already. Ship.

Generated by Ponytail Reviewer for #52681

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (0 additions detected).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 4.16 AIC · ⌖ 7.23 AIC · ⊞ 4K
Comment /review to run again

// A comment inside the (otherwise empty) braces documents intent, e.g.:
// } catch { /* best-effort cleanup, ignore */ }
const commentsInside = sourceCode.getCommentsInside(node.body);
if (commentsInside.length > 0) return;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule is too permissive: any comment inside an otherwise empty catch suppresses the warning, so catch { /* TODO */ } or a stale copy-pasted comment now bypasses the check while still swallowing the error with no logging or fallback. That undercuts the rule’s stated safety goal and will miss exactly the failures this PR is trying to surface.

💡 Tighten the exception instead of treating all comments as intent

Right now the implementation only checks getCommentsInside(node.body).length > 0, which means the presence of any comment disables the rule. That’s a weak proxy for documented intent and it creates an easy false-negative path.

At minimum, constrain the allowlist to comments matching an explicit intentional-ignore pattern, or better yet require a real handling action (log / fallback / rethrow) and keep comments informational only. For example:

const commentsInside = sourceCode.getCommentsInside(node.body);
const hasIntentionalIgnoreComment = commentsInside.some(comment =>
  /intentional|best-effort|ignore/i.test(comment.value),
);
if (hasIntentionalIgnoreComment) return;

Without that, this rule will look useful in CI while silently allowing empty catches to persist behind low-signal comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a custom ESLint rule that detects undocumented empty catch blocks in setup JavaScript scripts.

Changes:

  • Implements and tests no-empty-catch-block.
  • Registers and enables the rule at warning severity.
  • Allows empty catch blocks containing explanatory comments.
Show a summary per file
File Description
eslint-factory/src/rules/no-empty-catch-block.ts Implements detection and reporting.
eslint-factory/src/rules/no-empty-catch-block.test.ts Tests valid and invalid catch blocks.
eslint-factory/src/index.ts Registers the rule.
eslint-factory/eslint.config.cjs Enables the rule as a warning.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

@@ -0,0 +1,38 @@
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";

const createRule = ESLintUtils.RuleCreator(name => `https://github.com/github/gh-aw/tree/main/eslint-factory#${name}`);
@github-actions github-actions Bot mentioned this pull request Aug 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no-empty-catch-block rule implementation is correct and well-structured. CatchClause visitor correctly targets empty body arrays, getCommentsInside properly allows documented-intent escapes, tests cover all valid and invalid patterns, and the rule is properly registered. No blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 18.4 AIC · ⌖ 7.85 AIC · ⊞ 5.4K

@github-actions

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel 🧪

Summary

Score: 100/100 ✅ Excellent

This PR introduces a new ESLint rule (no-empty-catch-block) with comprehensive test coverage. All 3 new tests are design tests that verify behavioral contracts of the rule.

Test Coverage

  • Test Files Analyzed: 1 TypeScript test file (eslint-factory/src/rules/no-empty-catch-block.test.ts)
  • New Tests: 3 (all behavioral)
  • Test Framework: vitest + RuleTester
  • Test Inflation Ratio: 49:38 = 1.29:1 ✅ (threshold: ≤2:1)

Test Classification

Test Analysis (3 tests)
Test Name Design Invariant Value Type Status
uses the correct docs URL Verifies rule metadata URL is correct and discoverable High Design
accepts catch blocks that log, assign a fallback, or document intent Rule permits catch blocks with logging, fallback assignment, or explanatory comment High Design
reports catch blocks with no statements and no explanatory comment Rule correctly reports empty catch blocks lacking documentation or side effects High Design

Quality Signals

  • ✅ All tests verify user-visible rule behavior (not implementation details)
  • ✅ Comprehensive valid and invalid case coverage (5 valid cases, 3 invalid cases)
  • ✅ No redundant or duplicated test patterns
  • ✅ Test inflation well within acceptable range
  • ✅ No mock-heavy tests or assertion anti-patterns

Result

Implementation Test Ratio: 0% (all design tests) — threshold: ≤30%
No Violations Detected

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 12.1 AIC · ⌖ 5.33 AIC · ⊞ 7.6K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /codebase-design — approving with one minor suggestion on rule metadata scope.

📋 Summary

Positive Highlights

  • ✅ Clean, minimal rule implementation — purely structural check (empty block + no comment), low false-positive risk
  • ✅ Good test coverage: valid cases cover all intended escape hatches (log, fallback assign, comment, rethrow), invalid cases cover parameter-less and named catch
  • ✅ Comment-based escape hatch is the right design — avoids suppression comments and stays readable
  • ✅ Rule registered and enabled as warn (correct severity for a new rule before fixing existing occurrences)
  • ✅ PR description clearly explains the 3 real-world occurrences that motivated the rule

Minor Issue

  • The docs.description mentions in

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 22.7 AIC · ⌖ 8.69 AIC · ⊞ 7K
Comment /matt to run again

name: "no-empty-catch-block",
meta: {
type: "problem",
docs: {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] The docs.description says in

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). All tests verify user-visible rule behavior with comprehensive valid and invalid case coverage.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot
Quick triage for maintainer-ready follow-up:

Unresolved review threads (newest first):

Please refresh the branch if needed, address the unresolved review feedback, rerun validation, and use the pr-finisher skill before handing back.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.47 AIC · ⌖ 7.2 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@copilot
Quick triage for maintainer-ready follow-up:
...

Addressed in d4d7096: documented the rule in the README and tightened the exception to explicit, case-insensitive intentional / best[- ]effort comments. Added coverage for accepted and weak-comment cases. Focused tests pass; the full Factory suite retains its unrelated require-fs-io-try-catch suggestion-assertion failures. CodeQL found no alerts.

Copilot AI requested a review from gh-aw-bot August 14, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation cookie Issue Monster Loves Cookies! eslint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants