Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hirokiokada77
Copy link
Contributor

Summary

This PR adds the noMultiStr rule, which disallows creating multiline strings by escaping newlines.

Closes #8193.

Test Plan

Added:

  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js.snap
  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js.snap

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2025

🦋 Changeset detected

Latest commit: 8e2d199

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-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Nov 22, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 22, 2025

CodSpeed Performance Report

Merging #8218 will not alter performance

Comparing hirokiokada77:feat/no-multi-str (8e2d199) with main (68c052e)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

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

  2. 95 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Walkthrough

This pull request introduces a new linter rule noMultiStr to Biome's JavaScript analyser. The rule flags the use of escaped newlines within string literals, which is a practice discouraged by ESLint's equivalent rule. The implementation includes the rule declaration and logic, corresponding test cases for both valid and invalid patterns, and the necessary configuration infrastructure via rule options.

Suggested labels

A-Project, A-Linter, L-JavaScript, A-Diagnostic

Suggested reviewers

  • dyc3
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: implementing the noMultiStr linting rule for Biome's JavaScript analyser.
Description check ✅ Passed The description is directly related to the changeset, explaining what the noMultiStr rule does and referencing the closed issue and test additions.
Linked Issues check ✅ Passed The PR successfully implements the ESLint no-multi-str rule in Biome with the suggested noMultiStr name [#8193], meeting all stated objectives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the noMultiStr rule—no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
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: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js (1)

1-4: Core invalid pattern is covered

This 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

📥 Commits

Reviewing files that changed from the base of the PR and between e430555 and 8e2d199.

⛔ Files ignored due to path filters (8)
  • 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_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noMultiStr/valid.js.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 (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 cases

Single‑line \n usage 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 semantics

Description, 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

NoMultiStrOptions follows 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 consistent

Docs, 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 work

The rule captures the standard line-continuation patterns (\\\n and \\\r\n) covered by your test cases. Whilst bare \r and 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.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Nice!

@dyc3 dyc3 added this pull request to the merge queue Nov 22, 2025
Merged via the queue into biomejs:main with commit 91484d1 Nov 22, 2025
20 checks passed
@github-actions github-actions bot mentioned this pull request Nov 22, 2025
@hirokiokada77 hirokiokada77 deleted the feat/no-multi-str branch November 22, 2025 17:13
@github-actions github-actions bot mentioned this pull request Nov 25, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
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.

📎 port no-multi-str from eslint

2 participants