Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Trunk Code Quality as a metalinter. #302

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gewenyu99
Copy link

@gewenyu99 gewenyu99 commented Aug 15, 2024

What does this PR do?

This repo has a ton of languages and is difficult to lint, so I'd like to introduce a tool to help solve this issue. Trunk Code Quality is a metalinter. It does these things:

  • Hermetically installs the dependencies needed to run any of the many static analysis tools on first run, so you don't need to tell maintainers to install them independently. It will maintain those installs, upgrade them, etc.
  • Allows you to configure how they're run, what level of warnings are blocking, the exact command it executes, how it outputs, etc.
  • Allows you to share the configuration between repos, so that many repos can pull from the same set of configs for Trunk Code Quality.
  • Runs in a way called "hold-the-line", which means it's git aware. Only the files changed in a PR/commit is linted, so that you don't need to fix all issues at once. You can fix as you change files.
  • Standardizes the output of these many linters.
  • Runs in CI, annotates PRs, and supports nightly runs and reporting.

How to run the linter

  • The linter comes with a launcher that installs the platform-appropriate version of Trunk on your machine.
  • Run trunk check to run linter and formatters on changes in your branch vs main.
  • Run trunk fmt to run formatters and apply fix, only.
  • Run trunk check --all to run on all files
  • Run trunk check --filter="prettier" --sample=5 ./node/ to run only prettier, on every 5 files, for only the node folder.

@gewenyu99
Copy link
Author

A quick demo
https://youtu.be/E8u88NzJCzY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant