-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
🐛 biome lint panics when encountering multi-byte characters #4181
Comments
Can you provide a playground link or a reproduction repo? |
@dyc3 This is easily reproducible by running the following in an empty directory:
The same happens when ran via npm. Running in WSL2 on Ubuntu 22.04.4. My rustc version is 1.81.0 if that matters. |
It appears the issue was introduced in a recent commit where the string iteration was changed from using char_indices() to bytes().enumerate(). The change to processing strings as raw bytes caused the error, as bytes().enumerate() does not respect UTF-8 character boundaries. This leads to panics when the code attempts to slice strings containing multi-byte characters, like To handle multi-byte UTF-8 characters safely, the file should be reverted to use char_indices() instead of bytes().enumerate(). This ensures that the string is processed as valid UTF-8 characters, preventing the panic from occurring. The relevant code change would be:
Instead of:
|
As a temporary workaround you can disable the fix of the linter rule {
"linter": {
"rules": {
"style": {
"useTemplate": {
"level": "warn",
"fix": "off"
}
}
}
}
} or you can completely disable the rule: {
"linter": {
"rules": {
"style": {
"useTemplate": "off"
}
}
}
} |
Environment information
What happened?
When running
biome lint
on a JavaScript file containing (only) the expressiona + '€'
, Biome encounters an internal panic. The error message indicates an issue with byte indexing for the Euro symbol (€), which uses more than one byte. Here is the exact error:The original code that triggered the error was
return v.toFixed(2).replace('.', ',') + ' €';
which I was able to trim down to justa + '€'
in a separate file while still producing the same error.If I change the original code to use template literals instead, no panic happens:
Expected result
Biome should correctly parse and lint the file without crashing, even when handling non-ASCII characters like the Euro symbol.
Code of Conduct
The text was updated successfully, but these errors were encountered: