Skip to content

Commit

Permalink
chore(package): upgrade to eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed Aug 31, 2024
1 parent 51cd442 commit 3848da1
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 288 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## next

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

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

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"restream",
"snyk",
"streamify",
"tseslint",
"typicode",
"vhosted",
"websockets",
Expand Down
40 changes: 40 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default tseslint.config(
// replacement of legacy `.eslintignore`
{
ignores: ['dist'],
},
// extends...
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'none', ignoreRestSiblings: false },
],
'prettier/prettier': 'warn',
},
},
{
files: ['src/**/*.ts'],
rules: {
'no-restricted-imports': ['error', { paths: ['express'] }],
},
},
);
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@
"devDependencies": {
"@commitlint/cli": "19.4.1",
"@commitlint/config-conventional": "19.4.1",
"@eslint/js": "9.9.1",
"@types/debug": "4.1.12",
"@types/eslint": "9.6.1",
"@types/eslint__js": "8.42.3",
"@types/express": "4.17.21",
"@types/is-glob": "4.0.4",
"@types/jest": "29.5.12",
"@types/micromatch": "4.0.9",
"@types/node": "22.5.1",
"@types/supertest": "6.0.2",
"@types/ws": "8.5.12",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"body-parser": "1.20.2",
"eslint": "8.57.0",
"eslint": "9.9.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"express": "4.19.2",
Expand All @@ -83,6 +84,7 @@
"supertest": "7.0.0",
"ts-jest": "29.2.5",
"typescript": "5.5.4",
"typescript-eslint": "8.3.0",
"ws": "8.18.0"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/get-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {

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

const defaultPlugins = !!options.ejectPlugins
const defaultPlugins = options.ejectPlugins
? [] // no default plugins when ejecting
: [debugProxyErrorsPlugin, proxyEventsPlugin, loggerPlugin, ...maybeErrorResponsePlugin];
const userPlugins: Plugin<TReq, TRes>[] = options.plugins ?? [];
Expand Down
4 changes: 2 additions & 2 deletions src/http-proxy-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export class HttpProxyMiddleware<TReq, TRes> {
debug(`proxy request to target: %O`, activeProxyOptions.target);
this.proxy.web(req, res, activeProxyOptions);
} catch (err) {
next && next(err);
next?.(err);
}
} else {
next && next();
next?.();
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-function */

import { Logger, Options } from './types';

/**
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
*/

/* eslint-disable @typescript-eslint/no-empty-interface */

import type * as http from 'http';
import type * as httpProxy from 'http-proxy';
import type * as net from 'net';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-unsafe-function-type */

export function getFunctionName(fn: Function): string {
return fn.name || '[anonymous Function]';
Expand Down
2 changes: 1 addition & 1 deletion test/types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-expressions */

import * as express from 'express';
import * as http from 'http';
Expand Down
1 change: 0 additions & 1 deletion test/unit/path-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ describe('Path Filter', () => {
});

it('should not throw error with Function', () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
expect(testPathFilter(() => {})).not.toThrowError(Error);
});
});
Expand Down
2 changes: 0 additions & 2 deletions test/unit/path-rewriter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,10 @@ describe('Path rewriting', () => {
});

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

it('should not throw when async function config is provided', () => {
// eslint-disable-next-line @typescript-eslint/no-empty-function
expect(badFn(async () => {})).not.toThrowError(Error);
});
});
Expand Down
1 change: 0 additions & 1 deletion test/unit/utils/function.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import { getFunctionName } from '../../../src/utils/function';

describe('getFunctionName()', () => {
Expand Down
Loading

0 comments on commit 3848da1

Please sign in to comment.