Skip to content

fix(anti-slop): honor disable-next-line before asserted expression - #85

Merged
howmanysmall merged 2 commits into
mainfrom
fix/safety-comment-inline-disable-next-line
Oct 8, 2026
Merged

howmanysmall merged 2 commits into
mainfrom
fix/safety-comment-inline-disable-next-line

Conversation

@howmanysmall

Copy link
Copy Markdown
Owner

Summary

 hasSafetyComment
   safety marker before ancestors
-  if tsgolint reports on assertion syntax
-    accept a disable that covers the assertion line
+  accept disable-next-line on the line before `as`
+    even when the comment sits inside the asserted expression
+  if tsgolint reports on assertion syntax
+    also accept same-line and block disables that cover `as`
   else
-    accept a disable before the enclosing statement
+    also accept a disable before the enclosing statement

type({ ... }).readonly() as unknown as Type<BunFile> with the suppression on the line before as is a justification. The old path only saw that comment when it already knew oxlint-tsgolint was 7.0.2002 or newer.

Evidence

  • Before: the rule reported missingSafetyComment on both as unknown and as Type<BunFile> even with // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- slopware immediately above the assertion.
    After: nr test:agent -- tests/rules/anti-slop/require-safety-comment-for-type-assertion.test.ts passes, including that case with no tsgolintVersion setting.

Merge Danger

Door: two-way

Revert the rule and the test. No data migration.

Blast Radius: consumers

Fewer require-safety-comment-for-type-assertion reports when a described disable-next-line sits on the line before as. Same-line disable-line still depends on the 7.0.2002 diagnostic range.

The safety-comment rule now accepts a `disable-next-line` on the line
before `as` even when that line is inside the asserted expression. For
the tsgolint range that reports on assertion syntax, only same-line and
block disables were honored before, so multi-line assertions with a
next-line disable were flagged incorrectly.

Signed-off-by: howmanysmall <26746527+howmanysmall@users.noreply.github.com>
Signed-off-by: howmanysmall <26746527+howmanysmall@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Bundle size

Artifact Base Pull request Change
dist/index.js 484.18 kB 484.21 kB +25 B (+0.01%)

Raw, uncompressed bytes from the minified prepublishOnly build. Measured for commit d873c26 against base 21291c7.

@howmanysmall
howmanysmall merged commit 5b6050b into main Oct 8, 2026
8 checks passed
@howmanysmall
howmanysmall deleted the fix/safety-comment-inline-disable-next-line branch October 8, 2026 18:47
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.

1 participant