Skip to content

Commit 097241d

Browse files
committed
feat: add tsgo type checking to check runner (lint + format + typecheck)
1 parent d8bfcc5 commit 097241d

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

.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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { fileURLToPath } from 'node:url'
1919
import { getDefaultLogger } from '@socketsecurity/lib/logger'
2020
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
2121

22-
import { runCommand, runParallel } from './utils/run-command.mts'
22+
import { runCommand, runCommandQuiet, runParallel } from './utils/run-command.mts'
2323
import process from 'node:process'
2424

2525
const logger = getDefaultLogger()
@@ -28,9 +28,30 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
2828
const rootPath = path.resolve(__dirname, '..')
2929
const registryDistPath = path.join(rootPath, 'registry', 'dist', 'index.js')
3030

31+
async function runTypeCheck(quiet = false): Promise<number> {
32+
if (!quiet) {
33+
logger.progress('Checking TypeScript')
34+
}
35+
const result = await runCommandQuiet('tsgo', ['--noEmit'])
36+
if (result.exitCode !== 0) {
37+
if (!quiet) {
38+
logger.error('Type checks failed')
39+
}
40+
if (result.stdout) {
41+
console.log(result.stdout)
42+
}
43+
return result.exitCode
44+
}
45+
if (!quiet) {
46+
logger.clearLine().done('Type checks passed')
47+
}
48+
return 0
49+
}
50+
3151
async function main(): Promise<void> {
3252
try {
3353
const all = process.argv.includes('--all')
54+
const quiet = process.argv.includes('--quiet')
3455
const staged = process.argv.includes('--staged')
3556
const help = process.argv.includes('--help') || process.argv.includes('-h')
3657

@@ -80,13 +101,6 @@ async function main(): Promise<void> {
80101
...(process.platform === 'win32' && { shell: true }),
81102
},
82103
},
83-
{
84-
args: ['exec', 'tsgo', '--noEmit'],
85-
command: 'pnpm',
86-
options: {
87-
...(process.platform === 'win32' && { shell: true }),
88-
},
89-
},
90104
{
91105
args: ['scripts/validation/no-link-deps.mts'],
92106
command: 'node',
@@ -144,10 +158,17 @@ async function main(): Promise<void> {
144158
if (failed) {
145159
logger.error('Some checks failed')
146160
process.exitCode = 1
147-
} else {
148-
logger.success('All checks passed')
149-
printFooter()
161+
return
150162
}
163+
164+
const typeCheckExitCode = await runTypeCheck(quiet)
165+
if (typeCheckExitCode !== 0) {
166+
process.exitCode = typeCheckExitCode
167+
return
168+
}
169+
170+
logger.success('All checks passed')
171+
printFooter()
151172
} catch (error) {
152173
logger.error(`Check failed: ${error.message}`)
153174
process.exitCode = 1

0 commit comments

Comments
 (0)