Skip to content

Commit de8c12a

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 eslint directly - Adds --all and --staged flag support - Lint command is single source of truth for linting behavior
1 parent 38d4027 commit de8c12a

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

scripts/check.mjs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
/**
33
* @fileoverview Check script for the SDK.
44
* Runs all quality checks in parallel:
5+
* - Linting (via lint command)
56
* - TypeScript type checking
6-
* - ESLint
77
*
88
* Usage:
9-
* node scripts/check.mjs
9+
* node scripts/check.mjs [options]
10+
*
11+
* Options:
12+
* --all Run on all files (default behavior)
13+
* --staged Run on staged files only
1014
*/
1115

1216
import { getDefaultLogger } from '@socketsecurity/lib/logger'
@@ -21,22 +25,44 @@ const tsConfigPath = '.config/tsconfig.check.json'
2125

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

51+
// Delegate to lint command with appropriate flags
52+
const lintArgs = ['run', 'lint']
53+
if (all) {
54+
lintArgs.push('--all')
55+
} else if (staged) {
56+
lintArgs.push('--staged')
57+
}
58+
2659
const checks = [
2760
{
28-
args: ['exec', 'tsgo', '--noEmit', '-p', tsConfigPath],
61+
args: lintArgs,
2962
command: 'pnpm',
3063
},
3164
{
32-
args: [
33-
'exec',
34-
'eslint',
35-
'--config',
36-
'.config/eslint.config.mjs',
37-
'--report-unused-disable-directives',
38-
'.',
39-
],
65+
args: ['exec', 'tsgo', '--noEmit', '-p', tsConfigPath],
4066
command: 'pnpm',
4167
},
4268
{

0 commit comments

Comments
 (0)