💅 Bug when linting on save, when Biome is changing RegEx to literal #1704
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
Environment information
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
The text was updated successfully, but these errors were encountered: