Files
PhotonVision/docs/source/docs/contributing/linting.md
Sam Freund 2cde701cff Add documentation for linting (#2166)
## Description

This adds documentation for how to lint PhotonVision, as it is not
available elsewhere and people have historically needed to figure it out
for themselves. It also adds an alias for linting PV.

## Meta

Merge checklist:
- [x] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [x] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added
2025-11-02 03:38:51 +00:00

2.0 KiB

Linting the PhotonVision Codebase

Versions

:::{note} If you work on other projects that use different versions of the same linters as PhotonVision, you may find it beneficial to use a venv instead of installing the linters globally. This will allow you to have different versions of the same linter installed for different projects. :::

The correct versions for each linter can be found under the linting workflow located here. For doc8, the version can be found in docs/requirements.txt. If you've linted, and are still unable to pass CI, please check the versions of your linters.

Frontend

Linting the frontend

In order to lint the frontend, run pnpm -C photon-client lint && pnpm -C photon-client format. This should be done from the base level of the repo.

Backend

wpiformat installation

To lint the backend, PhotonVision uses wpiformat and spotless. Spotless is included with gradle, which means installation is not needed. To install wpiformat, run pipx install wpiformat. To install a specific version, run pipx install wpiformat==<version>.

Linting the backend

To lint, run ./gradlew spotlessApply and wpiformat.

Documentation

doc8 installation

To install doc8, the python tool we use to lint our documentation, run pipx install doc8. To install a specific version, run pipx install doc8==<version>.

Linting the documentation

To lint the documentation, run doc8 docs from the root level of the docs.

Alias

The following alias can be added to your shell config, which will allow you to lint the entirety of the PhotonVision project by running pvLint. The alias will work on Linux, macOS, Git Bash on Windows, and WSL.

alias pvLint='wpiformat -v && ./gradlew spotlessApply && pnpm -C photon-client lint && pnpm -C photon-client format && doc8 docs'