NCATSTranslator / testing

Materials and tools for testing Translator components
1 stars 9 forks source link

Add pre-commit to auto-format JSON #106

Open brettasmi opened 3 years ago

brettasmi commented 3 years ago

Last Friday, I embarrassingly failed to manually parse a JSON because I struggled with its formatting. The JSON in this repo varies in its formatting and can make some of these queries difficult to parse quickly. To help with this issue, this PR adds a pre-commit hook to auto-format any staged JSON using pre-commit and its prettier plugin

In practice it works as follows:

Since @MarkDWilliams is essentially the only person who commits to this repository, I thought it would be a good test case for translator to see if it could be adopted more widely (e.g. minihackathon repo) if a single-user repo is successful.

I will make comments on the individual files to explain their function.

Please feel free to reject this PR if you think it will inhibit your workflow. It's just a suggestion that I think could make life easier, but I understand it complicates a widely used repo.

@MarkDWilliams, if you choose to merge this PR, it might be a good idea to do the following on a formatting branch after setting up precommit per the README:

pre-commit run --all-files

Bonus: you get a free dark green block on your git profile :)