Skip to content

Commit aceb886

Browse files
committed
chore(lint): oxfmt reformat check-primordials CLI + tests
Pure formatting from `pnpm run fix --all`. Single-line `logger.log` calls collapsed back from multi-line where they fit, multi-condition `if` collapsed where short, and the `(ternary) as RawConfig` rebuilt to a single line. No behavior change.
1 parent f913026 commit aceb886

2 files changed

Lines changed: 18 additions & 27 deletions

File tree

src/bin/check-primordials.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ function printHelp(): void {
7676
logger.log(' socket-lib check prim [opts] # short alias')
7777
logger.log('')
7878
logger.log('Options:')
79-
logger.log(
80-
` --config <path> Config file. Default: ${DEFAULT_CONFIG_PATH}`,
81-
)
79+
logger.log(` --config <path> Config file. Default: ${DEFAULT_CONFIG_PATH}`)
8280
logger.log(' --explain Print one detailed line per finding.')
8381
logger.log(' --json Machine-readable JSON output.')
8482
logger.log(' --quiet Silent on success.')
@@ -89,7 +87,9 @@ function printHelp(): void {
8987
logger.log(' "primordials": {')
9088
logger.log(' "aliasMap": { "Array": "ArrayCtor" },')
9189
logger.log(' "nodeInternalOnly": ["SafeMap", "SafeSet"],')
92-
logger.log(' "scanDirs": ["src", "additions/source-patched/lib"]')
90+
logger.log(
91+
' "scanDirs": ["src", "additions/source-patched/lib"]',
92+
)
9393
logger.log(' }')
9494
logger.log(' }')
9595
logger.log('')
@@ -118,18 +118,12 @@ function loadConfig(configPath: string): PrimordialsCheckConfig {
118118
// check (primordials, paths, public-surface, ...). When the file
119119
// has the section, use it; otherwise treat the whole file as the
120120
// primordials config (back-compat with single-check setups).
121-
if (
122-
typeof parsed !== 'object' ||
123-
parsed === null ||
124-
Array.isArray(parsed)
125-
) {
121+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
126122
throw new Error('config root must be an object')
127123
}
128124
const root = parsed as Record<string, unknown>
129125
const sectional = root[CONFIG_SECTION]
130-
const raw = (
131-
sectional !== undefined ? sectional : root
132-
) as RawConfig
126+
const raw = (sectional !== undefined ? sectional : root) as RawConfig
133127

134128
// Validate shape with concrete error messages — config files are
135129
// hand-edited and a misspelling here is the most common failure
@@ -152,7 +146,10 @@ function loadConfig(configPath: string): PrimordialsCheckConfig {
152146
) {
153147
throw new Error('config.aliasMap must be an object of source→target')
154148
}
155-
if (raw.nodeInternalOnly !== undefined && !Array.isArray(raw.nodeInternalOnly)) {
149+
if (
150+
raw.nodeInternalOnly !== undefined &&
151+
!Array.isArray(raw.nodeInternalOnly)
152+
) {
156153
throw new Error('config.nodeInternalOnly must be an array of strings')
157154
}
158155

@@ -204,10 +201,7 @@ function serialize(result: PrimordialsCheckResult): {
204201
}
205202
}
206203

207-
function renderHuman(
208-
result: PrimordialsCheckResult,
209-
args: ParsedArgs,
210-
): void {
204+
function renderHuman(result: PrimordialsCheckResult, args: ParsedArgs): void {
211205
if (result.findings.length === 0) {
212206
if (!args.silent) {
213207
logger.success(

test/unit/checks/primordials.test.mts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ describe('checks/primordials', () => {
123123
})
124124

125125
it('returns empty for files mentioning primordials only in comments', () => {
126-
expect(
127-
extractPrimordialsNames('// reads primordials elsewhere'),
128-
).toEqual([])
126+
expect(extractPrimordialsNames('// reads primordials elsewhere')).toEqual(
127+
[],
128+
)
129129
})
130130
})
131131

@@ -150,9 +150,9 @@ describe('checks/primordials', () => {
150150
})
151151

152152
it('captures `export declare function Foo` (.d.ts form)', () => {
153-
expect(
154-
extractTsExports('export declare function Foo(): void'),
155-
).toEqual(['Foo'])
153+
expect(extractTsExports('export declare function Foo(): void')).toEqual([
154+
'Foo',
155+
])
156156
})
157157

158158
it('mixes source and declaration forms', () => {
@@ -332,10 +332,7 @@ describe('checks/primordials', () => {
332332
})
333333

334334
it('walks scanDirs recursively', () => {
335-
writeFile(
336-
'src/deep/nested/path/file.js',
337-
'const { Foo } = primordials',
338-
)
335+
writeFile('src/deep/nested/path/file.js', 'const { Foo } = primordials')
339336
setupLib(['Foo'])
340337

341338
const result = checkPrimordials(makeConfig({}))

0 commit comments

Comments
 (0)