|
| 1 | +# ============================================================================= |
| 2 | +# 🛠️ PRE-COMMIT CONFIG - FAST-TIME-SERVER (Go project) |
| 3 | +# ============================================================================= |
| 4 | +# Install / run: |
| 5 | +# pip install --user pre-commit |
| 6 | +# pre-commit install |
| 7 | +# pre-commit run --all-files |
| 8 | +# |
| 9 | +# To skip checks: |
| 10 | +# git commit -m "msg" --no-verify |
| 11 | +# |
| 12 | +# To update: |
| 13 | +# pre-commit autoupdate # optional: bumps other hooks to latest pinned tags |
| 14 | +# pre-commit install # (re-installs the git hook if needed) |
| 15 | +# pre-commit run --all-files |
| 16 | +# ============================================================================= |
| 17 | + |
| 18 | +repos: |
| 19 | + # --------------------------------------------------------------------------- |
| 20 | + # 🔐 Security / secret detection |
| 21 | + # --------------------------------------------------------------------------- |
| 22 | + - repo: https://github.com/gitleaks/gitleaks |
| 23 | + rev: v8.27.2 |
| 24 | + hooks: |
| 25 | + - id: gitleaks |
| 26 | + name: 🔐 Gitleaks - Detect hard-coded secrets |
| 27 | + |
| 28 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 29 | + rev: v5.0.0 |
| 30 | + hooks: |
| 31 | + - id: detect-private-key |
| 32 | + name: 🔐 Detect Private Key |
| 33 | + types: [text] |
| 34 | + |
| 35 | + # --------------------------------------------------------------------------- |
| 36 | + # ❌ AI artefact & placeholder blockers |
| 37 | + # --------------------------------------------------------------------------- |
| 38 | + - repo: local |
| 39 | + hooks: |
| 40 | + - id: forbid-content-reference |
| 41 | + name: ❌ Forbid :contentReference |
| 42 | + entry: ":contentReference" |
| 43 | + language: pygrep |
| 44 | + types: [text] |
| 45 | + exclude: ^\.pre-commit-config\.yaml$ |
| 46 | + |
| 47 | + - id: forbid-oai-citations |
| 48 | + name: ❌ Forbid OpenAI Citations |
| 49 | + entry: '\[oaicite:\?\?\d+\]' |
| 50 | + language: pygrep |
| 51 | + types: [text] |
| 52 | + exclude: ^\.pre-commit-config\.yaml$ |
| 53 | + |
| 54 | + - id: forbid-ai-stock-phrases |
| 55 | + name: ❌ Forbid AI Stock Phrases |
| 56 | + entry: "(?i)(source=chatgpt.com|turn0search0|brevity| filecite|unchanged|as an ai language model|i am an ai developed by|this response was generated by|i don't have real-time information|i don't have access to real-time|i can't browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i'm not able to access|i don't have the ability to)" |
| 57 | + language: pygrep |
| 58 | + types: [text] |
| 59 | + exclude: ^\.pre-commit-config\.yaml$ |
| 60 | + |
| 61 | + - id: forbid-placeholder-citations |
| 62 | + name: ❌ Forbid Placeholder Citations |
| 63 | + entry: '\([A-Z][a-z]+,?\s+\d{4}\)' |
| 64 | + language: pygrep |
| 65 | + types: [text] |
| 66 | + exclude: ^\.pre-commit-config\.yaml$ |
| 67 | + |
| 68 | + - id: forbid-source-placeholders |
| 69 | + name: ❌ Forbid Source Placeholders |
| 70 | + entry: '(?i)\(source:' |
| 71 | + language: pygrep |
| 72 | + types: [text] |
| 73 | + exclude: ^\.pre-commit-config\.yaml$ |
| 74 | + |
| 75 | + - id: forbid-malformed-code-fences |
| 76 | + name: ❌ Forbid Malformed Code Fences |
| 77 | + entry: "````+" |
| 78 | + language: pygrep |
| 79 | + types: [text] |
| 80 | + exclude: ^\.pre-commit-config\.yaml$ |
| 81 | + |
| 82 | + - id: warn-ai-transitions |
| 83 | + name: ⚠️ Warn AI Transition Phrases |
| 84 | + entry: "(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it's worth noting that|please note that)" |
| 85 | + language: pygrep |
| 86 | + types: [text] |
| 87 | + verbose: true |
| 88 | + exclude: ^\.pre-commit-config\.yaml$ |
| 89 | + |
| 90 | + # --------------------------------------------------------------------------- |
| 91 | + # 🔤 Unicode text normalisation (smart-quotes, ligatures, exotic spaces) |
| 92 | + # --------------------------------------------------------------------------- |
| 93 | + - repo: https://github.com/sirosen/texthooks |
| 94 | + rev: 0.6.8 |
| 95 | + hooks: |
| 96 | + - id: fix-smartquotes |
| 97 | + name: 📝 Normalize Smart Quotes |
| 98 | + - id: fix-ligatures |
| 99 | + name: 🔡 Normalize Ligatures |
| 100 | + - id: fix-spaces |
| 101 | + name: ␣ Normalize Unicode Spaces |
| 102 | + - id: forbid-bidi-controls |
| 103 | + name: 🚫 Forbid BiDi Unicode Controls |
| 104 | + |
| 105 | + # --------------------------------------------------------------------------- |
| 106 | + # 🧹 Generic formatting & whitespace |
| 107 | + # --------------------------------------------------------------------------- |
| 108 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 109 | + rev: v5.0.0 |
| 110 | + hooks: |
| 111 | + - id: end-of-file-fixer |
| 112 | + name: 🧹 Fix End of Files |
| 113 | + stages: [pre-commit, pre-push, manual] |
| 114 | + |
| 115 | + - id: trailing-whitespace |
| 116 | + name: 🧹 Trim Trailing Whitespace |
| 117 | + stages: [pre-commit, pre-push, manual] |
| 118 | + |
| 119 | + - id: fix-byte-order-marker |
| 120 | + name: 🧹 Fix UTF-8 BOM |
| 121 | + |
| 122 | + - id: mixed-line-ending |
| 123 | + name: 🧹 Mixed Line Ending |
| 124 | + args: [--fix=lf] |
| 125 | + |
| 126 | + # size / merge / symlink checks |
| 127 | + - id: check-added-large-files |
| 128 | + - id: check-case-conflict |
| 129 | + - id: check-merge-conflict |
| 130 | + - id: check-symlinks |
| 131 | + - id: destroyed-symlinks |
| 132 | + - id: check-executables-have-shebangs |
| 133 | + - id: check-shebang-scripts-are-executable |
| 134 | + - id: forbid-new-submodules |
| 135 | + - id: check-json |
| 136 | + - id: check-yaml |
| 137 | + - id: check-toml |
| 138 | + - id: check-xml |
| 139 | + - id: check-byte-order-marker |
| 140 | + |
| 141 | + # YAML linter |
| 142 | + - repo: https://github.com/adrienverge/yamllint |
| 143 | + rev: v1.37.1 |
| 144 | + hooks: |
| 145 | + - id: yamllint |
| 146 | + name: ✅ yamllint |
| 147 | + args: [-c, .yamllint] |
| 148 | + files: ^.*\.(yml|yaml)$ |
| 149 | + exclude: ^charts/ |
| 150 | + |
| 151 | + # CRLF / tab remover |
| 152 | + - repo: https://github.com/Lucas-C/pre-commit-hooks |
| 153 | + rev: v1.5.5 |
| 154 | + hooks: |
| 155 | + - id: remove-crlf |
| 156 | + name: 🚀 Remove CRLF |
| 157 | + - id: remove-tabs |
| 158 | + name: 🚀 Remove Tabs |
| 159 | + exclude: '(^|/)Makefile$|\.mk$' |
| 160 | + |
| 161 | + # --------------------------------------------------------------------------- |
| 162 | + # 🐹 Go tool-chain (formatters + linters) |
| 163 | + # --------------------------------------------------------------------------- |
| 164 | + - repo: https://github.com/dnephin/pre-commit-golang |
| 165 | + rev: v0.5.1 |
| 166 | + hooks: |
| 167 | + # Formatters |
| 168 | + - id: go-fmt |
| 169 | + - id: go-imports |
| 170 | + # Vet / lints |
| 171 | + - id: go-vet |
| 172 | + - id: golangci-lint |
| 173 | + - id: go-lint # deprecated but kept here intentionally |
| 174 | + - id: go-critic |
| 175 | + # Complexity / metrics |
| 176 | + - id: go-cyclo |
| 177 | + args: ['-over=15'] |
| 178 | + # Build & test |
| 179 | + - id: go-build |
| 180 | + - id: go-unit-tests |
| 181 | + # Module hygiene |
| 182 | + - id: go-mod-tidy |
| 183 | + # Misc checks |
| 184 | + - id: validate-toml |
| 185 | + - id: no-go-testing |
| 186 | + |
| 187 | + - repo: https://github.com/segmentio/golines |
| 188 | + rev: v0.12.2 |
| 189 | + hooks: |
| 190 | + - id: golines |
| 191 | + name: 🧹 golines - wrap long lines |
| 192 | + args: ["--max-len=120", "--base-formatter=gofumpt"] |
| 193 | + |
| 194 | + # --------------------------------------------------------------------------- |
| 195 | + # 📝 OPTIONAL / web / extras (commented-out, keep for future) |
| 196 | + # --------------------------------------------------------------------------- |
| 197 | + # |
| 198 | + # - repo: https://github.com/pre-commit/mirrors-prettier |
| 199 | + # rev: v3.0.3 |
| 200 | + # hooks: |
| 201 | + # - id: prettier |
| 202 | + # |
| 203 | + # - repo: https://github.com/igorshubovych/markdownlint-cli |
| 204 | + # rev: v0.45.0 |
| 205 | + # hooks: |
| 206 | + # - id: markdownlint |
0 commit comments