Skip to content

feat(js_analyze): implement noJsxLeakedComment#9914

Open
Netail wants to merge 1 commit intobiomejs:mainfrom
Netail:feat/no-jsx-leaked-comment
Open

feat(js_analyze): implement noJsxLeakedComment#9914
Netail wants to merge 1 commit intobiomejs:mainfrom
Netail:feat/no-jsx-leaked-comment

Conversation

@Netail
Copy link
Copy Markdown
Member

@Netail Netail commented Apr 11, 2026

Summary

Port https://www.eslint-react.xyz/docs/rules/jsx-no-comment-textnodes, which disallows comment syntax in JSX text nodes.

Partially generated by co-pilot

Test Plan

Unit tests

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 11, 2026

🦋 Changeset detected

Latest commit: b237016

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 A-Diagnostic Area: diagnostocis A-CLI Area: CLI A-Project Area: project labels Apr 11, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 11, 2026

Merging this PR will not alter performance

✅ 59 untouched benchmarks
⏩ 195 skipped benchmarks1


Comparing Netail:feat/no-jsx-leaked-comment (b237016) with main (f785e8c)

Open in CodSpeed

Footnotes

  1. 195 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.

@Netail Netail force-pushed the feat/no-jsx-leaked-comment branch from 3557864 to d32cf4d Compare April 20, 2026 21:36
@Netail Netail marked this pull request as ready for review April 20, 2026 21:37
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b7b59baf-0ed9-47b5-8f10-4f0c3d07b286

📥 Commits

Reviewing files that changed from the base of the PR and between d32cf4d and b237016.

⛔ Files ignored due to path filters (9)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_configuration/src/generated/domain_selector.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (7)
  • .changeset/slick-paths-give.md
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_dollar.rs
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/no_jsx_leaked_comment.rs
✅ Files skipped from review due to trivial changes (2)
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_dollar.rs
  • .changeset/slick-paths-give.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx
  • crates/biome_rule_options/src/no_jsx_leaked_comment.rs
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs

Walkthrough

Adds a new nursery lint rule noJsxLeakedComment that scans JsxText nodes for // and /* */ comment syntax rendered as text and emits diagnostics with ranges covering the detected comment text. Expands noJsxLeakedDollar rule domains to include Qwik in addition to React. Exposes no_jsx_leaked_comment rule options module and introduces an empty NoJsxLeakedCommentOptions struct. Adds test fixtures (valid.jsx and invalid.jsx) covering valid and invalid JSX comment scenarios. Also includes a changeset entry for a patch release.

Possibly related PRs

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(js_analyze): implement noJsxLeakedComment' directly and clearly describes the main change: implementing a new JavaScript linting rule.
Description check ✅ Passed The description explains the changeset is porting an ESLint React rule that disallows comment syntax in JSX text nodes, which aligns with the code changes adding the noJsxLeakedComment rule.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs (1)

61-64: The URL exception branch is currently unreachable.

On Line 63, b == b':' can never be true because the same predicate already requires b.is_ascii_whitespace(). This works today, but it reads like logic drift.

Suggested clean-up
-            // Allow comment if preceded by whitespace, but not if it's "://" (URL)
-            prev_byte.is_some_and(|&b| {
-                b.is_ascii_whitespace() && !(b == b':' && bytes.get(index + 1) == Some(&b'/'))
-            })
+            // Allow comment if preceded by whitespace.
+            prev_byte.is_some_and(|&b| b.is_ascii_whitespace())
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs` around
lines 61 - 64, The predicate for allowing a comment uses
prev_byte.is_some_and(|&b| b.is_ascii_whitespace() && !(b == b':' &&
bytes.get(index + 1) == Some(&b'/'))) but the inner check b == b':' is
unreachable because b.is_ascii_whitespace() forbids ':'; update the logic so the
"://"-exception inspects surrounding bytes rather than the same whitespace byte:
keep the whitespace check on prev_byte (b.is_ascii_whitespace()) and replace the
unreachable part with a check like !(bytes.get(index - 1) == Some(&b':') &&
bytes.get(index) == Some(&b'/')) using the existing bytes and index variables so
the URL exception is actually evaluated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs`:
- Around line 1-3: The rule currently leaves severity implicit; locate the
declare_lint_rule invocation for this lint (search for the NoJsxLeaked* rule
name or the declare_lint_rule macro in this file) and add an explicit severity
set to Severity::Warning (ensure the Severity symbol is imported if not
already). Update the rule metadata in the declare_lint_rule block to include
severity: Severity::Warning so the lint reports as a warning rather than using
the default.

---

Nitpick comments:
In `@crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs`:
- Around line 61-64: The predicate for allowing a comment uses
prev_byte.is_some_and(|&b| b.is_ascii_whitespace() && !(b == b':' &&
bytes.get(index + 1) == Some(&b'/'))) but the inner check b == b':' is
unreachable because b.is_ascii_whitespace() forbids ':'; update the logic so the
"://"-exception inspects surrounding bytes rather than the same whitespace byte:
keep the whitespace check on prev_byte (b.is_ascii_whitespace()) and replace the
unreachable part with a check like !(bytes.get(index - 1) == Some(&b':') &&
bytes.get(index) == Some(&b'/')) using the existing bytes and index variables so
the URL exception is actually evaluated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7431c0cb-c455-4c0c-a658-7a2d5371c401

📥 Commits

Reviewing files that changed from the base of the PR and between f785e8c and d32cf4d.

⛔ Files ignored due to path filters (9)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_configuration/src/generated/domain_selector.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (7)
  • .changeset/slick-paths-give.md
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs
  • crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_dollar.rs
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx
  • crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/no_jsx_leaked_comment.rs

Comment thread crates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rs
@Netail Netail force-pushed the feat/no-jsx-leaked-comment branch from d32cf4d to b237016 Compare April 20, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant