feat(js_analyze): implement noJsxLeakedComment#9914
feat(js_analyze): implement noJsxLeakedComment#9914Netail wants to merge 1 commit intobiomejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: b237016 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
Merging this PR will not alter performance
Comparing Footnotes
|
3557864 to
d32cf4d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (9)
📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughAdds a new nursery lint rule Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 requiresb.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
⛔ Files ignored due to path filters (9)
crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rsis excluded by!**/migrate/eslint_any_rule_to_biome.rsand included by**crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_configuration/src/generated/domain_selector.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_configuration/src/generated/linter_options_check.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsx.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsx.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (7)
.changeset/slick-paths-give.mdcrates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_comment.rscrates/biome_js_analyze/src/lint/nursery/no_jsx_leaked_dollar.rscrates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/invalid.jsxcrates/biome_js_analyze/tests/specs/nursery/noJsxLeakedComment/valid.jsxcrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/no_jsx_leaked_comment.rs
d32cf4d to
b237016
Compare
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