Comment on page
Frequently Asked Questions
clang-tidyfor C++ projects. There are plenty more linters you can use, however. You can see all possible (built in) linters with
trunk check list
and enable a new linter with
trunk check enable cool_new_linter
If you aren’t seeing any issues the likely cause is that your local repo is clean. By default Trunk Check only processes new changes to your codebase (read about hold-the-line). To scan older changes try running:
trunk check --samples=5
to look at a sampling of each linter's issues for 5 random files
trunk check --all
One reason for seeing too many issues is that you may have multiple linters configured which are all printing output. Try running just one linter at a time with the
Linters are usually configured to be very aggressive and flag many potential bugs and security risks. Sometimes you may want to tell a linter “Trust me, I know what I’m doing”. If that is the case you can configure a linter to ignore certain issues.
.eslintrcfile is correctly set up to handle TypeScript. Also make sure the
extendssection lists the
typescriptdefaults after the
eslint:recommendedones, since ESLint uses last one wins priority.
You can also try running
trunk check --verboseto see what’s going on under the hood. If that still doesn’t work then please reach out to us on our community Slack with the output of
trunk check --verbose.
A linter is a tool that looks for potential code errors such as security vulnerabilities, code spell, anti-patterns, and other things that might be a problem at runtime. Linters generally report warnings and errors but do not modify code. A formatter is a tool that reformats code to fit a particular style (indentation, sorting imports, semicolons, etc). Formatters always modify code. In general, even though your setup may use many different linters we recommend using only one formatter per filetype.
Ruff and Black are another example of a linter/formatter pair that can collide with each other if not configured properly. If you enable Ruff but don’t already have a ruff config, Trunk Check will generate a
ruff.tomlfile for you automatically. This ruff.toml is formatter friendly, meaning that it will silence formatting related warnings and allow Black to take care of them more quickly and easily. This is another example of tuning your linters with linter configs.
Hold The Line (HTL) is the principle that Trunk Check will only run on new changes in your codebase, rather than every file in the whole repo. This allows you to use Check to improve your codebase incrementally rather than having to address all of the issues at once. HTL also runs checks much faster than scanning the entire codebase would.
If you specifically want to work on older files you can do that by running Check directly on that file
trunk check foo.file
trunk check --all
Sometimes Trunk Check says there is some
Incorrect formattingin your images. Check usually enables a program called Oxipng which can optimize images to make them smaller (without losing any data). The error message just means that Oxipng wants to optimize those images. You can do that with
trunk fmt filename.png. You can also disable Oxipng with
trunk check disable oxipng.
Trunk Check uses hermetically versioned tools, which means it downloads a separate copy of the tools and runtime for each tool version. Over time, as tools are upgraded, this can leave a lot of unnecessary files in the cache directory. Trunk is working on a way to automatically remove unneeded files from the cache. In the meantime you can safely clear your cache with
trunk cache clean --all
trunk installagain in your repos.
‘Trunk supports over 90 different linters, and we are always adding more! Some linters are easier to configure than others, and we enable many of them out-of-the-box. You can read more about specific linter setup here. Trunk is intended to be the one-stop-shop for running all of your linters.
To see a list of currently available linters run
trunk check list
When upgrading from Trunk CLI versions 1.14.2 or older, you will have to rerun
trunk upgradein order to get all available fixes.
You can use a different version of a runtime by changing its version in the enabled section of your
.trunk/trunk.yamlfile in the
If you want to pin the version of a runtime that a particular tool uses, you can do that with an
!after the version number in your
However, some versions are not supported in Trunk check by default. If you need to specify an unsupported version, for example to use a particular python version that has been deprecated, you would need to override the
downloadssection as necessary. Check out the definition for python downloads here. In general we advise against using unsupported runtimes.
Every linter defines a set of file types that it wants to work with in a section of the YAML called
files. To change this you need to override the files section of that linter’s definition. More linter application file types.
Suppose you are using the foo-linter which normally runs on
foofiles. The config might look like this:
- name: foo
- name: foo-linter
- name: lint
run: echo “foo”
success_codes: [0, 1]
To add support for
barfiles add this to your
trunk.yamlfile. The first part defines the
barfile type, and the second says that
- name: bar
- name: foo-linter
Last modified 23d ago