After initializing Trunk, you can begin scanning for issues in your repo, and decide whether to fix them up front, fix them incrementally as you code, or ignore irrelevant suggestions. This page walks through the process of linting locally and fixing existing issues.Documentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-flaky-tests-new-monitors.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Running for the first time
After initializing Trunk Code Quality, you can run all tools on all files to look for existing issues. You can run Trunk on all files in your repo with this command. This will output all issues detected by every linter enabled in your project.Hold-the-lineYou don’t need to fix all issues upfront. Trunk lets you fix linter errors incrementally with hold-the-line.Learn more about hold-the-line.
Issues in pull requests
You can reproduce issues discovered in CI by runningtrunk check and addressing issues.
If trunk check continues to identify new Code Quality issues on your PR, first try merging the latest changes from your base branch. Trunk will rebase your changes on top of the current HEAD in main to ensure it catches all issues before merging.
If this continues to fail, then run git checkout refs/pull/<PR number>/merge && trunk check. This is a reference to the merge commit GitHub creates.
Hold-the-line
After initializing Trunk, you can begin scanning for issues in your repo, and decide whether to fix them up front, fix them incrementally as you code, or ignore irrelevant suggestions. This page walks through the process of linting locally and fixing existing issues. If you only want to prevent new issues from new code changes, skip to prevent-new-issues.Running for the first time
After initializing Trunk Code Quality, you can run all tools on all files to look for existing issues. You can run Trunk on all files in your repo with this command. This will output all issues detected by every linter enabled in your project.Trunk is Git awareWhen you run
trunk check without specifying --all, it will only run on files you’ve modified according to git. Remember to specify a base branch if you’re using something other than main or master.Fixing existing issues
There are different approaches to dealing with existing issues, such as runningformat and applying automatic fixes, ignoring irrelevant issues, and sampling linters/files. This section walks you through the process to make fixing issues easier.
Hold-the-lineYou don’t need to fix all issues upfront. Trunk lets you fix linter errors incrementally with hold-the-line.Learn more about hold-the-line.
Running formatters and applying fixes
Some issues can be fixed automatically. You can apply fixes by running the following command.Overwhelmed by existing issues?
You can also focus on the issues revealed by 1 linter at a time.Disabling linters
Some recommended linters could be unnecessary for your project. You can disable and enable linters with these commands:Ignore issues
If there are warnings that don’t apply to your project, you can ignore them by line, by file, or by class of warnings in each linter’s config file. You can tell Trunk Code Quality to ignore a line in your source code with a special comment like this:clang-tidy For more complex ignore commands, see Ignoring Issues.
Sometimes you may want to ignore entire files or groups of files, such as generated code. To ignore them, use the ignore key to your .trunk/trunk.yaml file:
.trunk/configs
For example, these are the ignores for Markdownlint in .trunk/configs/.markdownlint.yaml:
Issues in pull requests
You can reproduce issues discovered in CI by runningtrunk check and addressing issues.
If trunk check continues to identify new Code Quality issues on your PR, first try merging the latest changes from your base branch. Trunk will rebase your changes on top of the current HEAD in main to ensure it catches all issues before merging.
If this continues to fail, then run git checkout refs/pull/<PR number>/merge && trunk check. This is a reference to the merge commit GitHub creates.