biome
biome copied to clipboard
📝 Multiple ternary operators are double indented after the second one
Environment information
CLI:
Version: 1.3.3-nightly.38797b7
Color support: true
Platform:
CPU Architecture: x86_64
OS: windows
Environment:
BIOME_LOG_DIR: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v18.16.1"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "npm/9.8.1"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: false
VCS disabled: true
Workspace:
Open Documents: 0
Configuration
No response
Playground link
https://biomejs.dev/playground?lineWidth=120&indentStyle=space&indentWidth=4&code=SABhAG4AZABsAGUAYgBhAHIAcwAuAHIAZQBnAGkAcwB0AGUAcgBIAGUAbABwAGUAcgAoACIAaQBuAGMAbAB1AGQAZQBzACIALAAgACgAYQByAHIAOgAgAHUAbgBrAG4AbwB3AG4ALAAgAGUAbABlAG0AZQBuAHQAOgAgAHUAbgBrAG4AbwB3AG4AKQA6ACAAYgBvAG8AbABlAGEAbgAgAD0APgAgAHsACgAgACAAIAAgAHIAZQB0AHUAcgBuACAAQQByAHIAYQB5AC4AaQBzAEEAcgByAGEAeQAoAGEAcgByACkACgAgACAAIAAgACAAIAAgACAAPwAgAGEAcgByAC4AaQBuAGMAbAB1AGQAZQBzACgAZQBsAGUAbQBlAG4AdAApAAoAIAAgACAAIAAgACAAIAAgADoAIABhAHIAcgAgAGkAbgBzAHQAYQBuAGMAZQBvAGYAIABTAGUAdAAKACAAIAAgACAAIAAgACAAIAAgACAAPwAgAGEAcgByAC4AaABhAHMAKABlAGwAZQBtAGUAbgB0ACkACgAgACAAIAAgACAAIAAgACAAIAAgADoAIABhAHIAcgAgACYAJgAgAHQAeQBwAGUAbwBmACAAYQByAHIAIAA9AD0APQAgACIAbwBiAGoAZQBjAHQAIgAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgAD8AIAAoAHQAeQBwAGUAbwBmACAAZQBsAGUAbQBlAG4AdAAgAD0APQA9ACAAIgBuAHUAbQBiAGUAcgAiACAAfAB8ACAAdAB5AHAAZQBvAGYAIABlAGwAZQBtAGUAbgB0ACAAPQA9AD0AIAAiAHMAdAByAGkAbgBnACIAKQAgACYAJgAgAGUAbABlAG0AZQBuAHQAIABpAG4AIABhAHIAcgAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgADoAIABmAGEAbABzAGUACgB9ACkAOwAKAA%3D%3D
Code of Conduct
- [X] I agree to follow Biome's Code of Conduct
The original playground input was formatted with prettier 3.1.0
Simplifying this down to the base case: Playground Link
longConditionExpression1
? consequent1
: longConditionExpression2
? consequent2
: longConditionExpression3
? consequent3
: consequent4
// Prettier 3.1 output
longConditionExpression1
? consequent1
: longConditionExpression2
? consequent2
: longConditionExpression3
? consequent3
: consequent4;
// Biome output
longConditionExpression1
? consequent1
: longConditionExpression2
? consequent2
: longConditionExpression3
? consequent3
: consequent4;
This happens regardless of indentation settings (spaces or tabs, or width).
It seems like the reason is that the formatter adds both a tab-equivalent indent along with the alignment spaces on the nested ternaries.
It seems that the issue was recently fixed.
@Conaclos It still looks broken, looking at my posted Playground link.
I don't understand where the problem is? We match Prettier here? Do you complain about the new way of formatting ternaries since Prettier 3.1?
To me it looks like a bug in Prettier. In the given example, the property is indented twice, and the closing bracket is indendet once. I would have expected the closing bracket to be on the same level as the opening bracket, and the property indented once with the opening bracket line.
To me it looks like a bug in Prettier. In the given example, the property is indented twice, and the closing bracket is indendet once. I would have expected the closing bracket to be on the same level as the opening bracket, and the property indented once with the opening bracket line.
Are you referring to this example? Which property? The closing bracket is the closing curly brace? I really don't get what you talk about...
No, I was referring to this example.
Ok I see. I am reopening the issue. Thanks for your help :)
Is there a Prettier issue we can track @DASPRiD? Otherwise, we match Prettier, which is NOT a bug
@ematipico A quick search yielded a few related ones:
- https://github.com/prettier/prettier/issues/4203
- https://github.com/prettier/prettier/issues/12517
- https://github.com/prettier/prettier/issues/5811