Skip to content

Commit

Permalink
feat: run-rust-backtick lint
Browse files Browse the repository at this point in the history
Use srgn[1] to find comments that contain empty backtick pairs which
vscode is happy to add.

[1]: https://github.com/alexpovel/srgn
  • Loading branch information
domodwyer committed Aug 24, 2024
1 parent a475d30 commit 567672e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,12 @@
pass_filenames: false
minimum_pre_commit_version: 0.15.0
description: "Runs buf breaking at the repo root"

- id: rust-doc-backticks
name: "rustdoc backticks"
entry: run-rust-backticks.sh
language: "script"
files: \.rs$
pass_filenames: true
minimum_pre_commit_version: 0.15.0
description: "Check for empty backtick pairs"
12 changes: 12 additions & 0 deletions run-rust-backticks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Find comments with empty backtick pairs (`thing``).
#
# Expects filenames to validate as script arguments.

set -euo pipefail

srgn -j --fail-no-files -G "$@" \
--rust doc-comments \
--rust comments \
'[^`]`{2}[^`]+'

0 comments on commit 567672e

Please sign in to comment.