Skip to content

Commit 80ebc86

Browse files
authored
Merge pull request #33 from IBM/linting-cleanup
Linting cleanup
2 parents 12ac553 + 755a0db commit 80ebc86

File tree

4 files changed

+512
-74
lines changed

4 files changed

+512
-74
lines changed

.pre-commit-config.yaml

Lines changed: 75 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,41 +51,86 @@ repos:
5151
# -----------------------------------------------------------------------------
5252
# ❌ Forbid Specific AI / LLM Patterns
5353
# -----------------------------------------------------------------------------
54-
# This local hook checks for patterns that should not be committed.
55-
# It aims to detect and prevent the inclusion of AI-generated content by
56-
# identifying common artifacts associated with large language models (LLMs).
54+
# Local hooks that block the most common "AI artefacts" before they enter
55+
# the repository — including:
5756
#
58-
# Patterns checked include:
59-
# - `:contentReference`
60-
# - `[oaicite:??<digits>]` (e.g., `[oaicite:??12345]`)
61-
# - Common AI-generated phrases (e.g., "As an AI language model")
62-
# - Placeholder citations (e.g., "(Author, 2023)")
63-
# - Repetitive or generic phrases often produced by LLMs
57+
# • `:contentReference`
58+
# • `[oaicite:??<digits>]` (e.g. `[oaicite:??12345]`)
59+
# • Stock phrases such as
60+
# – "As an AI language model"
61+
# – "I am an AI developed by"
62+
# – "This response was generated by"
63+
# – "In conclusion," / "To summarize," / "It is important to note that"
64+
# – "Remember that" / "Keep in mind that"
65+
# • Placeholder citations like `(Author, 2023)` and `(Source: …)`
66+
# • Any code-fence of **four or more** consecutive back-ticks: ```` , ``````, …
6467
# -----------------------------------------------------------------------------
6568
- repo: local
6669
hooks:
67-
- id: forbid-specific-patterns
68-
name: ❌ Forbid Specific AI / LLM Patterns
69-
entry: >
70-
bash -c '
71-
# Succeed immediately if no files are passed
72-
[ "$#" -eq 0 ] && exit 0
73-
74-
# Invert grep exit-code:
75-
! grep -rnE "(:contentReference|\[oaicite:\?\?\d*\]|As an AI language model|I am an AI developed by|This response was generated by|\(Author, [0-9]{4}\)|\(Source: [^)]+\)|In conclusion,|To summarize,|It is important to note that|Remember that|Keep in mind that)" \
76-
--exclude-dir=.git \
77-
--exclude-dir=node_modules \
78-
--exclude-dir=.venv \
79-
--exclude-dir=dist \
80-
--exclude-dir=build \
81-
--exclude-dir=__pycache__ \
82-
--exclude=.pre-commit-config.yaml \
83-
"$@"
84-
'
85-
language: system
86-
pass_filenames: true
70+
- id: forbid-content-reference
71+
name: ❌ Forbid :contentReference
72+
description: Prevents :contentReference patterns from being committed.
73+
entry: ':contentReference'
74+
language: pygrep
8775
types: [text]
88-
description: Prevents committing LLM artefacts like :contentReference, [oaicite], and common AI-generated phrases.
76+
exclude: ^\.pre-commit-config\.yaml$
77+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
78+
79+
- id: forbid-oai-citations
80+
name: ❌ Forbid OpenAI Citations
81+
description: Prevents [oaicite:??digits] patterns from being committed.
82+
entry: '\[oaicite:\?\?\d+\]'
83+
language: pygrep
84+
types: [text]
85+
exclude: ^\.pre-commit-config\.yaml$
86+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
87+
88+
- id: forbid-ai-stock-phrases
89+
name: ❌ Forbid AI Stock Phrases
90+
description: Prevents common AI-generated phrases from being committed.
91+
entry: '(?i)(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)'
92+
language: pygrep
93+
types: [text]
94+
exclude: ^\.pre-commit-config\.yaml$
95+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
96+
97+
- id: forbid-placeholder-citations
98+
name: ❌ Forbid Placeholder Citations
99+
description: Prevents placeholder citations like (Author, 2023) from being committed.
100+
entry: '\([A-Z][a-z]+,?\s+\d{4}\)'
101+
language: pygrep
102+
types: [text]
103+
exclude: ^\.pre-commit-config\.yaml$
104+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
105+
106+
- id: forbid-source-placeholders
107+
name: ❌ Forbid Source Placeholders
108+
description: Prevents (Source:...) placeholders from being committed.
109+
entry: '(?i)\(source:'
110+
language: pygrep
111+
types: [text]
112+
exclude: ^\.pre-commit-config\.yaml$
113+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
114+
115+
- id: forbid-malformed-code-fences
116+
name: ❌ Forbid Malformed Code Fences
117+
description: Prevents code fences with 4+ backticks from being committed.
118+
entry: '````+'
119+
language: pygrep
120+
types: [text]
121+
exclude: ^\.pre-commit-config\.yaml$
122+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
123+
124+
- id: warn-ai-transitions
125+
name: ⚠️ Warn AI Transition Phrases
126+
description: Warns about common AI transition phrases (non-blocking).
127+
entry: '(?i)(in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it''s worth noting that|please note that)'
128+
language: pygrep
129+
types: [text]
130+
verbose: true
131+
exclude: ^\.pre-commit-config\.yaml$
132+
stages: [pre-commit, pre-merge-commit, prepare-commit-msg, commit-msg, post-checkout, post-commit, post-merge, pre-push, manual]
133+
89134

90135
# -----------------------------------------------------------------------------
91136
# 🔤 Unicode Text Normalization (via texthooks)

0 commit comments

Comments
 (0)