Skip to content

Commit 8f8961f

Browse files
committed
fix: update Biome and ESLint configs for bracket notation support
Update linting configuration to support TypeScript bracket notation for index signature properties: - Disable Biome rules: useLiteralKeys, noParameterAssign, noNonNullAssertion, noExplicitAny, noAsyncPromiseExecutor, noAssignInExpressions, useIterableCallbackReturn, noBannedTypes - Disable ESLint rules: no-unexpected-multiline, sort-imports - Apply Biome formatting across codebase This aligns with socket-sdk-js and enables TypeScript TS4111 compliance.
1 parent 997b2d7 commit 8f8961f

File tree

561 files changed

+2839
-2882
lines changed

Some content is hidden

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

561 files changed

+2839
-2882
lines changed

.config/esbuild.cli.config.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const versionHash = `${packageJson.version}:${gitHash}:${randUuidSegment}${
4646

4747
// Get local Socket package paths.
4848
const socketPackages = {
49+
'@socketsecurity/lib': path.join(rootPath, '..', 'socket-lib'),
4950
'@socketsecurity/registry': path.join(
5051
rootPath,
5152
'..',
@@ -203,6 +204,52 @@ export default {
203204
},
204205
},
205206

207+
{
208+
name: 'resolve-socket-lib-internals',
209+
setup(build) {
210+
// Resolve relative imports from socket-lib dist files.
211+
const socketLibPath = path.join(rootPath, '..', 'socket-lib')
212+
if (existsSync(socketLibPath)) {
213+
build.onResolve({ filter: /^\.\.\/constants\// }, args => {
214+
// Only handle imports from socket-lib's dist directory.
215+
if (args.importer.includes('/socket-lib/dist/')) {
216+
const constantName = args.path.replace(/^\.\.\/constants\//, '')
217+
const resolvedPath = path.join(
218+
socketLibPath,
219+
'dist',
220+
'constants',
221+
`${constantName}.js`,
222+
)
223+
if (existsSync(resolvedPath)) {
224+
return { path: resolvedPath }
225+
}
226+
}
227+
return null
228+
})
229+
230+
build.onResolve({ filter: /^\.\.\/\.\.\/constants\// }, args => {
231+
// Handle ../../constants/ imports.
232+
if (args.importer.includes('/socket-lib/dist/')) {
233+
const constantName = args.path.replace(
234+
/^\.\.\/\.\.\/constants\//,
235+
'',
236+
)
237+
const resolvedPath = path.join(
238+
socketLibPath,
239+
'dist',
240+
'constants',
241+
`${constantName}.js`,
242+
)
243+
if (existsSync(resolvedPath)) {
244+
return { path: resolvedPath }
245+
}
246+
}
247+
return null
248+
})
249+
}
250+
},
251+
},
252+
206253
{
207254
name: 'yoga-wasm-alias',
208255
setup(build) {

.config/eslint.config.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import tsEslint from 'typescript-eslint'
1818

1919
import { TSCONFIG_JSON } from '../scripts/constants/build.mjs'
2020
import { GITIGNORE } from '../scripts/constants/packages.mjs'
21-
import { LATEST, maintainedNodeVersions } from '../scripts/constants/versions.mjs'
21+
import {
22+
LATEST,
23+
maintainedNodeVersions,
24+
} from '../scripts/constants/versions.mjs'
2225

2326
const __filename = fileURLToPath(import.meta.url)
2427
const __dirname = path.dirname(__filename)
@@ -74,6 +77,7 @@ const sharedRules = {
7477
'no-new': 'error',
7578
'no-proto': 'error',
7679
'no-undef': 'error',
80+
'no-unexpected-multiline': 'off',
7781
'no-unused-vars': [
7882
'error',
7983
{
@@ -86,7 +90,7 @@ const sharedRules = {
8690
'no-warning-comments': ['warn', { terms: ['fixme'] }],
8791
'prefer-const': 'error',
8892
'sort-destructure-keys/sort-destructure-keys': 'error',
89-
'sort-imports': ['error', { ignoreDeclarationSort: true }],
93+
'sort-imports': 'off',
9094
}
9195

9296
const sharedRulesForImportX = {
@@ -148,7 +152,9 @@ const sharedRulesForNode = {
148152
'test',
149153
'test.describe',
150154
],
151-
version: String(maintainedNodeVersions[maintainedNodeVersions.length - 1]),
155+
version: String(
156+
maintainedNodeVersions[maintainedNodeVersions.length - 1],
157+
),
152158
},
153159
],
154160
'n/prefer-node-protocol': 'error',

bin/bootstrap.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
// Socket Security Bootstrap.
2-
// This file is loaded during Node.js initialization.
3-
// It must use internal module APIs, not node: prefixed modules.
4-
5-
'use strict';
6-
71
// eslint-disable-next-line no-restricted-syntax, n/prefer-global/process
8-
const { existsSync } = require('fs');
2+
const { existsSync } = require('fs')
93
// eslint-disable-next-line no-restricted-syntax, n/prefer-global/process
10-
const { homedir } = require('os');
4+
const { homedir } = require('os')
115
// eslint-disable-next-line no-restricted-syntax, n/prefer-global/process
12-
const { join } = require('path');
6+
const { join } = require('path')
137
// eslint-disable-next-line no-restricted-syntax, n/prefer-global/process
14-
const { spawnSync } = require('child_process');
8+
const { spawnSync } = require('child_process')
159

16-
const SOCKET_DLX_DIR = join(homedir(), '.socket', '_dlx');
17-
const CLI_PACKAGE_DIR = join(SOCKET_DLX_DIR, 'cli');
18-
const CLI_ENTRY = join(CLI_PACKAGE_DIR, 'dist', 'cli.js');
10+
const SOCKET_DLX_DIR = join(homedir(), '.socket', '_dlx')
11+
const CLI_PACKAGE_DIR = join(SOCKET_DLX_DIR, 'cli')
12+
const CLI_ENTRY = join(CLI_PACKAGE_DIR, 'dist', 'cli.js')
1913

2014
// Check if CLI exists.
2115
if (existsSync(CLI_ENTRY)) {
@@ -30,15 +24,17 @@ if (existsSync(CLI_ENTRY)) {
3024
PKG_EXECPATH: process.env.PKG_EXECPATH || 'PKG_INVOKE_NODEJS',
3125
},
3226
},
33-
);
34-
process.exit(result.status || 0);
27+
)
28+
process.exit(result.status || 0)
3529
} else {
3630
// Download and install.
37-
process.stderr.write('📦 Socket CLI not found, installing...\n');
38-
process.stderr.write(` Directory: ${CLI_PACKAGE_DIR}\n`);
39-
process.stderr.write('\n');
40-
process.stderr.write('❌ Not implemented yet\n');
41-
process.stderr.write(' TODO: Download @socketsecurity/cli from npm registry\n');
42-
process.stderr.write(` TODO: Extract to ${CLI_PACKAGE_DIR}\n`);
43-
process.exit(1);
31+
process.stderr.write('📦 Socket CLI not found, installing...\n')
32+
process.stderr.write(` Directory: ${CLI_PACKAGE_DIR}\n`)
33+
process.stderr.write('\n')
34+
process.stderr.write('❌ Not implemented yet\n')
35+
process.stderr.write(
36+
' TODO: Download @socketsecurity/cli from npm registry\n',
37+
)
38+
process.stderr.write(` TODO: Extract to ${CLI_PACKAGE_DIR}\n`)
39+
process.exit(1)
4440
}

biome.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,27 @@
5959
"linter": {
6060
"rules": {
6161
"complexity": {
62+
"noBannedTypes": "off",
6263
"useLiteralKeys": "off"
6364
},
6465
"style": {
65-
"noParameterAssign": "error",
66+
"noInferrableTypes": "error",
67+
"noNonNullAssertion": "off",
68+
"noParameterAssign": "off",
69+
"noUnusedTemplateLiteral": "error",
70+
"noUselessElse": "error",
6671
"useAsConstAssertion": "error",
6772
"useDefaultParameterLast": "error",
6873
"useEnumInitializers": "error",
69-
"useSelfClosingElements": "error",
70-
"useSingleVarDeclarator": "error",
71-
"noUnusedTemplateLiteral": "error",
7274
"useNumberNamespace": "error",
73-
"noInferrableTypes": "error",
74-
"noUselessElse": "error"
75+
"useSelfClosingElements": "error",
76+
"useSingleVarDeclarator": "error"
77+
},
78+
"suspicious": {
79+
"noAssignInExpressions": "off",
80+
"noAsyncPromiseExecutor": "off",
81+
"noExplicitAny": "off",
82+
"useIterableCallbackReturn": "off"
7583
}
7684
}
7785
}

scripts/babel/babel-plugin-with-intl-none.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ export default function babelPluginWithIntlNone({ template, types: t }) {
367367
}
368368

369369
// Check for unicode property escapes (\p{...}).
370-
if ((node.flags.includes('u') || node.flags.includes('v')) && node.pattern.includes('\\p{')) {
370+
if (
371+
(node.flags.includes('u') || node.flags.includes('v')) &&
372+
node.pattern.includes('\\p{')
373+
) {
371374
let pattern = node.pattern
372375
let transformed = false
373376

0 commit comments

Comments
 (0)