Closed ChiefORZ closed 2 months ago
For a better understanding what i mean with the title:
For me to get biome's import sorting to work i needed to enable the vscode's default import sorting aswell, so my vscode's settings.json looks like this:
// settings.json
{
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
"source.organizeImports.biome": "explicit",
"source.sortPackageJson": "explicit"
}
}
If i remove the option source.organizeImports
- no imports will be sorted at all, vscode will not do anything.
In the playground provided the sorting will always be
import { type NextRequest, NextResponse } from "next/server";
so this is the correct way biome is sorting things.
But when Cmd+S and the codeActions run, the result will be
import { NextResponse, type NextRequest } from "next/server";
which i guess is vscode's default formatting/sorting.
I tried to remove all other codeActions, as well as re-ordering both "source.organizeImports" rules so that maybe the "source.organizeImports.biome" rule wins, but this did nothing -.-
Same here... I was considering using Prettier just because of this...
I have Biome formatting in pre-commit and every time I have to re-commit the organized imports because Biome doesn't do it automatically in VSCode.
"source.organizeImports": "explicit",
This is action code that triggers the built-in import sorting of VSCode, it should not be used if you want to use only Biome: source.organizeImports.biome.
If the import sorting isn't applied, I suspect there's something wrong with how the project is set up. Any chance you can create a reproduction to look at? Without that, we can't help you
I'm using it like this in my Workspace settings:
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit",
"source.organizeImports": "never",
"source.fixAll": "explicit"
}
},
... and the same for typescript, typescriptreact, etc.
Because source.organizeImports
is "never", it isn't organizing any imports now... If I set it to "explicit", it overrides Biome's.
Is the problem still there?
Environment information
Configuration
Playground link
https://biomejs.dev/playground/?code=aQBtAHAAbwByAHQAIAB7ACAAagB3AHQARABlAGMAbwBkAGUAIAB9ACAAZgByAG8AbQAgACIAagB3AHQALQBkAGUAYwBvAGQAZQAiADsACgBpAG0AcABvAHIAdAAgAGMAcgBlAGEAdABlAE0AaQBkAGQAbABlAHcAYQByAGUAIABmAHIAbwBtACAAIgBuAGUAeAB0AC0AaQBuAHQAbAAvAG0AaQBkAGQAbABlAHcAYQByAGUAIgA7AAoAaQBtAHAAbwByAHQAIAB7ACAATgBlAHgAdABSAGUAcwBwAG8AbgBzAGUALAAgAHQAeQBwAGUAIABOAGUAeAB0AFIAZQBxAHUAZQBzAHQAIAB9ACAAZgByAG8AbQAgACIAbgBlAHgAdAAvAHMAZQByAHYAZQByACIAOwA%3D
Code of Conduct