Skip to content
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

💅 useTemplate problem #2580

Closed
1 task done
Jack-Works opened this issue Apr 24, 2024 · 1 comment · Fixed by #2600
Closed
1 task done

💅 useTemplate problem #2580

Jack-Works opened this issue Apr 24, 2024 · 1 comment · Fixed by #2600
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@Jack-Works
Copy link

Jack-Works commented Apr 24, 2024

Environment information

CLI:
  Version:                      1.7.1
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm"
  JS_RUNTIME_VERSION:           "v21.7.3"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/9.0.5"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Linter:
  Recommended:                  true
  All:                          false
  Rules:                        complexity/noMultipleSpacesInRegularExpressionLiterals = "off"

Workspace:
  Open Documents:               0

Rule name

useTemplate

Playground link

https://biomejs.dev/playground/?code=JwBgAGAAYAB0AHMAXABuACcAIAArACAAeAAgACsAIAAnAFwAbgBgAGAAYAAnADsACgA%3D

Expected result

No error because the current code is readable enough. Instead, biome suggests a syntax invalid fix, and the readability also gets worse.

  ✖ Template literals are preferred over string concatenation.
  
  > 1 │ '```ts\n' + x + '\n```';
      │ ^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ Unsafe fix: Use a template literal.
  
    1   │ - '```ts\n'·+·x·+·'\n```';
      1 │ + `\`\`\`ts\n${x}\n`\`\``;
    2 2 │   

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico
Copy link
Member

Thank you, @Jack-Works for reporting the error; the readability is subjective, that's why this rule is part of the style group.

However, the fix is indeed incorrect.

@ematipico ematipico added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project labels Apr 24, 2024
@Conaclos Conaclos self-assigned this Apr 25, 2024
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 S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants