From 567672eca95106e728dea0c9e1238e08ad8076a0 Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Sat, 24 Aug 2024 17:48:44 +0200 Subject: [PATCH] feat: run-rust-backtick lint Use srgn[1] to find comments that contain empty backtick pairs which vscode is happy to add. [1]: https://github.com/alexpovel/srgn --- .pre-commit-hooks.yaml | 9 +++++++++ run-rust-backticks.sh | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 run-rust-backticks.sh diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index e31698c..7ecffe7 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -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" diff --git a/run-rust-backticks.sh b/run-rust-backticks.sh new file mode 100755 index 0000000..7407a8a --- /dev/null +++ b/run-rust-backticks.sh @@ -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}[^`]+'