Custom Linters
Trunk Code Quality allows you to define custom linters. If a linter is not within the list of supported linters or you have a bespoke solution, you can define a custom linter.
Defining a Custom Linter
You can define linters right in your .trunk/trunk.yaml
file in your repo. These definitions have the same configurable parameters as in our public plugins repo or your own plugins repo.
Pass-Fail Linter Script Example
For example, you can define a simple pass-fail linter that runs a custom script file. The linter passes or fails based on the status code returned.
Inline Grep Command Example
You can also define simple linters inline using tools like grep
. This linter will grep against your custom regex pattern, format the output using sed, and then parse the output into pattern groups using a regex output for Trunk Code Quality to report.
To see the configurable fields available Linter Definition Reference.
Contributing a New Linter
The Trunk Code Quality plugins repo is public and welcomes contributions. Feel free to open a PR if the new custom linter you defined could be useful to others. You can reach out to us on Slack if you need a hand.
Last updated