Skip to content

Commit d647e56

Browse files
committed
feat: add tsgo type checking to check runner (lint + format + typecheck)
1 parent 666aa90 commit d647e56

2 files changed

Lines changed: 35 additions & 15 deletions

File tree

.git-hooks/pre-push

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ while read local_ref local_sha remote_ref remote_sha; do
168168
ERRORS=$((ERRORS + 1))
169169
fi
170170

171-
# AWS keys.
172-
if echo "$file_text" | grep -iqE '(aws_access_key|aws_secret|AKIA[0-9A-Z]{16})'; then
171+
# AWS keys (word-boundary match to avoid false positives in base64 data).
172+
if echo "$file_text" | grep -iqE '(aws_access_key|aws_secret|\bAKIA[0-9A-Z]{16}\b)'; then
173173
printf "${RED}✗ BLOCKED: Potential AWS credentials found in: %s${NC}\n" "$file"
174-
echo "$file_text" | grep -niE '(aws_access_key|aws_secret|AKIA[0-9A-Z]{16})' | head -3
174+
echo "$file_text" | grep -niE '(aws_access_key|aws_secret|\bAKIA[0-9A-Z]{16}\b)' | head -3
175175
ERRORS=$((ERRORS + 1))
176176
fi
177177

scripts/check.mts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,34 @@ import {
1919
printHeader,
2020
} from '@socketsecurity/lib-stable/stdio/header'
2121

22-
import { runParallel } from './utils/run-command.mts'
22+
import { runCommandQuiet, runParallel } from './utils/run-command.mts'
2323

2424
const logger = getDefaultLogger()
2525

26+
async function runTypeCheck(quiet = false): Promise<number> {
27+
if (!quiet) {
28+
logger.progress('Checking TypeScript')
29+
}
30+
const result = await runCommandQuiet('tsgo', ['--noEmit'])
31+
if (result.exitCode !== 0) {
32+
if (!quiet) {
33+
logger.error('Type checks failed')
34+
}
35+
if (result.stdout) {
36+
console.log(result.stdout)
37+
}
38+
return result.exitCode
39+
}
40+
if (!quiet) {
41+
logger.clearLine().done('Type checks passed')
42+
}
43+
return 0
44+
}
45+
2646
async function main(): Promise<void> {
2747
try {
2848
const all = process.argv.includes('--all')
49+
const quiet = process.argv.includes('--quiet')
2950
const staged = process.argv.includes('--staged')
3051
const help = process.argv.includes('--help') || process.argv.includes('-h')
3152

@@ -66,15 +87,7 @@ async function main(): Promise<void> {
6687
},
6788
})
6889

69-
// TypeScript type checking always runs on whole project
7090
checks.push(
71-
{
72-
args: ['exec', 'tsgo', '--noEmit'],
73-
command: 'pnpm',
74-
options: {
75-
...(process.platform === 'win32' && { shell: true }),
76-
},
77-
},
7891
{
7992
args: ['scripts/validate/no-link-deps.mts'],
8093
command: 'node',
@@ -132,10 +145,17 @@ async function main(): Promise<void> {
132145
if (failed) {
133146
logger.error('Some checks failed')
134147
process.exitCode = 1
135-
} else {
136-
logger.success('All checks passed')
137-
printFooter()
148+
return
138149
}
150+
151+
const typeCheckExitCode = await runTypeCheck(quiet)
152+
if (typeCheckExitCode !== 0) {
153+
process.exitCode = typeCheckExitCode
154+
return
155+
}
156+
157+
logger.success('All checks passed')
158+
printFooter()
139159
} catch (error) {
140160
logger.error(`Check failed: ${error.message}`)
141161
process.exitCode = 1

0 commit comments

Comments
 (0)