Skip to content

Commit c2f912a

Browse files
authored
chore(package): upgrade to eslint v9 (#1032)
1 parent 51cd442 commit c2f912a

16 files changed

+260
-288
lines changed

.eslintignore

-1
This file was deleted.

.eslintrc.js

-30
This file was deleted.

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## next
44

55
- refactor(dependency): replace is-plain-obj with is-plain-object
6+
- chore(package): upgrade to eslint v9
67

78
## [v3.0.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.1)
89

cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"restream",
4747
"snyk",
4848
"streamify",
49+
"tseslint",
4950
"typicode",
5051
"vhosted",
5152
"websockets",

eslint.config.mjs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
6+
7+
export default tseslint.config(
8+
// replacement of legacy `.eslintignore`
9+
{
10+
ignores: ['dist'],
11+
},
12+
// extends...
13+
eslint.configs.recommended,
14+
...tseslint.configs.recommended,
15+
eslintPluginPrettierRecommended,
16+
{
17+
files: ['*.js'],
18+
rules: {
19+
'@typescript-eslint/no-require-imports': 'off',
20+
'@typescript-eslint/no-var-requires': 'off',
21+
},
22+
},
23+
{
24+
files: ['**/*.ts'],
25+
rules: {
26+
'@typescript-eslint/no-explicit-any': 'off',
27+
'@typescript-eslint/no-unused-vars': [
28+
'error',
29+
{ vars: 'all', args: 'none', ignoreRestSiblings: false },
30+
],
31+
'prettier/prettier': 'warn',
32+
},
33+
},
34+
{
35+
files: ['src/**/*.ts'],
36+
rules: {
37+
'no-restricted-imports': ['error', { paths: ['express'] }],
38+
},
39+
},
40+
);

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,19 @@
5858
"devDependencies": {
5959
"@commitlint/cli": "19.4.1",
6060
"@commitlint/config-conventional": "19.4.1",
61+
"@eslint/js": "9.9.1",
6162
"@types/debug": "4.1.12",
63+
"@types/eslint": "9.6.1",
64+
"@types/eslint__js": "8.42.3",
6265
"@types/express": "4.17.21",
6366
"@types/is-glob": "4.0.4",
6467
"@types/jest": "29.5.12",
6568
"@types/micromatch": "4.0.9",
6669
"@types/node": "22.5.1",
6770
"@types/supertest": "6.0.2",
6871
"@types/ws": "8.5.12",
69-
"@typescript-eslint/eslint-plugin": "7.16.0",
70-
"@typescript-eslint/parser": "7.16.0",
7172
"body-parser": "1.20.2",
72-
"eslint": "8.57.0",
73+
"eslint": "9.9.1",
7374
"eslint-config-prettier": "9.1.0",
7475
"eslint-plugin-prettier": "5.2.1",
7576
"express": "4.19.2",
@@ -83,6 +84,7 @@
8384
"supertest": "7.0.0",
8485
"ts-jest": "29.2.5",
8586
"typescript": "5.5.4",
87+
"typescript-eslint": "8.3.0",
8688
"ws": "8.18.0"
8789
},
8890
"dependencies": {

src/get-plugins.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88

99
export function getPlugins<TReq, TRes>(options: Options<TReq, TRes>): Plugin<TReq, TRes>[] {
1010
// don't load default errorResponsePlugin if user has specified their own
11-
const maybeErrorResponsePlugin = !!options.on?.error ? [] : [errorResponsePlugin];
11+
const maybeErrorResponsePlugin = options.on?.error ? [] : [errorResponsePlugin];
1212

13-
const defaultPlugins = !!options.ejectPlugins
13+
const defaultPlugins = options.ejectPlugins
1414
? [] // no default plugins when ejecting
1515
: [debugProxyErrorsPlugin, proxyEventsPlugin, loggerPlugin, ...maybeErrorResponsePlugin];
1616
const userPlugins: Plugin<TReq, TRes>[] = options.plugins ?? [];

src/http-proxy-middleware.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export class HttpProxyMiddleware<TReq, TRes> {
4646
debug(`proxy request to target: %O`, activeProxyOptions.target);
4747
this.proxy.web(req, res, activeProxyOptions);
4848
} catch (err) {
49-
next && next(err);
49+
next?.(err);
5050
}
5151
} else {
52-
next && next();
52+
next?.();
5353
}
5454

5555
/**

src/logger.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-empty-function */
2-
31
import { Logger, Options } from './types';
42

53
/**

src/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
44
*/
55

6-
/* eslint-disable @typescript-eslint/no-empty-interface */
7-
86
import type * as http from 'http';
97
import type * as httpProxy from 'http-proxy';
108
import type * as net from 'net';

src/utils/function.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/ban-types */
1+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
22

33
export function getFunctionName(fn: Function): string {
44
return fn.name || '[anonymous Function]';

test/types.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-empty-function */
1+
/* eslint-disable @typescript-eslint/no-unused-expressions */
22

33
import * as express from 'express';
44
import * as http from 'http';

test/unit/path-filter.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ describe('Path Filter', () => {
246246
});
247247

248248
it('should not throw error with Function', () => {
249-
// eslint-disable-next-line @typescript-eslint/no-empty-function
250249
expect(testPathFilter(() => {})).not.toThrowError(Error);
251250
});
252251
});

test/unit/path-rewriter.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,10 @@ describe('Path rewriting', () => {
171171
});
172172

173173
it('should not throw when function config is provided', () => {
174-
// eslint-disable-next-line @typescript-eslint/no-empty-function
175174
expect(badFn(() => {})).not.toThrowError(Error);
176175
});
177176

178177
it('should not throw when async function config is provided', () => {
179-
// eslint-disable-next-line @typescript-eslint/no-empty-function
180178
expect(badFn(async () => {})).not.toThrowError(Error);
181179
});
182180
});

test/unit/utils/function.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-empty-function */
21
import { getFunctionName } from '../../../src/utils/function';
32

43
describe('getFunctionName()', () => {

0 commit comments

Comments
 (0)