-
-
Notifications
You must be signed in to change notification settings - Fork 794
Closed
Labels
A-LinterArea: linterArea: linterL-JavaScriptLanguage: JavaScript and super languagesLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugStatus: report has been confirmed as a valid buggood first issueGood for newcomersGood for newcomers
Description
Environment information
CLI:
Version: 2.3.6
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
BIOME_THREADS: unset
NO_COLOR: unset
TERM: xterm-256color
JS_RUNTIME_VERSION: v22.21.1
JS_RUNTIME_NAME: node
NODE_PACKAGE_MANAGER: pnpm/9.13.2
Biome Configuration:
Status: Loaded successfully
Formatter enabled: true
Linter enabled: trueRule name
nursery/useConsistentArrowReturn
Playground link
Expected result
Current Behavior (Bug)
When running biome lint --fix via CLI with the useConsistentArrowReturn rule configured with style: "always", the autofix produces semantically incorrect code that changes the function's behavior.
Input code:
const foo = (l: string) =>
l
.split('\n')CLI autofix output (INCORRECT):
const foo = (l: string) =>
{
return
l
.split("\n");
}Problem: The function now returns undefined instead of the split array because there's a newline after return, triggering JavaScript's automatic semicolon insertion (ASI). This silently breaks working code by changing its runtime behavior.
Expected Behavior
The autofix should produce:
const foo = (l: string) => {
return l.split('\n');
};This is what VS Code's Quick Fix (source.fixAll.biome) correctly produces when applying the same lint rule fix.
Configuration Used
{
"linter": {
"rules": {
"nursery": {
"useConsistentArrowReturn": {
"level": "warn",
"options": { "style": "always" }
}
}
}
}
}Steps to Reproduce
- Save the input code to a file (e.g.,
test.ts) - Run:
biome lint --fix test.ts - Observe the incorrect output with
returnon a separate line from the value
Impact
This bug can silently break working code by changing its runtime behavior:
- The function returns
undefinedinstead of the intended value - The code remains syntactically valid, so the error may not be caught until runtime
- This is a critical semantic change that could cause production bugs
Additional Context
- VS Code's Quick Fix works correctly, suggesting the issue is specific to the CLI autofix implementation
- According to Discord discussion, VS Code likely runs format after applying the fix, which corrects the incorrect return placement
- The CLI autofix should produce correct code without requiring a subsequent format pass
- This was discussed in the Biome Discord where maintainer Siketyan confirmed this is a bug
Metadata
Metadata
Assignees
Labels
A-LinterArea: linterArea: linterL-JavaScriptLanguage: JavaScript and super languagesLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugStatus: report has been confirmed as a valid buggood first issueGood for newcomersGood for newcomers