Skip to content

Make bare @nothrow mute both its own line and the next - #3

Merged
mirek merged 1 commit into
mainfrom
claude/throwscript-throws-linter-8viyai
Jul 5, 2026
Merged

mirek merged 1 commit into
mainfrom
claude/throwscript-throws-linter-8viyai

Conversation

@mirek

@mirek mirek commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

Changes the bare @nothrow directive 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:

throw new E(); // @nothrow     ← muted (trailing)

// @nothrow                    ← next line muted too
throw new E();

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 line

One consequence worth knowing: a trailing bare @nothrow now 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 check green — build, oxlint, 10 core + 6 CLI tests
  • New fixture cases: bare @nothrow above a throw (muted), @nothrow-line on its own line (next line still reported), trailing @nothrow-next-line (own line still reported), and the spill-over case in partiallyMuted
  • Built CLI verified end-to-end on all three behaviours

🤖 Generated with Claude Code

https://claude.ai/code/session_01UG7WqvjcBWuMRj24ssFSrd


Generated by Claude Code

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
@mirek
mirek marked this pull request as ready for review July 5, 2026 07:17
Copilot AI review requested due to automatic review settings July 5, 2026 07:17
@mirek
mirek merged commit 186532b into main Jul 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 collectMutedLines so bare @nothrow mutes both current and next line; explicit -line / -next-line remain 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.

Comment on lines +26 to +27
// GOOD: bare @nothrow also covers the next line, so it works on its own line
// above the throw.
Comment on lines +47 to +48
// form: a bare @nothrow here would spill onto the next line and mute the
// OtherError throw too.
mirek added a commit that referenced this pull request Jul 5, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants