Skip to content

Commit e8457be

Browse files
committed
Apply Biome auto-fixes across codebase
- Use template literals instead of string concatenation - Replace bracket notation with dot notation for literal keys - Use Number namespace for parseFloat - Fix import ordering and formatting - Update test type annotations - Fix TypeScript strict type issues
1 parent e444e4a commit e8457be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+713
-527
lines changed

.config/esbuild.config.mjs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,23 @@ export const buildConfig = {
3939
external: [
4040
// Node.js built-ins
4141
...builtinModules,
42-
...builtinModules.map(m => `node:${m}`)
42+
...builtinModules.map(m => `node:${m}`),
4343
],
4444

4545
// Banner for generated code
4646
banner: {
47-
js: '/* Socket PackageURL - Built with esbuild */'
47+
js: '/* Socket PackageURL - Built with esbuild */',
4848
},
4949

5050
// TypeScript configuration
5151
tsconfig: path.join(rootPath, 'tsconfig.json'),
5252

5353
// Define constants for optimization
5454
define: {
55-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
56-
}
55+
'process.env.NODE_ENV': JSON.stringify(
56+
process.env.NODE_ENV || 'production',
57+
),
58+
},
5759
}
5860

5961
// Watch configuration for development with incremental builds
@@ -66,7 +68,7 @@ export const watchConfig = {
6668
watch: {
6769
// This will be extracted and not passed to context()
6870
// Rebuild logging is handled via plugin in build script
69-
}
71+
},
7072
}
7173

7274
/**
@@ -81,14 +83,14 @@ function analyzeMetafile(metafile) {
8183
totalSize += output.bytes
8284
return {
8385
name: path.relative(rootPath, file),
84-
size: (output.bytes / 1024).toFixed(2) + ' KB'
86+
size: `${(output.bytes / 1024).toFixed(2)} KB`,
8587
}
8688
})
8789

8890
return {
8991
files,
90-
totalSize: (totalSize / 1024).toFixed(2) + ' KB'
92+
totalSize: `${(totalSize / 1024).toFixed(2)} KB`,
9193
}
9294
}
9395

94-
export { analyzeMetafile }
96+
export { analyzeMetafile }

.config/eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const nodeGlobalsConfig = Object.fromEntries(
3030
const biomeConfigPath = path.join(rootPath, 'biome.json')
3131
const biomeConfig = require(biomeConfigPath)
3232
const biomeIgnores = {
33-
name: `Imported biome.json ignore patterns`,
33+
name: 'Imported biome.json ignore patterns',
3434
ignores: biomeConfig.files.includes
3535
.filter(p => p.startsWith('!'))
3636
.map(p => convertIgnorePatternToMinimatch(p.slice(1))),
@@ -39,7 +39,7 @@ const biomeIgnores = {
3939
const gitignorePath = path.join(rootPath, '.gitignore')
4040
const gitIgnores = {
4141
...includeIgnoreFile(gitignorePath),
42-
name: `Imported .gitignore ignore patterns`,
42+
name: 'Imported .gitignore ignore patterns',
4343
}
4444

4545
export default [

.config/tsconfig.check.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"paths": {
1010
"@socketsecurity/lib": ["../../socket-lib/dist/index.d.ts"],
1111
"@socketsecurity/lib/*": ["../../socket-lib/dist/*"],
12-
"@socketsecurity/registry": ["../../socket-registry/registry/dist/index.d.ts"],
12+
"@socketsecurity/registry": [
13+
"../../socket-registry/registry/dist/index.d.ts"
14+
],
1315
"@socketsecurity/registry/*": ["../../socket-registry/registry/dist/*"]
1416
},
1517
"skipLibCheck": true,

.config/vitest.config.isolated.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { defineConfig } from 'vitest/config'
66

77
// Check if coverage is enabled via CLI flags or environment.
88
const isCoverageEnabled =
9-
process.env['COVERAGE'] === 'true' ||
10-
process.env['npm_lifecycle_event']?.includes('coverage') ||
9+
process.env.COVERAGE === 'true' ||
10+
process.env.npm_lifecycle_event?.includes('coverage') ||
1111
process.argv.some(arg => arg.includes('coverage'))
1212

1313
export default defineConfig({

.config/vitest.config.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
99

1010
// Check if coverage is enabled via CLI flags or environment.
1111
const isCoverageEnabled =
12-
process.env['COVERAGE'] === 'true' ||
13-
process.env['npm_lifecycle_event']?.includes('coverage') ||
12+
process.env.COVERAGE === 'true' ||
13+
process.env.npm_lifecycle_event?.includes('coverage') ||
1414
process.argv.some(arg => arg.includes('coverage'))
1515

1616
export default defineConfig({

scripts/build.mjs

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ import { parseArgs } from '@socketsecurity/lib/argv/parse'
1414
import { logger } from '@socketsecurity/lib/logger'
1515
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
1616

17+
import {
18+
analyzeMetafile,
19+
buildConfig,
20+
watchConfig,
21+
} from '../.config/esbuild.config.mjs'
1722
import { runSequence } from './utils/run-command.mjs'
18-
import { analyzeMetafile, buildConfig, watchConfig } from '../.config/esbuild.config.mjs'
1923

20-
const rootPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
24+
const rootPath = path.resolve(
25+
path.dirname(fileURLToPath(import.meta.url)),
26+
'..',
27+
)
2128

2229
/**
2330
* Build source code with esbuild.
@@ -33,7 +40,10 @@ async function buildSource(options = {}) {
3340
// Clean dist directory if needed
3441
if (!skipClean) {
3542
const exitCode = await runSequence([
36-
{ args: ['scripts/load.cjs', 'clean', '--dist', '--quiet'], command: 'node' }
43+
{
44+
args: ['scripts/load.cjs', 'clean', '--dist', '--quiet'],
45+
command: 'node',
46+
},
3747
])
3848
if (exitCode !== 0) {
3949
if (!quiet) {
@@ -49,7 +59,7 @@ async function buildSource(options = {}) {
4959
const logLevel = quiet ? 'silent' : verbose ? 'info' : 'warning'
5060
const result = await build({
5161
...buildConfig,
52-
logLevel
62+
logLevel,
5363
})
5464
const buildTime = Date.now() - startTime
5565

@@ -68,7 +78,11 @@ async function buildSource(options = {}) {
6878
* Returns exitCode for external logging.
6979
*/
7080
async function buildTypes(options = {}) {
71-
const { quiet = false, skipClean = false, verbose: _verbose = false } = options
81+
const {
82+
quiet = false,
83+
skipClean = false,
84+
verbose: _verbose = false,
85+
} = options
7286

7387
if (!quiet) {
7488
logger.substep('Building TypeScript declarations')
@@ -77,7 +91,10 @@ async function buildTypes(options = {}) {
7791
const commands = []
7892

7993
if (!skipClean) {
80-
commands.push({ args: ['scripts/load.cjs', 'clean', '--types', '--quiet'], command: 'node' })
94+
commands.push({
95+
args: ['scripts/load.cjs', 'clean', '--types', '--quiet'],
96+
command: 'node',
97+
})
8198
}
8299

83100
commands.push({
@@ -122,7 +139,7 @@ async function watchBuild(options = {}) {
122139
{
123140
name: 'rebuild-logger',
124141
setup(build) {
125-
build.onEnd((result) => {
142+
build.onEnd(result => {
126143
if (result.errors.length > 0) {
127144
if (!quiet) {
128145
logger.error('Rebuild failed')
@@ -137,9 +154,9 @@ async function watchBuild(options = {}) {
137154
}
138155
}
139156
})
140-
}
141-
}
142-
]
157+
},
158+
},
159+
],
143160
})
144161

145162
// Enable watch mode
@@ -226,7 +243,9 @@ async function main() {
226243
console.log(' --help Show this help message')
227244
console.log(' --src Build source code only')
228245
console.log(' --types Build TypeScript declarations only')
229-
console.log(' --watch Watch mode with incremental builds (68% faster rebuilds)')
246+
console.log(
247+
' --watch Watch mode with incremental builds (68% faster rebuilds)',
248+
)
230249
console.log(' --needed Only build if dist files are missing')
231250
console.log(' --analyze Show bundle size analysis')
232251
console.log(' --quiet, --silent Suppress progress messages')
@@ -235,9 +254,13 @@ async function main() {
235254
console.log(' pnpm build # Full build (source + types)')
236255
console.log(' pnpm build --src # Build source only')
237256
console.log(' pnpm build --types # Build types only')
238-
console.log(' pnpm build --watch # Watch mode with incremental builds')
257+
console.log(
258+
' pnpm build --watch # Watch mode with incremental builds',
259+
)
239260
console.log(' pnpm build --analyze # Build with size analysis')
240-
console.log('\nNote: Watch mode uses esbuild context API for 68% faster rebuilds')
261+
console.log(
262+
'\nNote: Watch mode uses esbuild context API for 68% faster rebuilds',
263+
)
241264
process.exitCode = 0
242265
return
243266
}
@@ -279,18 +302,22 @@ async function main() {
279302
if (!quiet) {
280303
logger.step('Building source only')
281304
}
282-
const { buildTime, exitCode: srcExitCode, result } = await buildSource({ quiet, verbose, analyze: values.analyze })
305+
const {
306+
buildTime,
307+
exitCode: srcExitCode,
308+
result,
309+
} = await buildSource({ quiet, verbose, analyze: values.analyze })
283310
exitCode = srcExitCode
284311
if (exitCode === 0 && !quiet) {
285312
logger.substep(`Source build complete in ${buildTime}ms`)
286313

287-
if (values.analyze && result?.['metafile']) {
288-
const analysis = analyzeMetafile(result['metafile'])
314+
if (values.analyze && result?.metafile) {
315+
const analysis = analyzeMetafile(result.metafile)
289316
logger.info('Build output:')
290-
for (const file of analysis['files']) {
291-
logger.substep(`${file['name']}: ${file['size']}`)
317+
for (const file of analysis.files) {
318+
logger.substep(`${file.name}: ${file.size}`)
292319
}
293-
logger.step(`Total bundle size: ${analysis['totalSize']}`)
320+
logger.step(`Total bundle size: ${analysis.totalSize}`)
294321
}
295322
}
296323
}
@@ -305,7 +332,10 @@ async function main() {
305332
logger.substep('Cleaning build directories')
306333
}
307334
exitCode = await runSequence([
308-
{ args: ['scripts/load.cjs', 'clean', '--dist', '--types', '--quiet'], command: 'node' }
335+
{
336+
args: ['scripts/load.cjs', 'clean', '--dist', '--types', '--quiet'],
337+
command: 'node',
338+
},
309339
])
310340
if (exitCode !== 0) {
311341
if (!quiet) {
@@ -317,22 +347,27 @@ async function main() {
317347

318348
// Run source and types builds in parallel
319349
const [srcResult, typesExitCode] = await Promise.all([
320-
buildSource({ quiet, verbose, skipClean: true, analyze: values.analyze }),
321-
buildTypes({ quiet, verbose, skipClean: true })
350+
buildSource({
351+
quiet,
352+
verbose,
353+
skipClean: true,
354+
analyze: values.analyze,
355+
}),
356+
buildTypes({ quiet, verbose, skipClean: true }),
322357
])
323358

324359
// Log completion messages in order
325360
if (!quiet) {
326-
if (srcResult['exitCode'] === 0) {
327-
logger.substep(`Source build complete in ${srcResult['buildTime']}ms`)
361+
if (srcResult.exitCode === 0) {
362+
logger.substep(`Source build complete in ${srcResult.buildTime}ms`)
328363

329-
if (values.analyze && srcResult['result']?.['metafile']) {
330-
const analysis = analyzeMetafile(srcResult['result']['metafile'])
364+
if (values.analyze && srcResult.result?.metafile) {
365+
const analysis = analyzeMetafile(srcResult.result.metafile)
331366
logger.info('Build output:')
332-
for (const file of analysis['files']) {
333-
logger.substep(`${file['name']}: ${file['size']}`)
367+
for (const file of analysis.files) {
368+
logger.substep(`${file.name}: ${file.size}`)
334369
}
335-
logger.step(`Total bundle size: ${analysis['totalSize']}`)
370+
logger.step(`Total bundle size: ${analysis.totalSize}`)
336371
}
337372
}
338373

@@ -341,7 +376,7 @@ async function main() {
341376
}
342377
}
343378

344-
exitCode = srcResult['exitCode'] !== 0 ? srcResult['exitCode'] : typesExitCode
379+
exitCode = srcResult.exitCode !== 0 ? srcResult.exitCode : typesExitCode
345380
}
346381

347382
// Print final status and footer
@@ -363,4 +398,4 @@ async function main() {
363398
}
364399
}
365400

366-
main().catch(console.error)
401+
main().catch(console.error)

0 commit comments

Comments
 (0)