question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support the Pre-Commit framework with a .pre-commit-hooks.yaml file

See original GitHub issue

Expected Behavior Question/Feature request

This is more a blatant question and feature request:

Would a basic config for the pre-commit framework be possible, and if so, even desired for the repo to have?

It would be implemented by having a .pre-commit-hooks.yaml file in the root of the repo, that pre-commit can be pointed at in other projects to implement commit linting.

Possible Solution

Adding a .pre-commit-hooks.yaml to the project to be able to be used by the pre-commit tool simply. A number of projects, such as Prettier and Python’s Black provide such files to allow the tool to be transparently installed and run as git hooks.

Context

Pre-commit is a tool for declaratively managing git hooks in a repo, not unlike husky. The major difference is that pre-commit manages pulling down and transparently installing the tools itself, regardless of language, allowing projects to use software that don’t necessarily suit being a part of a project’s dependencies.

Many projects provide a .pre-commit-hooks.yaml themselves, for just this reason.

While Husky is the gold standard in the JS world, it’s not ideal for multi-language projects, as you either need to set up a dedicated package.json in the root of the repository, or even less elegantly, configure it just in sub-folder, likefrontend/ for example. I believe commit linting is such a powerful tool, that anything we can do to make it more widespread is a big win, and would lead to wider spread adoption outside of just javascript environments.

Incidentally, I have run across a small repo that achieves just this, though a first party equivalent would be a much healthier signal.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:28
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
falcorockscommented, Feb 9, 2021

Hey guys, I would also love to see first party support for this. As already mentioned by others, https://github.com/alessandrojcm/commitlint-pre-commit-hook project has it done for you, just a matter of copying it here! I’m sure @alessandrojcm would be fairly proud of it!

5reactions
pkochcommented, Aug 11, 2021

Added a PR, let’s see if it gets traction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pre-commit
A framework for managing and maintaining multi-language pre-commit hooks. ... Add a file called .pre-commit-config.yaml to the root of your project.
Read more >
Getting Started with Python Pre-commit Hooks
This article is focused on pre-commit hooks. Pre-commit ... We specify these Python hooks in a YAML file called pre-commit-config.yaml .
Read more >
Some out-of-the-box hooks for pre-commit - GitHub
Contribute to pre-commit/pre-commit-hooks development by creating an account on GitHub. ... Attempts to load all yaml files to verify syntax.
Read more >
Some Pre-commit git hooks for Python
Pre -commit hooks are a great way to automatically check and clean the code. They are executed when committing changes to git ....
Read more >
How to use git pre-commit hooks, the hard way and the easy ...
What is special about the pre-commit hook? This hook runs when you run the command git commit . The hook runs before a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found