Skip to content

fix(lint): allow underscores in custom_block .md filenames#34

Merged
erunion merged 1 commit into
mainfrom
fix/lint-custom-block-underscore-filenames
Jul 17, 2026
Merged

fix(lint): allow underscores in custom_block .md filenames#34
erunion merged 1 commit into
mainfrom
fix/lint-custom-block-underscore-filenames

Conversation

@rossrdme

Copy link
Copy Markdown
Contributor

Problem

lint flags custom_block .md snippet files whose names contain underscores, e.g.:

[warning] custom_blocks/Helm_v4_error.md: Bad filename: should be PascalCase —
          rename to "HelmV4Error.md" so it can be used as <HelmV4Error />

This is a false positive. The filename becomes a component tag <Name />, and the only real constraint is that the name be a valid JS identifier starting with an uppercase letter. Underscores are valid identifier characters — <Helm_v4_error /> is a legal tag. The resolver already agrees: getKnownComponentNames registers the raw slug (names.add(slug)) as a known component name, so <Helm_v4_error /> already resolves. Only the filename check was overzealous, conflating "unusable as a tag" with "not my preferred style."

Fix

Flag a filename only when it can't be a component tag — i.e. it's not ^[A-Z][A-Za-z0-9_$]*$ (hyphens, or a lowercase initial). Underscores and digits are allowed. When it is invalid, still suggest the collapsed PascalCase form.

Verification

  • Added unit tests: underscore name allowed; hyphenated name flagged; lowercase-initial name flagged. Full suite: 89/89 passing.
  • Ran the patched linter against a real 898-page ReadMe docs repo (Cast AI): the previous Helm_v4_error.md "Bad filename" warning is gone, with no new warnings introduced.

Reported via a customer lint run (CX-3425-adjacent). Independent of #33 (Windows path fix).

🤖 Generated with Claude Code

The custom_block filename check required the name to equal its collapsed
PascalCase form, so valid component tags like Helm_v4_error.md were flagged
as "Bad filename" and told to rename to HelmV4Error.md. But underscores are
valid JS identifier characters — <Helm_v4_error /> is a legal component tag,
and the resolver already registers the raw slug as a known name.

Only flag filenames that can't be a component tag: not a valid identifier
starting with an uppercase letter (i.e. hyphens or a lowercase initial).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@erunion
erunion merged commit 2415f0c into main Jul 17, 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.

2 participants