LogoLogo
SlackLogin
  • Overview
    • Welcome
  • Setup & Configuration
    • Connecting to Trunk
    • Managing Your Organization
      • GitHub App Permissions
  • Integration with Slack
  • Flaky Tests (Beta)
    • Overview
    • Get Started
      • Test Frameworks
        • Android
        • Bazel
        • Behave
        • cargo-nextest
        • Cypress
        • Dart Test
        • Go
        • GoogleTest
        • Gradle
        • Jasmine
        • Jest
        • Karma
        • Maven
        • minitest
        • Mocha
        • Nightwatch
        • NUnit
        • Pest
        • PHPUnit
        • Playwright
        • Pytest
        • Robot Framework
        • RSpec
        • Swift Testing
        • Vitest
        • XCTest
        • Other Test Frameworks
      • CI Providers
        • Azure DevOps Pipelines
        • BitBucket Pipelines
        • Buildkite
        • CircleCI
        • Drone CI
        • GitHub Actions
        • GitLab
        • Jenkins
        • Semaphore CI
        • TeamCity
        • Travis CI
        • Other CI Providers
    • Dashboard
    • Flaky Test Detection
    • Quarantining
    • PR Comments
    • Ticketing Integrations
      • Jira Integration
      • Linear Integration
      • Other Ticketing Platforms
    • Webhooks
      • Slack Integration
      • Microsoft Teams Integration
      • GitHub Issues Integration
      • Linear Integration
    • Uploader CLI Reference
  • Merge Queue
    • Overview
    • How does it work?
    • Setup
      • Quick Start
      • Settings
      • Integration for Slack
    • Concepts and Optimizations
      • Predictive Testing
      • Optimistic Merging
      • Pending Failure Depth
      • Anti-Flake Protection
      • Batching
      • Parallel Queues
        • Bazel
        • Nx
        • API
      • FAQ
    • Priority
    • Managing Merge Queue
      • Using the Merge UI
      • Metrics
      • Command Line
    • Webhooks
    • Reference
  • Code Quality
    • Overview
    • Why Metalinters?
      • How does it work?
      • Why Code Quality?
    • Setup & Installation
      • Initialize Trunk
      • Local Linting
      • Linting in CI
      • Nightly Report (Deprecated)
    • IDE Integration
      • VSCode
      • Neovim
      • GitHub Codespaces
    • Linters
      • Supported Linters
        • Actionlint
        • Ansible-lint
        • Autopep8
        • Bandit
        • Biome
        • Black
        • Brakeman
        • buf
        • Buildifier
        • cfnlint
        • Checkov
        • circleci
        • ClangFormat
        • clang-tidy
        • Clippy
        • cmake-format
        • codespell
        • cspell
        • cue-fmt
        • dart
        • deno
        • Detekt
        • djlint
        • dotenv-linter
        • dotnet-format
        • dustilock
        • ESLint
        • Flake8
        • git-diff-check
        • Gitleaks
        • Gofmt
        • gofumpt
        • goimports
        • gokart
        • golangci-lint
        • golines
        • google-java-format
        • graphql-schema-linter
        • hadolint
        • haml-lint
        • isort
        • iwyu
        • ktlint
        • kube-linter
        • markdown-link-check
        • markdown-table-prettify
        • Markdownlint
        • markdownlint-cli2
        • mypy
        • nancy
        • nixpkgs-fmt
        • opa
        • OSV-Scanner
        • Oxipng
        • perlcritic
        • perltidy
        • php-cs-fixer
        • phpstan
        • pmd
        • pragma-once
        • pre-commit-hooks
        • Prettier
        • prisma
        • psscriptanalyzer
        • Pylint
        • pyright
        • regal
        • remark-lint
        • renovate
        • rome
        • rubocop
        • Ruff
        • rufo
        • rustfmt
        • scalafmt
        • semgrep
        • ShellCheck
        • shfmt
        • sort-package-json
        • sourcery
        • sql-formatter
        • SQLFluff
        • sqlfmt
        • squawk
        • standardrb
        • stringslint
        • stylelint
        • stylua
        • SVGO
        • swiftformat
        • swiftlint
        • taplo
        • Terraform
        • terragrunt
        • terrascan
        • TFLint
        • tfsec
        • tofu
        • Trivy
        • Trufflehog
        • txtpbfmt
        • vale
        • Yamllint
        • yapf
      • Run Linters
      • Manage Linters
      • Configure Linters
      • Ignoring Issues and Files
      • Custom Linters
      • Shared Configs
      • Upgrades
    • Debugging
    • Licensing
  • CLI & API References
    • CLI Reference
      • Install
      • Getting Started
        • Code Quality
        • Merge Queue
        • Flaky Tests
        • Tools
        • Actions
          • Git Hooks
        • Announce
      • Compatibility
      • Caching
      • Commands Reference
        • Code Quality
        • Actions
        • Merge
      • Configuration
        • Plugins
          • Share Config Between Codebases
          • Exporting Linter Configs
        • Runtimes
        • Tools
        • Lint
          • Definitions
          • Commands
          • Output
          • Output Parsing
          • Files and Caching
          • Dependencies
          • Auto-Enable
        • Actions
          • Notifications
          • Logging and Troubleshooting
        • Merge
        • Telemetry
        • Per User Overrides
    • API Reference
      • Flaky Tests
      • Merge Queue
      • Webhooks Reference
  • Pricing & Security
    • Security
  • Billing
  • Community & Support
  • Links
    • Open App
    • Slack Community
    • Changelog
    • Feature Requests
On this page
  • trunk check
  • Trunk Check Enable Linter
  • Trunk Check Disable Linter
  • Trunk Check List Linters
  • Trunk Check Run Format
  • Advanced Trunk Check Features
Edit on GitHub
  1. CLI & API References
  2. CLI Reference
  3. Commands Reference

Code Quality

trunk check

trunk check: Universal code checker.

Usage example

trunk check [options]

Filtering Options

  • -a, --all: Check all files instead of only changed files

  • --sample: Run each linter on N files

  • --filter: Comma-separated list of linters and/or issue codes to include or exclude

  • --exclude: Shorthand for an inverse --filter

  • --scope: Scope of checks to run {all | security}

  • --ignore: Glob pattern to exclude files from linting

  • --force: Run on all files, even if ignored

  • --include-existing-autofixes: Include existing issues that can be autofixed

CI Options

  • --ci: Run in non-interactive mode designed for CI environments

  • -j, --jobs: Number of concurrent jobs

Git Hooks Options

  • --index: Run linter on git-indexed files

  • --index-file: Run linter on git-indexed files based on specified index

  • --commit-ref: Commit ref to lint (instead of current working tree)

  • --commit-ref-from-pre-push: Commit ref to lint from the stdin of a pre-push git hook (instead of the current working tree)

Output Options

  • --show-existing: Show existing issues otherwise hidden by

  • --print-failures: Print any failures that occur

  • --diff: Diff printing mode {none | compact | full}

  • -v, --verbose: Show verbose output for debugging purposes

  • --debug: Show debug output

Behavior Options

  • -y, --fix: Automatically apply all fixes without prompting

  • -n, --no-fix: Don't automatically apply fixes

  • --cache: Disable to skip cache for all check actions

  • --ignore-git-state: Run linters even if a merge, rebase, or revert is in progress

  • --upstream: Upstream branch used to compute changed files

Trunk Check Enable Linter

trunk check enable: Enable linters for trunk check.

Usage example

trunk check enable [options]

Trunk Check Disable Linter

trunk check disable: Disable linters for trunk check.

Usage example

trunk check disable [options]

Trunk Check List Linters

trunk check list: List linters for trunk check.

Usage example

trunk check list [options]

Trunk Check Run Format

trunk fmt: List linters for trunk check.

Usage example

trunk fmt [options]

Options

Filtering Options

  • -a, --all: Check all files instead of only changed files

  • --filter: Comma-separated list of linters and/or issue codes to include or exclude

  • --exclude: Shorthand for an inverse --filter

  • --scope: Scope of checks to run {all | security}

  • --ignore: Glob pattern to exclude files from linting

  • --force: Run on all files, even if ignored

  • --ignore-git-state: Run linters even if a merge, rebase, or revert is in progress

Git Hooks Options

  • --index: Run linter on git-indexed files

  • --index-file: Run linter on git-indexed files based on specified index

  • --commit-ref: Commit ref to lint (instead of current working tree)

  • --commit-ref-from-pre-push: Commit ref to lint from the stdin of a pre-push git hook (instead of the current working tree)

Output Options

  • --show-existing: Show existing issues otherwise hidden by

  • --print-failures: Print any failures that occur

  • --diff: Diff printing mode {none | compact | full}

  • -v, --verbose: Show verbose output for debugging purposes

  • --debug: Show debug output

Behavior Options

  • -y, --fix: Automatically apply all fixes without prompting

  • -n, --no-fix: Don't automatically apply fixes

  • --cache: Disable to skip cache for all check actions

  • --ignore-git-state: Run linters even if a merge, rebase, or revert is in progress

  • --upstream: Upstream branch used to compute changed files

  • -j, --jobs: Number of concurrent jobs

Advanced Trunk Check Features

Options & Flags
Explanation

--root

Explicitly set the root of the repository to run against

--upstream

Specify the upstream branch used to calculate new vs existing issued.

--trigger

Supports running trunk check from inside a git hook. Options are manual (default), git-push, git-commit. Controls whether the check returns early and its interactivity.

--output=format

Output results in specified format: text (default) or json

--output-file=FILE

Write json results to specified file

--filter

--filter argument allows you to restrict trunk check to a subset of the linters enabled in your repository.

For example, to run eslint and isort on the entire repo:

trunk check --all --filter=eslint,isort

Alternatively, to run every linter except clang-tidy and shellcheck:

trunk check --all --filter=-clang-tidy,-shellcheck

--sample

--sample=N will attempt to run every enabled linter against the requested number of files. The goal of the sample flag is to test the setup of the linters in your repository as well as any specific configuration they might honor.

The sample command will attempt to run each linter N times, but may run fewer if not enough applicable files exist in your set of files to lint. --sample=N can be combined with any other set of options for trunk check.

For example, to run prettier against 10 different prettier supported files:

trunk check --sample=10 --filter=prettier

Alternatively, to run every linter at most 5 times against its supported files:

trunk check --sample=5

Last updated 1 month ago

--show-existing: Show existing issues otherwise hidden by

hold-the-line