We're running into issues with md handlers that expect this kind of 4-space indent. It should be cross-compatible with GH, so switch, even though it feels a little churny.
Manual edits are to:
- .prettierrc.yaml:
- rename from .prettierrc
- add tabWidth (primary change)
- add trailingComma (fix vimPrettier skew)
- contribution_tools.md: Fix remarks about .prettierrc.yaml
- pre-commit-toc.js: indent, bullets
- pre-commit-proposal-list.py: indent of output
The rest is the result of `pre-commit run --all-files`
Unfortunately this'll probably depend on the change being propagated into PR branches, so I wouldn't be surprised if we see regressions for a bit. We'll also need to nudge people to update .vimrc's. Hopefully the pre-commit GH action helps catch issues.
3.0 KiB
Contribution tools
The Carbon language project has a number of tools used to assist in preparing contributions.
Table of contents
pre-commit
We use pre-commit to run various checks. This will automatically run important checks, including formatting.
To set up pre-commit:
- Follow the installation instructions.
- Enable per-repo:
pre-commit install- We already have
pre-commitconfigured for Carbon repos -- do not go through theQuick startinstructions.
- We already have
- pre-commit may be run either automatically with
git commitor manually withpre-commit run.- When files are modified, including by pre-commit failures,
git addwill need to be run to include the modifications in the commit, and the commit re-started.
- When files are modified, including by pre-commit failures,
When modifying or adding pre-commit hooks, please run
pre-commit run --all-files to see what changes.
black
pre-commit enabled: If you're using pre-commit, it will run this. Installing and running manually is optional, but may be helpful.
We use Black to format Python code. Although Prettier is used for most languages, it doesn't support Python.
codespell
pre-commit enabled: If you're using pre-commit, it will run this. Installing and running manually is optional, but may be helpful.
We use codespell to spellcheck common errors. This won't catch every error; we're trying to balance true and false positives.
markdown-toc
pre-commit enabled: If you're using pre-commit, it will run this. Installing and running manually is optional, but may be helpful.
We use markdown-toc to provide GitHub-compatible tables of contents for some documents.
If run manually, specify --bullets=- to use Prettier-compatible bullets, or
always run Prettier after markdown-toc.
Prettier
pre-commit enabled: If you're using pre-commit, it will run this. Installing and running manually is optional, but may be helpful.
We use Prettier for formatting. There is an rc file for configuration.
vim-prettier
If you use vim-prettier, the
.prettierrc.yaml should still apply as long as config_precedence is set to
the default file-override. However, we may need to add additional settings
where the vim-prettier default diverges from prettier, as we notice them.