-
-
Notifications
You must be signed in to change notification settings - Fork 794
feat(biome_js_analyze): implement noMultiStr rule
#8218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 8e2d199 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 |
CodSpeed Performance ReportMerging #8218 will not alter performanceComparing Summary
Footnotes
|
WalkthroughThis pull request introduces a new linter rule Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js (1)
1-4: Core invalid pattern is coveredThis fixture exercises the key forbidden form (backslash + newline continuation). If you ever see edge‑cases in the wild, you could add more samples, but this is perfectly adequate for now.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
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_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_js_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js.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 (6)
.changeset/happy-mirrors-grow.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_multi_str.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js(1 hunks)crates/biome_rule_options/src/lib.rs(1 hunks)crates/biome_rule_options/src/no_multi_str.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-21T01:10:53.036Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8171
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:125-137
Timestamp: 2025-11-21T01:10:53.036Z
Learning: In the Biome codebase, each lint rule has its own options type declaration (e.g., `type Options = RuleNameOptions`) as part of the codegen process, even if the options struct is empty or unused. This is standard practice and should not be flagged as an issue.
Applied to files:
crates/biome_rule_options/src/no_multi_str.rs
🧬 Code graph analysis (3)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js (1)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js (1)
foo(2-4)
crates/biome_js_analyze/src/lint/nursery/no_multi_str.rs (1)
crates/biome_analyze/src/rule.rs (3)
recommended(602-605)sources(617-620)same(246-251)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js (1)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js (1)
foo(2-2)
⏰ 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). (13)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test Node.js API
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: autofix
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (6)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js (1)
1-4: Valid fixtures nicely cover the non‑violation casesSingle‑line
\nusage and multiline template literal are exactly the patterns this rule should allow; this pairs well with the invalid fixture and rule docs..changeset/happy-mirrors-grow.md (1)
1-21: Changeset reads well and matches the rule semanticsDescription, link, and invalid/valid snippets all mirror the implementation and test fixtures, so this will make for a clear release note.
crates/biome_rule_options/src/lib.rs (1)
132-132: Module export wiring looks consistent
pub mod no_multi_str;is in the expected place and cleanly exposes the options module for the new rule.crates/biome_rule_options/src/no_multi_str.rs (1)
1-6: Options struct matches existing patterns
NoMultiStrOptionsfollows the usual derive/serde pattern for rule options, even though it is currently field‑less, which is standard for this codebase.
Based on learnings.crates/biome_js_analyze/src/lint/nursery/no_multi_str.rs (2)
10-44: Rule metadata and docs are clear and consistentDocs, examples, rule name, ESLint source mapping, and severity all look coherent and line up with the fixtures and changeset; nothing alarming here.
47-74: Implementation correctly handles the common cases; edge-case extension can remain future workThe rule captures the standard line-continuation patterns (
\\\nand\\\r\n) covered by your test cases. Whilst bare\rand Unicode line terminators (LS/PS) are technically valid per the ECMAScript spec, they're exceedingly rare in practice and aren't currently surfaced as problematic line continuations in the parser. Your approach is sound for the mainstream use case, and the suggested pedantic refinements make good candidates for a future enhancement if needed.
dyc3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Summary
This PR adds the
noMultiStrrule, which disallows creating multiline strings by escaping newlines.Closes #8193.
Test Plan
Added:
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.jscrates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js.snapcrates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.jscrates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js.snap