Skip to content

Code Style

Terranova enforces consistent code style via pre-commit hooks.

Setup

Install pre-commit hooks after cloning:

source .venv/bin/activate
pre-commit install

Once installed, the hooks run automatically on git commit. To run them manually:

pre-commit run --all-files

Python

Formatter: Black (v22.3.0)

Black reformats Python code with no configuration — just run it:

.venv/bin/black .

Linter: flake8 (v3.9.2) via pyproject-flake8

Flake8 configuration is in pyproject.toml. Run it with:

.venv/bin/pflake8 .

Frontend (TypeScript / JavaScript)

Formatter: Prettier (v2.4.1)

Prettier configuration is in .prettierrc. Files excluded from formatting are listed in .prettierignore.

Run Prettier manually:

cd terranova/frontend
pnpm exec prettier --write .

Editor configuration

Most editors support Black and Prettier natively via extensions. Configure your editor to format on save using the project's formatter settings for the best experience.

  • VS Code: Install the ms-python.black-formatter and esbenp.prettier-vscode extensions
  • JetBrains IDEs: Black and Prettier are supported via the built-in external tools configuration