Skip to content

fix(lint): skip noUselessStringConcat for tagged templates#9565

Merged
ematipico merged 2 commits intobiomejs:mainfrom
eyupcanakman:fix/no-useless-string-concat-tagged-template-9505
Mar 22, 2026
Merged

fix(lint): skip noUselessStringConcat for tagged templates#9565
ematipico merged 2 commits intobiomejs:mainfrom
eyupcanakman:fix/no-useless-string-concat-tagged-template-9505

Conversation

@eyupcanakman
Copy link
Contributor

Tagged template literals like sqlquery call a function and are not plain strings. The noUselessStringConcat rule incorrectly treated them as strings and suggested an autofix that stripped the tag, changing runtime behavior.

is_string_expression and extract_string_value now check tag().is_none() before classifying a template as a string. Untagged templates are still flagged.

Fixes #9505

…sStringConcat

Fixes biomejs#9505

The `noUselessStringConcat` rule treated tagged template literals
(e.g. `sql\`query\``) as plain strings. The autofix would strip the
tag function and produce incorrect code.

Check `JsTemplateExpression::tag()` before treating a template as a
plain string in both `is_string_expression` and `extract_string_value`.
@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2026

🦋 Changeset detected

Latest commit: d10b82e

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 Mar 21, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 21, 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: 9fa70c90-bf7d-4ef8-b14b-40a8ad7a8d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 1ed62a7 and d10b82e.

📒 Files selected for processing (1)
  • .changeset/pretty-hornets-rescue.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/pretty-hornets-rescue.md

Walkthrough

The no_useless_string_concat rule was changed to treat template literals differently: a template expression is considered a string expression only if it is untagged (i.e., has no tag). String-value extraction now returns None for tagged template expressions, preventing tagged templates from being treated as plain strings. Tests were added to ensure concatenations involving tagged templates are not flagged or auto-fixed.

Possibly related PRs

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: skipping the noUselessStringConcat rule for tagged templates.
Description check ✅ Passed The description clearly explains the problem, the fix, and references the specific issue being resolved.
Linked Issues check ✅ Passed The PR fully addresses issue #9505 by preventing the noUselessStringConcat rule from flagging and autofixing tagged template literals, only processing untagged templates.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the noUselessStringConcat rule for tagged templates and include appropriate test coverage and changelog entry.

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

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

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
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Changeset missing. Do people read the PR template, or contribution guide or the bot? Lol

@eyupcanakman
Copy link
Contributor Author

@ematipico Sorry, first time contributing here and I missed that. Added now.

@ematipico
Copy link
Member

@eyupcanakman

Thank you. Please next time don't wipe out the PR template (or at least read it). It had all the information you needed.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 22, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing eyupcanakman:fix/no-useless-string-concat-tagged-template-9505 (d10b82e) with main (1710cf1)

Open in CodSpeed

Footnotes

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

@ematipico ematipico merged commit ccb249e into biomejs:main Mar 22, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Mar 22, 2026
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.

💅 [v2.4.7] noUselessStringConcat fix breaks strings concatenated with template functions

2 participants