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

pretty-format-json stops formatting JSONs when it encounters one with incorrect format (e.g. JSON5 comments) #1038

Closed
amarvin opened this issue Apr 12, 2024 · 0 comments · Fixed by #1039

Comments

@amarvin
Copy link
Contributor

amarvin commented Apr 12, 2024

Transferred from pre-commit/pre-commit#3124.

pretty-format-json prints "Input File {json_file} is not a valid JSON, consider using check-json" when it encounters an incorrectly formatted JSON file (e.g. with JSON5 comments), but it's not clear from that message that it then stops further processing files.

As pre-commit can partition the processed files into batches, this makes it even harder to tell as multiple batches of files can fail midway through with a few "X is not a valid JSON" messages printed, giving the impression that all the JSONs were formatted (or attempted formatted) and only those files printed are incorrect. The reality is that some JSONs may not have been formatted. I think this hook should try to format every JSON and only fail at the end if any have an invalid JSON format.

@amarvin amarvin changed the title pretty-format-json --all-files stops formatting JSONs when it encounters one with incorrect format (e.g. JSON5 comments) pretty-format-json stops formatting JSONs when it encounters one with incorrect format (e.g. JSON5 comments) Apr 12, 2024
asottile added a commit that referenced this issue Apr 20, 2024
Continues processing JSONs even if hook fails (fixes #1038)
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this issue Oct 9, 2024
… (hetznercloud/fleeting-plugin-hetzner!125)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [pre-commit/pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks) | repository | major | `v4.6.0` -> `v5.0.0` |

Note: The `pre-commit` manager in Renovate is not supported by the `pre-commit` maintainers or community. Please do not report any problems there, instead [create a Discussion in the Renovate repository](https://github.com/renovatebot/renovate/discussions/new) if you have any questions.

---

### Release Notes

<details>
<summary>pre-commit/pre-commit-hooks (pre-commit/pre-commit-hooks)</summary>

### [`v5.0.0`](https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0): pre-commit-hooks v5.0.0

[Compare Source](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)

##### Features

-   `requirements-txt-fixer`: also remove `pkg_resources==...`.
    -   [#&#8203;850](pre-commit/pre-commit-hooks#850) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1030](pre-commit/pre-commit-hooks#1030) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
-   `check-illegal-windows-names`: new hook!
    -   [#&#8203;1044](pre-commit/pre-commit-hooks#1044) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;589](pre-commit/pre-commit-hooks#589) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1049](pre-commit/pre-commit-hooks#1049) MR by [@&#8203;Jeffrey-Lim](https://github.com/Jeffrey-Lim).
-   `pretty-format-json`: continue processing even if a file has a json error.
    -   [#&#8203;1039](pre-commit/pre-commit-hooks#1039) MR by [@&#8203;amarvin](https://github.com/amarvin).
    -   [#&#8203;1038](pre-commit/pre-commit-hooks#1038) issue by [@&#8203;amarvin](https://github.com/amarvin).

##### Fixes

-   `destroyed-symlinks`: set `stages` to `[pre-commit, pre-push, manual]`
    -   MR [#&#8203;1085](pre-commit/pre-commit-hooks#1085) by [@&#8203;AdrianDC](https://github.com/AdrianDC).

##### Migrating

-   pre-commit-hooks now requires `pre-commit>=3.2.0`.
-   use non-deprecated names for `stages`.
    -   [#&#8203;1093](pre-commit/pre-commit-hooks#1093) MR by [@&#8203;asottile](https://github.com/asottile).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMTAuMiIsInVwZGF0ZWRJblZlciI6IjM4LjExMC41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant