We've added code formatting and linting in the form of pre-commit hooks. Whether a developer would like to use these hooks to automatically format/lint their code is a personal choice. But for uniformity, in PRs we should still test whether new code conforms to the formatting we've agreed to.
This would also ensure our codebases remain uniform in the case that a developer's local formatting tools malfunction.
Proposal
Add black and prettier tests to scripts/run-tests.sh.
If you have a CI setup, run the following as part of it to make sure that everyone runs Prettier. This avoids merge conflicts and other collaboration issues!
npx prettier --check .
--check is like --write, but only checks that files are already formatted, rather than overwriting them. prettier --write and prettier --check are the most common ways to run Prettier.
By default Black reformats the files given and/or found in place. Sometimes you need Black to just tell you what it would do without actually rewriting the Python files.
There’s two variations to this mode that are independently enabled by their respective flags. Both variations can be enabled at once.
Background
We've added code formatting and linting in the form of pre-commit hooks. Whether a developer would like to use these hooks to automatically format/lint their code is a personal choice. But for uniformity, in PRs we should still test whether new code conforms to the formatting we've agreed to.
This would also ensure our codebases remain uniform in the case that a developer's local formatting tools malfunction.
Proposal
Add
black
andprettier
tests toscripts/run-tests.sh
.Doc Snippets
Prettier:
Black:
Deliverables
I'll update the Django and Wagtail templates.
Timeline
Less than one day.