Skip to content

Conversation

@Conaclos
Copy link
Member

@Conaclos Conaclos commented Oct 22, 2025

Summary

Fix #7798

The panic occurs when the rule tries to convert $ in a name that matches the custom conventions. The conversion results in an empty string that in turn produces an invalid parse tree.
The fix is pretty simple: we check if the name is empty before applying the fix.

Test Plan

I added a non-regression test.

Docs

I added a change set.

@changeset-bot
Copy link

changeset-bot bot commented Oct 22, 2025

🦋 Changeset detected

Latest commit: d3185f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 22, 2025
@Conaclos Conaclos requested review from a team October 22, 2025 18:40
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

This patch release addresses a panic in the useNamingConvention linter rule. The fix prevents the tool from crashing when it encounters a single dollar sign ("$") identifier that does not match custom naming conventions. Changes include guard logic to skip empty computed names during renaming operations, alongside new test cases documenting the edge case behaviour.

Suggested labels

L-JSON

Suggested reviewers

  • ematipico
  • siketyan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix(useNamingConvention): don't panic on $ name" is fully related to the main change in the changeset. It clearly and concisely summarizes the primary objective: fixing a panic in the useNamingConvention rule when encountering a dollar sign character. The title is specific enough that a teammate scanning the history would immediately understand the nature of the fix, and it accurately reflects the code changes that add a guard to prevent renaming when the computed name becomes empty.
Description Check ✅ Passed The pull request description is clearly related to the changeset and provides meaningful context about the fix. It explains the root cause (conversion of $ producing an empty string), describes the solution (checking for empty names before applying the fix), and documents the supporting work (non-regression test and changeset entry). All elements mentioned in the description align with the actual code changes present in the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch conaclos/useNamingConvention-7798-dollar-sign-panic

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef45056 and d3185f7.

⛔ Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/metal-plants-tell.md (1 hunks)
  • crates/biome_js_analyze/src/lint/style/use_naming_convention.rs (1 hunks)
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.options.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/lint/style/use_naming_convention.rs
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.options.json
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/style/use_naming_convention.rs
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.options.json
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Format Rust files before committing (e.g., via just f which formats Rust)
Document rules, assists, and options with inline rustdoc in source

Files:

  • crates/biome_js_analyze/src/lint/style/use_naming_convention.rs
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js
  • crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.options.json
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period

Files:

  • .changeset/metal-plants-tell.md
🧠 Learnings (1)
📚 Learning: 2025-10-15T09:20:19.139Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:20:19.139Z
Learning: Applies to crates/biome_analyze/**/lib/src/{lint,assist}/**/*.rs : Name rules according to conventions (e.g., no<Concept>, use<Concept>, noDuplicate<Concept>, noEmpty<Concept>, noUnused<Concept>, useConsistent<Concept>, useShorthand<Concept>, etc.) and set the macro name field accordingly

Applied to files:

  • crates/biome_js_analyze/src/lint/style/use_naming_convention.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/style/use_naming_convention.rs (1)
crates/biome_js_syntax/src/expr_ext.rs (6)
  • name (108-110)
  • name (168-170)
  • name (1698-1712)
  • name (1743-1764)
  • name (1795-1815)
  • name (1872-1898)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (4)
crates/biome_js_analyze/src/lint/style/use_naming_convention.rs (1)

980-980: LGTM – Guard prevents panic on empty conversion.

The addition of || new_name.is_empty() correctly prevents attempting to rename when case conversion produces an empty string (e.g., when converting a lone $). This is a minimal, defensive fix that addresses the root cause without affecting other code paths.

crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.js (1)

1-1: Appropriate test case for the edge case.

This simple test case effectively covers the scenario that previously caused a panic when the linter encountered a single $ identifier that didn't match the configured naming conventions.

crates/biome_js_analyze/tests/specs/style/useNamingConvention/invalidSIngleDollarName.options.json (1)

1-27: Test configuration correctly exercises the edge case.

This configuration enables the useNamingConvention rule with formats that $ doesn't match, triggering the code path that previously panicked. The setup is appropriate for validating the fix.

.changeset/metal-plants-tell.md (1)

1-5: Changeset follows the guidelines correctly.

The changeset properly documents this patch release using past tense ("Fixed"), includes links to both the issue and the rule documentation, and ends with a period.


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

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 22, 2025

CodSpeed Performance Report

Merging #7825 will not alter performance

Comparing conaclos/useNamingConvention-7798-dollar-sign-panic (d3185f7) with main (d9b7ade)1

Summary

✅ 53 untouched
⏩ 85 skipped2

Footnotes

  1. No successful run was found on main (ef45056) during the generation of this report, so d9b7ade was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 85 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Conaclos Conaclos merged commit ad55b35 into main Oct 22, 2025
18 checks passed
@Conaclos Conaclos deleted the conaclos/useNamingConvention-7798-dollar-sign-panic branch October 22, 2025 19:49
@github-actions github-actions bot mentioned this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Panic in useNamingConvention with biome check --write (builder.rs:217)

3 participants