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

💅 Bug when linting on save, when Biome is changing RegEx to literal #1704

Closed
1 task done
HermanBergsholm opened this issue Jan 30, 2024 · 1 comment · Fixed by #1707
Closed
1 task done

💅 Bug when linting on save, when Biome is changing RegEx to literal #1704

HermanBergsholm opened this issue Jan 30, 2024 · 1 comment · Fixed by #1707
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

@HermanBergsholm
Copy link

Environment information

CLI:
  Version:                      1.5.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.10.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.2.3"

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

Workspace:
  Open Documents:               0

Rule name

useRegexLiterals

Playground link

https://biomejs.dev/playground/?lineWidth=120&indentStyle=space&trailingComma=es5&semicolons=as-needed&code=IAAgAGMAbwBuAHMAdAAgAHIAZQBnAGUAeAAgAD0AIABuAGUAdwAgAFIAZQBnAEUAeABwACgAIgA6AC8ALwBbAF4AOgAvAF0AKgAiACkACgAKAC8ALwAgAF4AIABiAGUAYwBvAG0AZQBzACAACgAKAGMAbwBuAHMAdAAgAHIAZQBnAGUAeAAgAD0AIAAvADoALwAvAFsAXgA6AC8AXQAqAC8ACgAKAC8ALwAgAF4AIAB1AHAAbwBuACAAcwBhAHYAaQBuAGcALAAgAHcAaABpAGMAaAAgAHcAaQBsAGwAIABjAGEAdQBzAGUAIABhAHAAcABsAGkAYwBhAHQAaQBvAG4AIAB0AG8AIABjAHIAYQBzAGgALgAgAAoACgAvAC8AIABUAGUAbQBwAG8AcgBhAHIAaQBsAHkAIABzAG8AbAB2AGUAZAAgAHUAcwBpAG4AZwA6ACAACgAKAC8ALwAgAGIAaQBvAG0AZQAtAGkAZwBuAG8AcgBlACAAbABpAG4AdAAvAGMAbwBtAHAAbABlAHgAaQB0AHkALwB1AHMAZQBSAGUAZwBlAHgATABpAHQAZQByAGEAbABzADoAIABiAGkAbwBtAGUAIABiAHUAZwBzACAAbwB1AHQAIABvAG4AIAByAGUAZwBlAHgAIABsAGkAdABlAHIAYQBsAHMA

Expected result

As the string does not contain any concatenation, I find it weird that Biome tries to lint it differently when saving.

As can be seen in the playground link, this:
const regex = new RegExp("://[^:/]*")
turns into this:
const regex = /://[^:/]*/
when saving/running linter. This is a syntax error and will crash the node application.

Expected outcome is, I guess, that Biome does not do anything with this variable's value, as there is no string concatenation present.

Using // biome-ignore lint/complexity/useRegexLiterals temporarily to avoid this, but that should not be necessary.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@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 Jan 30, 2024
@togami2864
Copy link
Contributor

I'll take a look :)

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