Files
carbon-lang/docs/project/contribution_tools.md
T
Jon Meow 65cfd73b78 Enable codespell pre-commit (#90)
This catches some common spelling errors, but is *not* an exhaustive spell-checker. The only false positive is "rouge" in Gemfile.lock, which is why I'm excluding that file.

True positives are in the change, and it does catch the "langauge" typo I keep making, which zygoloid fixed for me in a few spots. False negatives are:

- virmc
- Announcemented
- propsal

For comparison:

- cspell (https://www.npmjs.com/package/cspell) is too aggressive and has a small dictionary
  - Caught the false negatives, but many false positives, including 'LLVM', 'roadmap', 'Carruth'
- https://github.com/lorenzwalthert/precommit has a spellcheck, but config looks ruby-specific
2020-06-25 08:37:03 -07:00

2.6 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-commit configured for Carbon repos -- do not go through the Quick start instructions.
  • pre-commit may be run either automatically with git commit or manually with pre-commit run.
    • When files are modified, including by pre-commit failures, git add will need to be run to include the modifications in the commit, and the commit re-started.

When modifying or adding pre-commit hooks, please run pre-commit run --all-files to see what changes.

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, it may help to add to your .vimrc:

let g:prettier#config#print_width = '80'
let g:prettier#config#tab_width = '2'
let g:prettier#config#use_tabs = 'false'
let g:prettier#config#prose_wrap = 'always'