templates
templates copied to clipboard
Add Trunk Code Quality as a metalinter.
What does this PR do?
This repo has a ton of languages and is difficult to lint, so I'd like to introduce a tool to help solve this issue. Trunk Code Quality is a metalinter. It does these things:
- Hermetically installs the dependencies needed to run any of the many static analysis tools on first run, so you don't need to tell maintainers to install them independently. It will maintain those installs, upgrade them, etc.
- Allows you to configure how they're run, what level of warnings are blocking, the exact command it executes, how it outputs, etc.
- Allows you to share the configuration between repos, so that many repos can pull from the same set of configs for Trunk Code Quality.
- Runs in a way called "hold-the-line", which means it's git aware. Only the files changed in a PR/commit is linted, so that you don't need to fix all issues at once. You can fix as you change files.
- Standardizes the output of these many linters.
- Runs in CI, annotates PRs, and supports nightly runs and reporting.
How to run the linter
- The linter comes with a
launcher
that installs the platform-appropriate version of Trunk on your machine. - Run
trunk check
to run linter and formatters on changes in your branch vs main. - Run
trunk fmt
to run formatters and apply fix, only. - Run
trunk check --all
to run on all files - Run
trunk check --filter="prettier" --sample=5 ./node/
to run only prettier, on every 5 files, for only the node folder.