Closed unional closed 2 weeks ago
It's very difficult to triage the issue without information.
Can you please at least share the contents of the file? Can you check if you can replicate the issue in the playground?
Hi, since this is related to extension, probably can't repro it in the playground.
I think any repo using biome
with jsonc
file should able to repro it.
e.g. https://github.com/repobuddy/repobuddy/tree/biome-jsonc
pnpm i
and open a jsonc
file should be sufficient.
What does your editor detect the file as? Are you sure that you don't have some kind of mapping that tells VS Code that the .jsonc
extension is a JSON file? I can't reproduce the issue when opening the recommended.jsonc
file from your repo.
What does your editor detect the file as? Are you sure that you don't have some kind of mapping that tells VS Code that the
.jsonc
extension is a JSON file? I can't reproduce the issue when opening therecommended.jsonc
file from your repo.
That's strange. Are you on MacOS, and the extension shows that it is using biome
1.8.3
?
I don't have setting that map jsonc
to json
.
It is detected as jsonc
I confirmed the issue also occurs in linux (wsl, ubuntu) and Windows 11.
I can repro it to other repo using biome
. Only need to update it to 1.8.3
and reload vscode.
I am sorry @unional, I tried it myself and I can't replicate the issue. So it's possible is something in your internal settings (probably in settings.json
). Please provide a minimal reproduction.
It is really weird. Another repo in the same system, same biome 1.8.3. And that works fine.
Will need to look deeper on what's causing it.
Pasting an image here for reference:
I am going to close this, as we can't replicate it.
Again, I advise you to check your settings.json (project, workspace and user).
Feel free to open it again once you manage to provide a reproduction and some logs from the Daemon (instructions are attached to the template when you create the issue)
I found out what the problem is.
biome
parses json
as jsonc
by default.
Since that would causes false positives, my presets disable that by default:
{
"json": {
// `biome` treat `json` as `jsonc` by default.
// That causes false positives and should be avoided.
"parser": {
"allowComments": false,
"allowTrailingCommas": false
}
}
https://github.com/repobuddy/repobuddy/blob/main/packages/biome/recommended.jsonc#L16-L20
Now the problem is,
biome
is not parsing json
as jsonc
by default.
It is actually using the same parser to parse json
and jsonc
.
i.e. by doing "allowComments": false
at the top level,
I actually also turn off comment support for jsonc
files.
IMO this is a bug.
As for why you don't get the error,
it is because my top level biome.json
is doing extends
like this:
{
"extends": ["@repobuddy/biome/recommended"]
}
You need to run pnpm install
first to hook up the node_modules
.
Biome doesn't parse JSON files as JSONC files. Did you read this somewhere in our docs? However, some files get a particular treatment, which we document here: https://biomejs.dev/guides/configure-biome/#well-known-files
As for why you don't get the error, it is because my top level biome.json is doing extends like this
And that's why it's important to provide a reproduction.
Can you please provide a minimal reproduction? It's possible it is a bug, I haven't understood yet what's the issue and where it is.
https://github.com/repobuddy/repobuddy/tree/biome-jsonc
here is the minimal repro. The top level biome.jsonc
only has:
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"json": {
// `biome` treat `json` as `jsonc` by default.
// That causes false positives and should be avoided.
"parser": {
"allowComments": false,
"allowTrailingCommas": false
}
}
}
and it fails by itself:
That's not a minimal reproduction, that's a project. The reason why we ask for a minimal reproduction is because we can remove all the noise from a project, and make sure that there aren't other factors at play.
I can reproduce the issue seen in the screenshot using the reproduction repo, however I'm moving this to the main repo as it's not an issue with the extension.
VS Code version
1.90.2
Extension version
2.3.0
Biome version
1.8.3
Operating system
Description
It seems like the extension is trying to parse
jsonc
files asjson
files.Steps to reproduce
update
biome
from1.7.3
to1.8.3
Expected behavior
should work
Does this issue occur when using the CLI directly?
No
Logs