-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
feat(formatter): add option json.formatter.trailingComma
#1948
Conversation
✅ Deploy Preview for biomejs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@Sec-ant I'd like your input here. What do you think? |
CodSpeed Performance ReportMerging #1948 will degrade performances by 7.75%Falling back to comparing Summary
Benchmarks breakdown
|
For the VS Code extension at least, I would suggest the default value for I'm less opinionated about the defaults for the CLI, although I guess it makes more sense if they'd be the same? |
Hey, thanks for mentioning. Here are my two cents:
|
32f5328
to
2cd670e
Compare
I applied all the suggestions. A couple of notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ematipico I left a few reviews which I hope wouldn't bother you too much.
And a last question is shouldn't we also update the name of javascript.formatter.trailingComma
to javascript.formatter.trailingCommas
? This is certainly a breaking change but now that we decide to use plural forms for every other option, I assume you agree with me right?
@@ -619,6 +619,10 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b | |||
|
|||
### Formatter | |||
|
|||
#### New features | |||
|
|||
- Add option `json.formatter.trailingComma`, to provide a better control over the trailing comma in JSON/JSONC files. Its default value is `"none"`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json.formatter.trailingCommas
} | ||
|
||
#[test] | ||
fn format_omits_json_trailing_comma_omit() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is only for testing, but the function name seems a little confusing?
/// Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to "omit". | ||
#[partial(bpaf( | ||
long("json-formatter-trailing-commas"), | ||
argument("omit|allow"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use none
and all
or is there something I missed with the omit
and allow
choices?
@@ -694,6 +694,16 @@ How many characters can be written on a single line in JSON (and its super langu | |||
|
|||
> Default: `80` | |||
|
|||
### `json.formatter.trailingComma` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json.formatter.trailingCommas
Thank you for the review @Sec-ant , I will address them later. I won't change existing options because they are breaking changes. We can create new options and deprecate the old ones, and eventually remove everything in V2.0 |
Summary
This is a follow up of #1944
Closes #926
This PR adds the option
json.formatter.trailingComma
. Its options are the same ofjs.formatter.trailingComma
, exception fores5
, which doesn't have anything to do with JSON.Warning
This option changes its value if
json.parser.allowTrailingComma
is set totrue
. That was done to have both parser and formatter to behave in the same way.Let me know what you think about this decision ⬆️ Logically, I thought it made sense, because if a user wants to parse JSON trailing commas, and it makes sense to leave them there.
Test Plan
I added a new test case