File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,6 +198,34 @@ export const scanNpxDlx = (text: string): LineHit[] => {
198198 return hits
199199}
200200
201+ // ── Linear issue reference scanner ─────────────────────────────────
202+ // CLAUDE.md "ABSOLUTE RULES": NEVER reference Linear issues in commits.
203+ // Team keys enumerated from the Socket workspace. PATCH listed before
204+ // PAT so the alternation matches the longer prefix first.
205+
206+ const LINEAR_TEAM_KEYS =
207+ 'ASK|AUTO|BOT|CE|CORE|DAT|DES|DEV|ENG|INFRA|LAB|MAR|MET|OPS|PAR|PATCH|PAT|PLAT|REA|SALES|SBOM|SEC|SMO|SUP|TES|TI|WEB'
208+
209+ const LINEAR_ISSUE_RE = new RegExp (
210+ `(?:^|[^A-Za-z0-9_])((?:${ LINEAR_TEAM_KEYS } )-[0-9]+)(?:$|[^A-Za-z0-9_])` ,
211+ 'gm' ,
212+ )
213+
214+ const LINEAR_URL_RE = / l i n e a r \. a p p \/ [ A - Z a - z 0 - 9 / _ - ] + / g
215+
216+ export const scanLinearReferences = ( commitMsg : string ) : string [ ] => {
217+ const hits : string [ ] = [ ]
218+ const lines = commitMsg . split ( '\n' ) . filter ( l => ! l . startsWith ( '#' ) )
219+ const body = lines . join ( '\n' )
220+ for ( const m of body . matchAll ( LINEAR_ISSUE_RE ) ) {
221+ hits . push ( m [ 1 ] ! )
222+ }
223+ for ( const m of body . matchAll ( LINEAR_URL_RE ) ) {
224+ hits . push ( m [ 0 ] ! )
225+ }
226+ return hits . slice ( 0 , 5 )
227+ }
228+
201229// ── AI attribution scanner ─────────────────────────────────────────
202230
203231const AI_ATTRIBUTION_RE =
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
2323 out ,
2424 red ,
2525 readFileForScan ,
26+ scanLinearReferences ,
2627 scanSocketApiKeys ,
2728 shouldSkipFile ,
2829 stripAiAttribution ,
@@ -67,10 +68,26 @@ const main = (): number => {
6768 }
6869 }
6970
70- // Auto-strip AI attribution lines from the commit message.
7171 const commitMsgFile = process . argv [ 2 ]
7272 if ( commitMsgFile && existsSync ( commitMsgFile ) ) {
7373 const original = readFileSync ( commitMsgFile , 'utf8' )
74+
75+ // Block Linear issue references in the commit message.
76+ const linearHits = scanLinearReferences ( original )
77+ if ( linearHits . length ) {
78+ out ( red ( '✗ Commit message references Linear issue(s):' ) )
79+ for ( const hit of linearHits ) {
80+ out ( ` ${ hit } ` )
81+ }
82+ out (
83+ red (
84+ 'Linear tracking lives in Linear. Remove the reference from the commit message.' ,
85+ ) ,
86+ )
87+ errors ++
88+ }
89+
90+ // Auto-strip AI attribution lines from the commit message.
7491 const { cleaned, removed } = stripAiAttribution ( original )
7592 if ( removed > 0 ) {
7693 writeFileSync ( commitMsgFile , cleaned )
You can’t perform that action at this time.
0 commit comments