Skip to content

fix(comments): keep CSS at-rules like @keyframes inline instead of treating them as JSDoc tags - #672

Merged
aversini merged 1 commit into
mainfrom
claude/comments-keyframes-bug-f58icc
Sep 11, 2026
Merged

aversini merged 1 commit into
mainfrom
claude/comments-keyframes-bug-f58icc

Conversation

@aversini

Copy link
Copy Markdown
Collaborator

Summary

Investigates and fixes the reported bug: "The comments script reflowed pre-existing comments and mangled the ui-styles JSDoc by misreading @keyframes as a tag."

The report is valid. A wrapped prose line inside a JSDoc block that starts with a CSS at-rule was classified as a JSDoc tag line by isTagLine(). The reflow then flushed the paragraph early, injected a spurious period on the previous line, and left the at-rule on its own line:

/**
 * Global styles for the UI. Animations are registered through the
 * @keyframes rule and referenced by name in each component.
 */

became

/**
 * Global styles for the UI. Animations are registered through the.
 * @keyframes rule and referenced by name in each component.
 */

(The "reflowed pre-existing comments" part of the report is the tool's intended behavior: it reflows every JSDoc block it finds. Only the @keyframes mangling was a defect.)

Fix

  • isTagLine() now recognizes a small allowlist of CSS at-rules whose names never double as JSDoc/TSDoc tags (@keyframes, @media, @layer, @supports, @container, @font-face, @tailwind, @apply, ...) and treats such lines as sentence continuation. This mirrors the existing scoped-package exclusion (@auth0/auth0-react).
  • At-rules that are also real JSDoc tags (@function, @import, @mixin, @namespace, @property, @return) are deliberately left out so they keep working as tags.
  • The NOTE-line lookahead reuses isTagLine(), so it benefits automatically.

Tests

  • New regression test covering @keyframes, @media, and @layer opening a wrapped prose line (no injected period, sentence joined).
  • New test asserting @property, @function, @namespace, @return are still treated as tags.
  • vitest: 52 passed. biome check: clean. Running the tool in dry-run mode against its own src/lib.ts produces the same diff as before this change (the new comments are stable under its own reflow).

Docs

README heuristics list now mentions the scoped-package and CSS at-rule exclusions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MNMqVHj6CjPFuwpB1qXS5P


Generated by Claude Code

…eating them as JSDoc tags

A wrapped prose line inside a JSDoc block that happened to start with a
CSS at-rule (e.g. "... registered through the" / "@Keyframes rule and
referenced by name") was classified as a tag line. The reflow then severed
the sentence, injected a spurious period on the previous line, and kept
the at-rule on its own line, mangling comments in style-heavy packages.

isTagLine() now recognizes a small allowlist of CSS at-rules whose names
never double as JSDoc/TSDoc tags (@Keyframes, @media, @layer, @supports,
@container, @font-face, ...) and treats such lines as sentence
continuation. At-rules that are also real JSDoc tags (@function, @import,
@mixin, @namespace, @Property, @return) are deliberately left out so they
keep working as tags. This mirrors the existing scoped-package exclusion
(@auth0/auth0-react).

Adds regression tests for both directions and documents the heuristic in
the README.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNMqVHj6CjPFuwpB1qXS5P

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.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.


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

@aversini
aversini merged commit e0e04b2 into main Sep 11, 2026
6 checks passed
@aversini
aversini deleted the claude/comments-keyframes-bug-f58icc branch September 11, 2026 16:17
@aversini aversini mentioned this pull request Sep 11, 2026
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.

3 participants