Skip to content

Commit 4c1fee5

Browse files
authored
chore: update eslint to v9, use new shared config (apify#568)
1 parent 237b749 commit 4c1fee5

25 files changed

+208
-164
lines changed

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/check.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
os: [ubuntu-latest] # add windows-latest later
18-
node-version: [14, 16]
17+
os: [ubuntu-22.04] # add windows-latest later
18+
node-version: [14, 16, 18]
1919

2020
steps:
2121
-
@@ -27,19 +27,19 @@ jobs:
2727
node-version: ${{ matrix.node-version }}
2828
-
2929
name: Cache Node Modules
30-
if: ${{ matrix.node-version == 16 }}
30+
if: ${{ matrix.node-version == 18 }}
3131
uses: actions/cache@v2
3232
with:
3333
path: |
3434
node_modules
3535
build
36-
key: cache-${{ github.run_id }}-v16
36+
key: cache-${{ github.run_id }}-v18
3737
-
3838
name: Install Dependencies
3939
run: npm install
4040
-
4141
name: Add localhost-test to Linux hosts file
42-
if: ${{ matrix.os == 'ubuntu-latest' }}
42+
if: ${{ matrix.os == 'ubuntu-22.04' }}
4343
run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts
4444
# -
4545
# name: Add localhost-test to Windows hosts file
@@ -52,23 +52,23 @@ jobs:
5252
lint:
5353
name: Lint
5454
needs: [build_and_test]
55-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-22.04
5656

5757
steps:
5858
-
5959
uses: actions/checkout@v2
6060
-
61-
name: Use Node.js 16
61+
name: Use Node.js 18
6262
uses: actions/setup-node@v1
6363
with:
64-
node-version: 16
64+
node-version: 18
6565
-
6666
name: Load Cache
6767
uses: actions/cache@v2
6868
with:
6969
path: |
7070
node_modules
7171
build
72-
key: cache-${{ github.run_id }}-v16
72+
key: cache-${{ github.run_id }}-v18
7373
-
7474
run: npm run lint

.github/workflows/release.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
os: [ubuntu-latest] # add windows-latest later
22-
node-version: [14, 16]
21+
os: [ubuntu-22.04] # add windows-latest later
22+
node-version: [14, 16, 18]
2323

2424
steps:
2525
-
@@ -31,18 +31,18 @@ jobs:
3131
node-version: ${{ matrix.node-version }}
3232
-
3333
name: Cache Node Modules
34-
if: ${{ matrix.node-version == 16 }}
34+
if: ${{ matrix.node-version == 18 }}
3535
uses: actions/cache@v2
3636
with:
3737
path: |
3838
node_modules
3939
build
40-
key: cache-${{ github.run_id }}-v16
40+
key: cache-${{ github.run_id }}-v18
4141
-
4242
name: Install Dependencies
4343
run: npm install
4444
- name: Add localhost-test to Linux hosts file
45-
if: ${{ matrix.os == 'ubuntu-latest' }}
45+
if: ${{ matrix.os == 'ubuntu-22.04' }}
4646
run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts
4747
# -
4848
# name: Add localhost-test to Windows hosts file
@@ -55,24 +55,24 @@ jobs:
5555
lint:
5656
name: Lint
5757
needs: [build_and_test]
58-
runs-on: ubuntu-latest
58+
runs-on: ubuntu-22.04
5959

6060
steps:
6161
-
6262
uses: actions/checkout@v2
6363
-
64-
name: Use Node.js 16
64+
name: Use Node.js 18
6565
uses: actions/setup-node@v1
6666
with:
67-
node-version: 16
67+
node-version: 18
6868
-
6969
name: Load Cache
7070
uses: actions/cache@v2
7171
with:
7272
path: |
7373
node_modules
7474
build
75-
key: cache-${{ github.run_id }}-v16
75+
key: cache-${{ github.run_id }}-v18
7676
-
7777
run: npm run lint
7878

@@ -82,14 +82,14 @@ jobs:
8282
deploy:
8383
name: Publish to NPM
8484
needs: [lint]
85-
runs-on: ubuntu-latest
85+
runs-on: ubuntu-22.04
8686
steps:
8787
-
8888
uses: actions/checkout@v2
8989
-
9090
uses: actions/setup-node@v1
9191
with:
92-
node-version: 16
92+
node-version: 18
9393
registry-url: https://registry.npmjs.org/
9494
-
9595
name: Load Cache
@@ -98,7 +98,7 @@ jobs:
9898
path: |
9999
node_modules
100100
build
101-
key: cache-${{ github.run_id }}-v16
101+
key: cache-${{ github.run_id }}-v18
102102
-
103103
# Determine if this is a beta or latest release
104104
name: Set Release Tag

eslint.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import apify from '@apify/eslint-config';
2+
3+
// eslint-disable-next-line import/no-default-export
4+
export default [
5+
{ ignores: ['**/dist'] }, // Ignores need to happen first
6+
...apify,
7+
{
8+
languageOptions: {
9+
sourceType: 'module',
10+
11+
parserOptions: {
12+
project: 'tsconfig.eslint.json',
13+
},
14+
},
15+
rules: {
16+
'no-param-reassign': 'off',
17+
'import/extensions': 'off',
18+
},
19+
},
20+
];

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "proxy-chain",
3-
"version": "2.5.6",
3+
"version": "2.5.7",
44
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",
55
"main": "dist/index.js",
66
"keywords": [
@@ -38,24 +38,22 @@
3838
"local-proxy": "node ./dist/run_locally.js",
3939
"test": "nyc cross-env NODE_OPTIONS=--insecure-http-parser mocha --bail",
4040
"lint": "eslint src",
41-
"lint-fix": "eslint src --fix"
41+
"lint:fix": "eslint src --fix"
4242
},
4343
"engines": {
4444
"node": ">=14"
4545
},
4646
"devDependencies": {
47-
"@apify/eslint-config-ts": "^0.2.3",
47+
"@apify/eslint-config": "^0.5.0-beta.2",
4848
"@apify/tsconfig": "^0.1.0",
4949
"@types/jest": "^28.1.2",
5050
"@types/node": "^18.8.3",
51-
"@typescript-eslint/eslint-plugin": "5.29.0",
52-
"@typescript-eslint/parser": "5.29.0",
5351
"basic-auth": "^2.0.1",
5452
"basic-auth-parser": "^0.0.2",
5553
"body-parser": "^1.19.0",
5654
"chai": "^4.3.4",
5755
"cross-env": "^7.0.3",
58-
"eslint": "^8.10.0",
56+
"eslint": "^9.18.0",
5957
"express": "^4.17.1",
6058
"faye-websocket": "^0.11.4",
6159
"got-scraping": "^3.2.4-beta.0",
@@ -73,6 +71,7 @@
7371
"through": "^2.3.8",
7472
"ts-node": "^10.2.1",
7573
"typescript": "^4.4.3",
74+
"typescript-eslint": "^8.20.0",
7675
"underscore": "^1.13.1",
7776
"ws": "^8.2.2"
7877
},

src/anonymize_proxy.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import net from 'net';
2-
import http from 'http';
3-
import { Buffer } from 'buffer';
1+
import type { Buffer } from 'buffer';
2+
import type http from 'http';
3+
import type net from 'net';
44
import { URL } from 'url';
5+
56
import { Server, SOCKS_PROTOCOLS } from './server';
67
import { nodeify } from './utils/nodeify';
78

@@ -17,7 +18,7 @@ export interface AnonymizeProxyOptions {
1718
* Parses and validates a HTTP proxy URL. If the proxy requires authentication, then the function
1819
* starts an open local proxy server that forwards to the upstream proxy.
1920
*/
20-
export const anonymizeProxy = (
21+
export const anonymizeProxy = async (
2122
options: string | AnonymizeProxyOptions,
2223
callback?: (error: Error | null) => void,
2324
): Promise<string> => {
@@ -39,7 +40,6 @@ export const anonymizeProxy = (
3940

4041
const parsedProxyUrl = new URL(proxyUrl);
4142
if (!['http:', ...SOCKS_PROTOCOLS].includes(parsedProxyUrl.protocol)) {
42-
// eslint-disable-next-line max-len
4343
throw new Error(`Invalid "proxyUrl" provided: URL must have one of the following protocols: "http", ${SOCKS_PROTOCOLS.map((p) => `"${p.replace(':', '')}"`).join(', ')} (was "${parsedProxyUrl}")`);
4444
}
4545

@@ -50,8 +50,8 @@ export const anonymizeProxy = (
5050

5151
let server: Server & { port: number };
5252

53-
const startServer = () => {
54-
return Promise.resolve().then(() => {
53+
const startServer = async () => {
54+
return Promise.resolve().then(async () => {
5555
server = new Server({
5656
// verbose: true,
5757
port,
@@ -83,7 +83,7 @@ export const anonymizeProxy = (
8383
* and its result if `false`. Otherwise the result is `true`.
8484
* @param closeConnections If true, pending proxy connections are forcibly closed.
8585
*/
86-
export const closeAnonymizedProxy = (
86+
export const closeAnonymizedProxy = async (
8787
anonymizedProxyUrl: string,
8888
closeConnections: boolean,
8989
callback?: (error: Error | null, result?: boolean) => void,

src/chain.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import type { Buffer } from 'buffer';
2+
import type dns from 'dns';
3+
import type { EventEmitter } from 'events';
14
import http from 'http';
25
import https from 'https';
3-
import dns from 'dns';
4-
import { URL } from 'url';
5-
import { EventEmitter } from 'events';
6-
import { Buffer } from 'buffer';
6+
import type { URL } from 'url';
7+
8+
import type { Socket } from './socket';
9+
import { badGatewayStatusCodes, createCustomStatusHttpResponse, errorCodeToStatusCode } from './statuses';
710
import { countTargetBytes } from './utils/count_target_bytes';
811
import { getBasicAuthorizationHeader } from './utils/get_basic';
9-
import { Socket } from './socket';
10-
import { badGatewayStatusCodes, createCustomStatusHttpResponse, errorCodeToStatusCode } from './statuses';
1112

1213
interface Options {
1314
method: string;

src/chain_socks.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import http from 'http';
2-
import net from 'net';
3-
import { Buffer } from 'buffer';
1+
import type { Buffer } from 'buffer';
2+
import type { EventEmitter } from 'events';
3+
import type http from 'http';
4+
import type net from 'net';
45
import { URL } from 'url';
5-
import { EventEmitter } from 'events';
6-
import { SocksClient, SocksClientError, type SocksProxy } from 'socks';
7-
import { countTargetBytes } from './utils/count_target_bytes';
8-
import { Socket } from './socket';
6+
7+
import { type SocksClientError, SocksClient, type SocksProxy } from 'socks';
8+
9+
import type { Socket } from './socket';
910
import { createCustomStatusHttpResponse, socksErrorMessageToStatusCode } from './statuses';
11+
import { countTargetBytes } from './utils/count_target_bytes';
1012

1113
export interface HandlerOpts {
1214
upstreamProxyUrlParsed: URL;

src/custom_connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import net from 'net';
21
import type http from 'http';
2+
import type net from 'net';
33
import { promisify } from 'util';
44

55
export const customConnect = async (socket: net.Socket, server: http.Server): Promise<void> => {

src/custom_response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type http from 'http';
21
import type { Buffer } from 'buffer';
2+
import type http from 'http';
33

44
export interface CustomResponse {
55
statusCode?: number;

0 commit comments

Comments
 (0)