Skip to content

Commit bcde330

Browse files
committed
chore(format): apply oxfmt to .mts hooks
1 parent 39966e7 commit bcde330

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

.git-hooks/pre-commit.mts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ const main = (): number => {
6565
// .env files (allowlist .env.example / .env.test).
6666
out('Checking for .env files...')
6767
const envFiles = stagedFiles.filter(
68-
f =>
69-
/^\.env(\.[^/]+)?$/.test(f) && !/^\.env\.(example|test)$/.test(f),
68+
f => /^\.env(\.[^/]+)?$/.test(f) && !/^\.env\.(example|test)$/.test(f),
7069
)
7170
if (envFiles.length > 0) {
7271
out(red('✗ ERROR: .env file detected!'))
@@ -90,9 +89,7 @@ const main = (): number => {
9089
const hits = scanPersonalPaths(text)
9190
if (hits.length > 0) {
9291
out(red(`✗ ERROR: Hardcoded personal path found in: ${file}`))
93-
hits
94-
.slice(0, 3)
95-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
92+
hits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
9693
out('Replace with relative paths or environment variables.')
9794
errors++
9895
}
@@ -111,9 +108,7 @@ const main = (): number => {
111108
const hits = scanSocketApiKeys(text)
112109
if (hits.length > 0) {
113110
out(yellow(`⚠ WARNING: Potential API key found in: ${file}`))
114-
hits
115-
.slice(0, 3)
116-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
111+
hits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
117112
out('If this is a real API key, DO NOT COMMIT IT.')
118113
}
119114
}
@@ -167,9 +162,7 @@ const main = (): number => {
167162
const hits = scanNpxDlx(text)
168163
if (hits.length > 0) {
169164
out(red(`✗ ERROR: npx/dlx usage found in: ${file}`))
170-
hits
171-
.slice(0, 3)
172-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
165+
hits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
173166
out("Use 'pnpm exec <package>' or 'pnpm run <script>' instead.")
174167
errors++
175168
}

.git-hooks/pre-push.mts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ const computeRange = (
102102
}
103103

104104
const defaultBranchOf = (remoteName: string): string => {
105-
const sym = git(
106-
'symbolic-ref',
107-
`refs/remotes/${remoteName}/HEAD`,
108-
).trim()
105+
const sym = git('symbolic-ref', `refs/remotes/${remoteName}/HEAD`).trim()
109106
if (sym) {
110107
return sym.replace(`refs/remotes/${remoteName}/`, '')
111108
}
@@ -172,9 +169,7 @@ const scanCommitMessages = (range: string): number => {
172169
}
173170
if (errors > 0) {
174171
out('')
175-
out(
176-
'These commits were likely created with --no-verify, bypassing the',
177-
)
172+
out('These commits were likely created with --no-verify, bypassing the')
178173
out('commit-msg hook that strips AI attribution.')
179174
out('')
180175
const rangeBase = range.split('..')[0]
@@ -246,36 +241,28 @@ const scanFilesInRange = (range: string): number => {
246241
const pathHits = scanPersonalPaths(text)
247242
if (pathHits.length > 0) {
248243
out(red(`✗ BLOCKED: Hardcoded personal path found in: ${file}`))
249-
pathHits
250-
.slice(0, 3)
251-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
244+
pathHits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
252245
errors++
253246
}
254247

255248
const apiHits = scanSocketApiKeys(text)
256249
if (apiHits.length > 0) {
257250
out(red(`✗ BLOCKED: Real API key detected in: ${file}`))
258-
apiHits
259-
.slice(0, 3)
260-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
251+
apiHits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
261252
errors++
262253
}
263254

264255
const awsHits = scanAwsKeys(text)
265256
if (awsHits.length > 0) {
266257
out(red(`✗ BLOCKED: Potential AWS credentials found in: ${file}`))
267-
awsHits
268-
.slice(0, 3)
269-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
258+
awsHits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
270259
errors++
271260
}
272261

273262
const ghHits = scanGitHubTokens(text)
274263
if (ghHits.length > 0) {
275264
out(red(`✗ BLOCKED: Potential GitHub token found in: ${file}`))
276-
ghHits
277-
.slice(0, 3)
278-
.forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
265+
ghHits.slice(0, 3).forEach(h => out(`${h.lineNumber}:${h.line.trim()}`))
279266
errors++
280267
}
281268

0 commit comments

Comments
 (0)