Linting & Formatting
The repository contains linting and formatting tools so all code and documentation follows the same guidelines.
It is required that all linters pass wihtout warnings / errors before code is merged.
However, if you ever do need to disable the linters and formatters you can prepend SKIP=flake8 to
your git command
1 | |
How to setup?
Reccomended: Install the Prettier vscode extension and enable auto format.
Installpre-commit. This is a tool that can execute code before a
commit is done (git commit command). We use this to run formatting and linting automatically.
pre-commit is included so it should be automatically installed if you installed the requirements
from requirements.txt.
You can run the command below to install pre-commit locally.
1 | |
If pre-commit is installed yet you can install it with pip.
1 | |
Note: it could take some time on your first git commit to install all the dependencies
What to do if a check fails during your git commit
If a check shows that if fails when you do a git commit, fix the errors that are shown. (Note that
a check will fail if a fail was changed)
Then add all changes again git add . and execute your git commit command again.
What tools are used?
In order the following tools are used:
- check yaml syntax, make all files have the same line endings and remove trailing whitespace
- Format and lint python code
- Format backend code and markdown using Prettier
- Use
eslintto check typescript code - Use
clang-formatto format c++ code according to google standards - Use
cpp-lintto check code according to google standards.
Each entry in the list is called a "stage"
Configuration
Prettier is configured in the .prettierrc dotfile.
cpplint rules are configured in CPPLINT.cfg
eslint rules are configured in web/eslint.config.mts
Run linters locally
You can run any stage of pre-commit individually and locally.
Here are all the commands:
Check yaml:
1 | |
End of file fixer:
1 | |
Fix trailing white space:
1 | |
Python formatter
1 | |
Format using prettier:
1 | |
Clang format:
1 | |
C++ linter
1 | |