Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

πŸ› lint/style/useTemplate autofix breaks for adding numbers then strings #4713

Closed
1 task done
tomchambers2 opened this issue Jul 20, 2023 · 1 comment Β· Fixed by biomejs/biome#70
Closed
1 task done
Labels
S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@tomchambers2
Copy link

tomchambers2 commented Jul 20, 2023

Environment information

➜  user-interface git:(main) βœ— npx rome rage
CLI:
  Version:              11.0.0
  Color support:        true

Platform:
  CPU Architecture:     x86_64
  OS:                   macos

Environment:
  ROME_LOG_DIR:         unset
  NO_COLOR:             unset
  TERM:                 "xterm-256color"

Rome Configuration:
  Status:               unset

Workspace:
  Open Documents:       0

Discovering running Rome servers...

Incompatible Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

β„Ή Rage discovered this running server using an incompatible version of Rome.

Server:
  Version:              12.1.3

What happened?

  1. With the following line
const num1 = 1;
const num2 = 2;
const newNumber = num1 + num2 + "px";

This outputs 3px.

Rome rule lint/style/useTemplate can autofix it but it turns it into:

const newNumber = `${num1}${num2}px`

Which outputs 12px.

Expected result

It should maintain the prior output of 3px.

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@tomchambers2 tomchambers2 added the S-To triage Status: user report of a possible bug that needs to be triaged label Jul 20, 2023
@tomchambers2 tomchambers2 changed the title πŸ› <TITLE> πŸ› lint/style/useTemplate autofix breaks for adding numbers then strings Jul 20, 2023
@Conaclos Conaclos added S-Bug: confirmed Status: report has been confirmed as a valid bug and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Aug 25, 2023
@Conaclos
Copy link
Contributor

Thanks for the report!

lint/useTemplate provides an unsafe fix. Technically it is not necessarily a bug. However, there is certainly some room for improvement!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants