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 61d1933 commit 9786b41
Show file tree
Hide file tree
Showing 15 changed files with 256 additions and 292 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

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

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"deno.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"markdown.extension.toc.levels": "2..3"
}
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
41 changes: 41 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const tseslint = require('typescript-eslint');
const tseslintParser = require('@typescript-eslint/parser');

/** @type {import('eslint').Linter.Config[]} */
module.exports = [
eslintPluginPrettierRecommended,
...tseslint.configs.recommended,
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/*.ts'],
ignores: ['dist/*'],
languageOptions: {
parser: tseslintParser,
},
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'],
ignores: ['dist/*'],
languageOptions: {
parser: tseslintParser,
},
rules: {
'no-restricted-imports': ['error', { paths: ['express'] }],
},
},
];
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@
"@commitlint/cli": "19.4.1",
"@commitlint/config-conventional": "19.4.1",
"@types/debug": "4.1.12",
"@types/eslint": "9.6.1",
"@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",
"@typescript-eslint/parser": "8.3.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 @@ -82,7 +82,8 @@
"prettier": "3.3.3",
"supertest": "7.0.0",
"ts-jest": "29.2.5",
"typescript": "5.5.4",
"typescript": "5.4.4",
"typescript-eslint": "8.3.0",
"ws": "8.18.0"
},
"dependencies": {
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 9786b41

Please sign in to comment.