-
Notifications
You must be signed in to change notification settings - Fork 653
feat(rome_json_formatter): implement JSON array formatting #4064
Conversation
✅ Deploy Preview for docs-rometools canceled.
|
Some of the prettier snapshot tests are failing, should I accept those? |
… errors Some prettier tests for JSON5 are failing after implementing array formatting in #4064 The tests fail because the formatting returns a `FormatError::SyntaxError` if a mandatory child node is missing but the error is never handled by the JSON formatting. This PR fixes this by * Gracefully handle missing values on the root value by calling into verbatim formatting if that's the case * Use `format_or_verbatim` when formatting values I had to pull out the `format_or_verbatim` from the `rome_js_formatter` and move it to `rome_formatter` so that it can be re-used between js and json formatting.
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.
Yes. You'll need to update the prettier snapshots. Ideally, most of the output will match prettier precisely after your changes (as all JSON formatting is implemented).
However, you have to wait for #4066 to land because some JSON 5 tests are failing because of a syntax error on the root level.
… errors Some prettier tests for JSON5 are failing after implementing array formatting in #4064 The tests fail because the formatting returns a `FormatError::SyntaxError` if a mandatory child node is missing but the error is never handled by the JSON formatting. This PR fixes this by * Gracefully handle missing values on the root value by calling into verbatim formatting if that's the case * Use `format_or_verbatim` when formatting values I had to pull out the `format_or_verbatim` from the `rome_js_formatter` and move it to `rome_formatter` so that it can be re-used between js and json formatting.
Co-authored-by: Micha Reiser <micha@reiser.io>
I'll wait then |
… errors (#4066) Some prettier tests for JSON5 are failing after implementing array formatting in #4064 The tests fail because the formatting returns a `FormatError::SyntaxError` if a mandatory child node is missing but the error is never handled by the JSON formatting. This PR fixes this by * Gracefully handle missing values on the root value by calling into verbatim formatting if that's the case * Use `format_or_verbatim` when formatting values I had to pull out the `format_or_verbatim` from the `rome_js_formatter` and move it to `rome_formatter` so that it can be re-used between js and json formatting.
The last thing missing after merging main is to use the The logic should work similar to the JavaScript array formatting tools/crates/rome_js_formatter/src/js/lists/array_element_list.rs Lines 28 to 61 in 2655264
|
done |
Summary
JSON Array Formating #2570