Skip to content

Commit 23281d2

Browse files
committed
feat(check): delegate linting to lint command for consistency
Aligns check.mjs with standard pattern across socket-* repos: - check.mjs now delegates to `pnpm run lint` with appropriate flags - Removes running biome directly - Adds --all and --staged flag support - Lint command is single source of truth for linting behavior
1 parent 548fd10 commit 23281d2

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

scripts/check.mjs

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/**
22
* @fileoverview Check script for the lib.
33
* Runs all quality checks in parallel:
4-
* - Biome (linting)
4+
* - Linting (via lint command)
55
* - TypeScript type checking
66
*
77
* Usage:
8-
* node scripts/check.mjs
8+
* node scripts/check.mjs [options]
9+
*
10+
* Options:
11+
* --all Run on all files (default behavior)
12+
* --staged Run on staged files only
913
*/
1014

1115
import { getDefaultLogger } from '@socketsecurity/lib-stable/logger'
@@ -20,16 +24,49 @@ const logger = getDefaultLogger()
2024

2125
async function main() {
2226
try {
27+
const all = process.argv.includes('--all')
28+
const staged = process.argv.includes('--staged')
29+
const help = process.argv.includes('--help') || process.argv.includes('-h')
30+
31+
if (help) {
32+
logger.log('Check Runner')
33+
logger.log('\nUsage: node scripts/check.mjs [options]')
34+
logger.log('\nOptions:')
35+
logger.log(' --help, -h Show this help message')
36+
logger.log(' --all Run on all files (default behavior)')
37+
logger.log(' --staged Run on staged files only')
38+
logger.log('\nExamples:')
39+
logger.log(' node scripts/check.mjs # Run on all files')
40+
logger.log(
41+
' node scripts/check.mjs --all # Run on all files (explicit)',
42+
)
43+
logger.log(' node scripts/check.mjs --staged # Run on staged files')
44+
process.exitCode = 0
45+
return
46+
}
47+
2348
printHeader('Code Checks')
2449

25-
const checks = [
26-
{
27-
args: ['exec', 'biome', 'check', '.'],
28-
command: 'pnpm',
29-
options: {
30-
...(process.platform === 'win32' && { shell: true }),
31-
},
50+
const checks = []
51+
52+
// Delegate to lint command with appropriate flags
53+
const lintArgs = ['run', 'lint']
54+
if (all) {
55+
lintArgs.push('--all')
56+
} else if (staged) {
57+
lintArgs.push('--staged')
58+
}
59+
60+
checks.push({
61+
args: lintArgs,
62+
command: 'pnpm',
63+
options: {
64+
...(process.platform === 'win32' && { shell: true }),
3265
},
66+
})
67+
68+
// TypeScript type checking always runs on whole project
69+
checks.push(
3370
{
3471
args: ['exec', 'tsgo', '--noEmit'],
3572
command: 'pnpm',
@@ -86,7 +123,7 @@ async function main() {
86123
...(process.platform === 'win32' && { shell: true }),
87124
},
88125
},
89-
]
126+
)
90127

91128
const exitCodes = await runParallel(checks)
92129
const failed = exitCodes.some(code => code !== 0)

0 commit comments

Comments
 (0)