Skip to content

Commit

Permalink
chore: update eslint to v9, use new shared config (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik authored Jan 15, 2025
1 parent 237b749 commit 4c1fee5
Show file tree
Hide file tree
Showing 25 changed files with 208 additions and 164 deletions.
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

18 changes: 9 additions & 9 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:

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

steps:
-
Expand All @@ -27,19 +27,19 @@ jobs:
node-version: ${{ matrix.node-version }}
-
name: Cache Node Modules
if: ${{ matrix.node-version == 16 }}
if: ${{ matrix.node-version == 18 }}
uses: actions/cache@v2
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v16
key: cache-${{ github.run_id }}-v18
-
name: Install Dependencies
run: npm install
-
name: Add localhost-test to Linux hosts file
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts
# -
# name: Add localhost-test to Windows hosts file
Expand All @@ -52,23 +52,23 @@ jobs:
lint:
name: Lint
needs: [build_and_test]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
-
uses: actions/checkout@v2
-
name: Use Node.js 16
name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
-
name: Load Cache
uses: actions/cache@v2
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v16
key: cache-${{ github.run_id }}-v18
-
run: npm run lint
24 changes: 12 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

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

steps:
-
Expand All @@ -31,18 +31,18 @@ jobs:
node-version: ${{ matrix.node-version }}
-
name: Cache Node Modules
if: ${{ matrix.node-version == 16 }}
if: ${{ matrix.node-version == 18 }}
uses: actions/cache@v2
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v16
key: cache-${{ github.run_id }}-v18
-
name: Install Dependencies
run: npm install
- name: Add localhost-test to Linux hosts file
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts
# -
# name: Add localhost-test to Windows hosts file
Expand All @@ -55,24 +55,24 @@ jobs:
lint:
name: Lint
needs: [build_and_test]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
-
uses: actions/checkout@v2
-
name: Use Node.js 16
name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
-
name: Load Cache
uses: actions/cache@v2
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v16
key: cache-${{ github.run_id }}-v18
-
run: npm run lint

Expand All @@ -82,14 +82,14 @@ jobs:
deploy:
name: Publish to NPM
needs: [lint]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
-
uses: actions/checkout@v2
-
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org/
-
name: Load Cache
Expand All @@ -98,7 +98,7 @@ jobs:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v16
key: cache-${{ github.run_id }}-v18
-
# Determine if this is a beta or latest release
name: Set Release Tag
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import apify from '@apify/eslint-config';

// eslint-disable-next-line import/no-default-export
export default [
{ ignores: ['**/dist'] }, // Ignores need to happen first
...apify,
{
languageOptions: {
sourceType: 'module',

parserOptions: {
project: 'tsconfig.eslint.json',
},
},
rules: {
'no-param-reassign': 'off',
'import/extensions': 'off',
},
},
];
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "proxy-chain",
"version": "2.5.6",
"version": "2.5.7",
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",
"main": "dist/index.js",
"keywords": [
Expand Down Expand Up @@ -38,24 +38,22 @@
"local-proxy": "node ./dist/run_locally.js",
"test": "nyc cross-env NODE_OPTIONS=--insecure-http-parser mocha --bail",
"lint": "eslint src",
"lint-fix": "eslint src --fix"
"lint:fix": "eslint src --fix"
},
"engines": {
"node": ">=14"
},
"devDependencies": {
"@apify/eslint-config-ts": "^0.2.3",
"@apify/eslint-config": "^0.5.0-beta.2",
"@apify/tsconfig": "^0.1.0",
"@types/jest": "^28.1.2",
"@types/node": "^18.8.3",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"basic-auth": "^2.0.1",
"basic-auth-parser": "^0.0.2",
"body-parser": "^1.19.0",
"chai": "^4.3.4",
"cross-env": "^7.0.3",
"eslint": "^8.10.0",
"eslint": "^9.18.0",
"express": "^4.17.1",
"faye-websocket": "^0.11.4",
"got-scraping": "^3.2.4-beta.0",
Expand All @@ -73,6 +71,7 @@
"through": "^2.3.8",
"ts-node": "^10.2.1",
"typescript": "^4.4.3",
"typescript-eslint": "^8.20.0",
"underscore": "^1.13.1",
"ws": "^8.2.2"
},
Expand Down
16 changes: 8 additions & 8 deletions src/anonymize_proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import net from 'net';
import http from 'http';
import { Buffer } from 'buffer';
import type { Buffer } from 'buffer';
import type http from 'http';
import type net from 'net';
import { URL } from 'url';

import { Server, SOCKS_PROTOCOLS } from './server';
import { nodeify } from './utils/nodeify';

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

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

Expand All @@ -50,8 +50,8 @@ export const anonymizeProxy = (

let server: Server & { port: number };

const startServer = () => {
return Promise.resolve().then(() => {
const startServer = async () => {
return Promise.resolve().then(async () => {
server = new Server({
// verbose: true,
port,
Expand Down Expand Up @@ -83,7 +83,7 @@ export const anonymizeProxy = (
* and its result if `false`. Otherwise the result is `true`.
* @param closeConnections If true, pending proxy connections are forcibly closed.
*/
export const closeAnonymizedProxy = (
export const closeAnonymizedProxy = async (
anonymizedProxyUrl: string,
closeConnections: boolean,
callback?: (error: Error | null, result?: boolean) => void,
Expand Down
13 changes: 7 additions & 6 deletions src/chain.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { Buffer } from 'buffer';
import type dns from 'dns';
import type { EventEmitter } from 'events';
import http from 'http';
import https from 'https';
import dns from 'dns';
import { URL } from 'url';
import { EventEmitter } from 'events';
import { Buffer } from 'buffer';
import type { URL } from 'url';

import type { Socket } from './socket';
import { badGatewayStatusCodes, createCustomStatusHttpResponse, errorCodeToStatusCode } from './statuses';
import { countTargetBytes } from './utils/count_target_bytes';
import { getBasicAuthorizationHeader } from './utils/get_basic';
import { Socket } from './socket';
import { badGatewayStatusCodes, createCustomStatusHttpResponse, errorCodeToStatusCode } from './statuses';

interface Options {
method: string;
Expand Down
16 changes: 9 additions & 7 deletions src/chain_socks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import http from 'http';
import net from 'net';
import { Buffer } from 'buffer';
import type { Buffer } from 'buffer';
import type { EventEmitter } from 'events';
import type http from 'http';
import type net from 'net';
import { URL } from 'url';
import { EventEmitter } from 'events';
import { SocksClient, SocksClientError, type SocksProxy } from 'socks';
import { countTargetBytes } from './utils/count_target_bytes';
import { Socket } from './socket';

import { type SocksClientError, SocksClient, type SocksProxy } from 'socks';

import type { Socket } from './socket';
import { createCustomStatusHttpResponse, socksErrorMessageToStatusCode } from './statuses';
import { countTargetBytes } from './utils/count_target_bytes';

export interface HandlerOpts {
upstreamProxyUrlParsed: URL;
Expand Down
2 changes: 1 addition & 1 deletion src/custom_connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import net from 'net';
import type http from 'http';
import type net from 'net';
import { promisify } from 'util';

export const customConnect = async (socket: net.Socket, server: http.Server): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion src/custom_response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type http from 'http';
import type { Buffer } from 'buffer';
import type http from 'http';

export interface CustomResponse {
statusCode?: number;
Expand Down
9 changes: 5 additions & 4 deletions src/direct.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Buffer } from 'buffer';
import type dns from 'dns';
import type { EventEmitter } from 'events';
import net from 'net';
import dns from 'dns';
import { Buffer } from 'buffer';
import { URL } from 'url';
import { EventEmitter } from 'events';

import type { Socket } from './socket';
import { countTargetBytes } from './utils/count_target_bytes';
import { Socket } from './socket';

export interface HandlerOpts {
localAddress?: string;
Expand Down
11 changes: 6 additions & 5 deletions src/forward.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import dns from 'dns';
import type dns from 'dns';
import http from 'http';
import https from 'https';
import stream from 'stream';
import type { URL } from 'url';
import util from 'util';
import { URL } from 'url';
import { validHeadersOnly } from './utils/valid_headers_only';
import { getBasicAuthorizationHeader } from './utils/get_basic';
import { countTargetBytes } from './utils/count_target_bytes';

import { badGatewayStatusCodes, errorCodeToStatusCode } from './statuses';
import { countTargetBytes } from './utils/count_target_bytes';
import { getBasicAuthorizationHeader } from './utils/get_basic';
import { validHeadersOnly } from './utils/valid_headers_only';

const pipeline = util.promisify(stream.pipeline);

Expand Down
Loading

0 comments on commit 4c1fee5

Please sign in to comment.