Open
Conversation
arnavsurve
approved these changes
Feb 14, 2026
Contributor
arnavsurve
left a comment
There was a problem hiding this comment.
Clean, well-structured rule addition. The implementation is correct and consistent with existing rules in the codebase.
What I reviewed:
- Rule logic in
catch-must-log-to-sentry.ts: The recursivecontainsCallhelper is a solid approach for AST searching without a nested traverse. The rule correctly only flags catch blocks that havelogger.error()/console.error()withoutSentry.captureException(), avoiding false positives on handled errors. - Test coverage: 7 tests covering the core cases (flagging logger.error, console.error, allowing both together, Sentry-only, no logging, empty catch, multiple independent blocks). Good coverage.
- README documentation: Properly adds a new "Error Handling Rules" section, updates the rule count, and includes clear code examples.
- Integration: Rule export, index registration, and config-modes test count bump are all correct.
Minor observations (non-blocking):
- The recursive
containsCalltraverses into nested function/arrow function bodies within the catch block. If someone defines a callback inside a catch that callslogger.error, it would trigger the rule even though the logging is in a different execution scope. This is an extremely rare pattern and arguably still worth flagging, so not a concern in practice. - Only
Sentry.captureExceptionis recognized (notSentry.captureMessageetc.), which seems intentional and correct for catch blocks.
All CI checks pass. LGTM.
🤖 Generated with Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
catch-must-log-to-sentryrule that flags catch blocks containinglogger.error()orconsole.error()without a correspondingSentry.captureException()callTest plan