Skip to content

Commit 73d5f6b

Browse files
committed
Fix ESLint errors and apply Prettier formatting
- Disable no-unsafe-declaration-merging rule for EventEmitter pattern - Apply Prettier formatting to source files - All tests passing (65 passing, 10 pending) - Linter now passes without errors
1 parent 27ec9d6 commit 73d5f6b

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ module.exports = {
88
'eslint:recommended',
99
'plugin:@typescript-eslint/recommended',
1010
],
11+
rules: {
12+
// Allow declaration merging for EventEmitter pattern (interface + class)
13+
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
14+
},
1115
};

src/client/socksclient.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,7 @@ class SocksClient extends EventEmitter implements SocksClient {
695695

696696
if (responseCode !== Socks4Response.Granted) {
697697
this.closeSocket(
698-
`${ERRORS.Socks4ProxyRejectedConnection} - (${
699-
Socks4Response[responseCode]
700-
})`,
698+
`${ERRORS.Socks4ProxyRejectedConnection} - (${Socks4Response[responseCode]})`,
701699
);
702700
} else {
703701
// Bind response
@@ -740,9 +738,7 @@ class SocksClient extends EventEmitter implements SocksClient {
740738

741739
if (responseCode !== Socks4Response.Granted) {
742740
this.closeSocket(
743-
`${ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${
744-
Socks4Response[responseCode]
745-
})`,
741+
`${ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${Socks4Response[responseCode]})`,
746742
);
747743
} else {
748744
const remoteHost: SocksRemoteHost = {
@@ -812,7 +808,10 @@ class SocksClient extends EventEmitter implements SocksClient {
812808
this.socks5ChosenAuthType = Socks5Auth.UserPass;
813809
this.sendSocks5UserPassAuthentication();
814810
// If selected Socks v5 auth method is the custom_auth_method, send custom handshake.
815-
} else if (data[1] === this.options.proxy.custom_auth_method && this.options.proxy.custom_auth_method !== undefined) {
811+
} else if (
812+
data[1] === this.options.proxy.custom_auth_method &&
813+
this.options.proxy.custom_auth_method !== undefined
814+
) {
816815
this.socks5ChosenAuthType = this.options.proxy.custom_auth_method;
817816
this.sendSocks5CustomAuthentication();
818817
} else {
@@ -834,7 +833,9 @@ class SocksClient extends EventEmitter implements SocksClient {
834833
const passwordBuf = Buffer.from(password, 'utf8');
835834

836835
// Build packet: Version (1) + UserLen (1) + User (n) + PassLen (1) + Pass (n)
837-
const packet = Buffer.allocUnsafe(3 + userIdBuf.length + passwordBuf.length);
836+
const packet = Buffer.allocUnsafe(
837+
3 + userIdBuf.length + passwordBuf.length,
838+
);
838839
let offset = 0;
839840

840841
packet.writeUInt8(0x01, offset++);
@@ -976,9 +977,7 @@ class SocksClient extends EventEmitter implements SocksClient {
976977
if (header[0] !== 0x05 || header[1] !== Socks5Response.Granted) {
977978
const responseCode = header[1] ?? 0;
978979
this.closeSocket(
979-
`${ERRORS.InvalidSocks5FinalHandshakeRejected} - ${
980-
Socks5Response[responseCode]
981-
}`,
980+
`${ERRORS.InvalidSocks5FinalHandshakeRejected} - ${Socks5Response[responseCode]}`,
982981
);
983982
} else {
984983
// Read address type
@@ -1105,9 +1104,7 @@ class SocksClient extends EventEmitter implements SocksClient {
11051104
if (header[0] !== 0x05 || header[1] !== Socks5Response.Granted) {
11061105
const responseCode = header[1] ?? 0;
11071106
this.closeSocket(
1108-
`${ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${
1109-
Socks5Response[responseCode]
1110-
}`,
1107+
`${ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${Socks5Response[responseCode]}`,
11111108
);
11121109
} else {
11131110
// Read address type

src/common/helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ export function ipv4ToInt32(ip: string): number {
216216
const address = new Address4(ip);
217217
// Convert the IPv4 address parts to an integer
218218
return (
219-
address.toArray().reduce((acc: number, part: number) => (acc << 8) + part, 0) >>> 0
219+
address
220+
.toArray()
221+
.reduce((acc: number, part: number) => (acc << 8) + part, 0) >>> 0
220222
);
221223
}
222224

0 commit comments

Comments
 (0)