feat: add support for pre-commit (#1396)

This commit is contained in:
Matthew Timms 2024-04-16 02:18:52 +10:00 committed by GitHub
parent eff77d6342
commit eb12064fab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 0 deletions

18
.pre-commit-hooks.yaml Normal file
View file

@ -0,0 +1,18 @@
- id: lychee
name: lychee
description: "Run 'lychee' for fast, async, stream-based link checking"
entry: lychee
language: system
args: ["--no-progress"]
types: [text]
pass_filenames: true
require_serial: true
- id: lychee-docker
name: lychee
description: "Run 'lychee' docker image for fast, async, stream-based link checking"
entry: lycheeverse/lychee:0.14
language: docker_image
args: ["--no-progress"]
types: [text]
pass_filenames: true
require_serial: true

View file

@ -25,6 +25,7 @@ Available as a command-line utility, a library and a [GitHub Action](https://git
- [Commandline usage](#commandline-usage)
- [Library usage](#library-usage)
- [GitHub Action Usage](#github-action-usage)
- [Pre-commit Usage](#pre-commit-usage)
- [Contributing to lychee](#contributing-to-lychee)
- [Debugging and improving async code](#debugging-and-improving-async-code)
- [Troubleshooting and Workarounds](#troubleshooting-and-workarounds)
@ -551,6 +552,27 @@ folder.
A GitHub Action that uses lychee is available as a separate repository: [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action)
which includes usage instructions.
## Pre-commit Usage
Lychee can also be used as a [pre-commit](https://pre-commit.com/) hook.
```yaml
# .pre-commit-config.yaml
repos:
- repo: https://github.com/lycheeverse/lychee.git
rev: 0.14.3
hooks:
- id: lychee
# Optionally include additional CLI arguments
args: ["--no-progress", "--exclude", "file://"]
```
Rather than running on staged-files only, Lychee can be run against an entire repository.
```yaml
- id: lychee
args: ["--no-progress", "."]
pass_filenames: false
```
## Contributing to lychee
We'd be thankful for any contribution. \