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
amarvin added a commit to amarvin/pre-commit-hooks that referenced this issue Apr 12, 2024
asottile pushed a commit to amarvin/pre-commit-hooks that referenced this issue Apr 20, 2024
asottile added a commit that referenced this issue Apr 20, 2024
Continues processing JSONs even if hook fails (fixes #1038)
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