Repository navigation
Make bare @nothrow mute both its own line and the next - #3
Conversation
The bare directive now works both trailing a statement and on its own line above one. The explicit forms are unchanged and remain the way to target exactly one line: @nothrow-line mutes only the directive's line, @nothrow-next-line mutes only the following line. Update fixtures to cover the new bare-above case, the explicit-form negative controls, and the spill-over pitfall (a trailing bare @nothrow also mutes the following line). Bump packages to 0.3.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UG7WqvjcBWuMRj24ssFSrd
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33addab5b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ).line; | ||
| muted.add(match[1] === "-next-line" ? directiveLine + 1 : directiveLine); | ||
| if (match[1] !== "-next-line") muted.add(directiveLine); | ||
| if (match[1] !== "-line") muted.add(directiveLine + 1); |
There was a problem hiding this comment.
Restrict bare @nothrow to directive comments
Because MUTE_DIRECTIVE matches @nothrow anywhere in any comment, adding directiveLine + 1 for every bare match makes prose comments silently suppress the following line. For example, a comment like // this API used to need @nothrow immediately above an exported function now mutes the function's missing-throws diagnostic even though it was not written as a directive, creating false negatives; consider only applying the next-line behavior when the comment body is actually a directive.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR updates the core analyzer’s @nothrow muting semantics so that the bare @nothrow directive mutes both its own line and the following line, allowing it to work consistently as either a trailing comment or as a standalone directive line.
Changes:
- Change
collectMutedLinesso bare@nothrowmutes both current and next line; explicit-line/-next-lineremain single-target. - Update docs/help text to reflect the new muting rules and the “spill-over” implication.
- Expand fixture + unit test coverage for the new behaviors and edge cases; bump package versions to
0.3.0.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents bare vs explicit @nothrow* semantics and spill-over guidance. |
| packages/core/src/analyzer.ts | Implements updated muted-line collection rules for directives. |
| packages/core/test/mute-fix.test.ts | Adds assertions for new fixture cases under updated muting semantics. |
| packages/core/test/fixtures/muted.ts | Updates/extends fixture scenarios for bare and explicit directive behaviors. |
| packages/core/package.json | Bumps @throwscript/core version to 0.3.0. |
| packages/cli/src/main.ts | Updates CLI help text and printed version to 0.3.0. |
| packages/cli/package.json | Bumps CLI package version to 0.3.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // GOOD: bare @nothrow also covers the next line, so it works on its own line | ||
| // above the throw. |
| // form: a bare @nothrow here would spill onto the next line and mute the | ||
| // OtherError throw too. |
The bare directive now works both trailing a statement and on its own line above one. The explicit forms are unchanged and remain the way to target exactly one line: @nothrow-line mutes only the directive's line, @nothrow-next-line mutes only the following line. Update fixtures to cover the new bare-above case, the explicit-form negative controls, and the spill-over pitfall (a trailing bare @nothrow also mutes the following line). Bump packages to 0.3.0. Claude-Session: https://claude.ai/code/session_01UG7WqvjcBWuMRj24ssFSrd Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Summary
Changes the bare
@nothrowdirective to mute both its own line and the following line, so a single form works trailing a statement and on its own line above one:The explicit forms are unchanged and remain the way to target exactly one line:
// @nothrow-line— only the directive's line// @nothrow-next-line— only the following lineOne consequence worth knowing: a trailing bare
@nothrownow also mutes the line below it. When that neighbouring line should stay checked, use@nothrow-line— the README calls this out, and a fixture covers the pitfall.Packages bumped to 0.3.0.
Test plan
pnpm run checkgreen — build, oxlint, 10 core + 6 CLI tests@nothrowabove a throw (muted),@nothrow-lineon its own line (next line still reported), trailing@nothrow-next-line(own line still reported), and the spill-over case inpartiallyMuted🤖 Generated with Claude Code
https://claude.ai/code/session_01UG7WqvjcBWuMRj24ssFSrd
Generated by Claude Code