Documentation Index
Fetch the complete documentation index at: https://docs.trunk.io/llms.txt
Use this file to discover all available pages before exploring further.
Output Sources
The output format that Trunk expects from a linter is determined by itsoutput type.
stdout, stderr or tmp_file
trunk generally expects a linter to output its findings to stdout, but does support other output mechanisms:
read_output_from | Description |
|---|---|
stdout | Standard output. |
stderr | Standard error. |
tmp_file | If ${tmpfile} was specified in command, the path of the created ${tmpfile}. |
Output Types
Trunk supports several different generic output types. Most linters will use one of these output types, but if your linter doesn’t conform well to any of these specifications, you can also write a custom parser. In general, SARIF should be preferred over other formats because it is the most flexible and battle tested. Trunk currently supports the following linter output types.| Linter Type | Autofix support | Description |
|---|---|---|
sarif | ✓ | Produces diagnostics as Static Analysis Results Interchange Format JSON. |
lsp_json | Produces diagnostics as Language Server Protocol JSON. | |
pass_fail | Writes a single file-level diagnostic to stdout. | |
regex | Produces diagnostics using a custom regex format. | |
arcanist | ✓ | Produces diagnostics as Arcanist JSON. |
rewrite | ✓ | Writes the formatted version of a file to stdout. |
SARIF
output: sarif linters produce diagnostics in the Static Analysis Results Interchange Format:
LSP JSON
output: lsp_json linters output issues as Language Server Protocol JSON.
Pass/Fail Linters
output: pass_fail linters find either:
- no issues in a file, indicated by exiting with
exit_code=0, or - a single file-level issue in a file, whose message is the linter’s
stdout, indicated by exiting
withexit_code=1.
Note: Exiting withexit_code=1but writing nothing tostdoutis considered to be a linter tool failure. Note:pass_faillinters are required to havesuccess_codes: [0, 1]
Regex
output: regex linters produce output that can be parsed with custom regular expressions and named capture groups. The regular expression is specified in the parse_regex field.
regex supports capturing strings from a linter output for the following named capture groups:
path: file path (required)line: line numbercol: column numberseverity: one ofnote,notice,allow,deny,disabled,error,info,warningcode: linter diagnostic codemessage: description
trunk diagnostic that looks like this:
Note: For additional information on building custom regular expressions, see re2. More complicated regex may require additional escape characters in yaml configuration.
Arcanist
You can also output JSON using the Arcanist format.Formatters
output: rewrite linters write the formatted version of a file to stdout; this becomes an autofix which trunk can prompt you to apply (which is what trunk check does by default) or automatically apply for you (if you trunk check --fix or trunk fmt).
For example, if you wanted a linter to normalize your line endings, you could do this:
formatter: true will cause trunk fmt to run this linter.