Skip to content
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

🐛 Buggy side-effect caused by previous fix that made biome.json(c) un-ignore-able #2990

Closed
1 task done
KemingHe opened this issue May 26, 2024 · 3 comments · Fixed by #3007 or abdulrahman305/continue#2
Closed
1 task done
Assignees
Labels
A-Project Area: project good first issue Good for newcomers S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@KemingHe
Copy link

Environment information

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.2.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/9.1.2"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

To replicate the issue (after setting up the same env as mine):

  1. In your biome.json, specify:
{
  "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
  ...
  "json": {
      "formatter": {
        "trailingCommas": "all"
      }
    },
  ...
}
  1. Run npx biome check --apply . (or yarn, or npmp, or predefined script in package.json);

  2. biome.json will be formatted with trailing commas, which breaks the json standard for a root level config data file. To demonstrate, run npx biome check --apply . again and receive this error:

✖ Expected a property but instead found '}'.
  
    51 │     },
    52 │   },
  > 53 │ }
       │ ^
    54 │ 
  1. Furthermore, merge fix: the file biome.json can't be ignored #1531 specified biome.json to be un-ignore-able, meaning that while the rest of the **/*.json files can be ignored or fine-grained controlled to add/not add commas (i.e. package.json), biome.json will always be incorrectly formatted.

Expected result

biome.json should be (by design, not by user choice) untouched by the trailing comma formatting option.

I would further suggest that user would not be able to specify to apply formatting to the file to avoid confusion.

In short:
Given the trailingCommas formatter for json is set to all
When running npx biome check --apply .
Then biome.json should not be affected

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@KemingHe
Copy link
Author

For those come across here looking for a workaround, here's what you need to do:

"json": {
    "formatter": {
      "trailingCommas": "none"
    }
  },

And keep the discussion going so our wonderful maintainers can see this issue. ❤️

@ematipico ematipico added A-Project Area: project S-Bug-confirmed Status: report has been confirmed as a valid bug good first issue Good for newcomers S-Help-wanted Status: you're familiar with the code base and want to help the project labels May 26, 2024
@dyc3
Copy link
Contributor

dyc3 commented May 27, 2024

I'd like to give this a shot.

@nhedger
Copy link
Member

nhedger commented May 27, 2024

I'd like to give this a shot.

Thanks, assigned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Project Area: project good first issue Good for newcomers S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
4 participants