Skip to content

Commit de0c973

Browse files
authored
build(prettier): improve prettier setup (#1108)
* build(prettier): improve prettier setup * chore(prettier): fix prettier lint
1 parent d5aac9e commit de0c973

38 files changed

+159
-231
lines changed

.prettierrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"printWidth": 100,
33
"tabWidth": 2,
44
"semi": true,
5-
"singleQuote": true
5+
"singleQuote": true,
6+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
7+
"importOrder": ["^node:.*$", "<THIRD_PARTY_MODULES>", "^[./]"],
8+
"importOrderSeparation": true,
9+
"importOrderSortSpecifiers": true
610
}

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
"editor.codeActionsOnSave": {
44
"source.fixAll.eslint": "explicit"
55
},
6+
"editor.defaultFormatter": "esbenp.prettier-vscode",
7+
"editor.formatOnSave": true,
68
"markdown.extension.toc.levels": "2..3"
79
}

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ Proxy `/api` requests to `http://www.example.org`
2828

2929
```typescript
3030
// typescript
31-
3231
import * as express from 'express';
33-
import type { Request, Response, NextFunction } from 'express';
34-
32+
import type { NextFunction, Request, Response } from 'express';
3533
import { createProxyMiddleware } from 'http-proxy-middleware';
3634
import type { Filter, Options, RequestHandler } from 'http-proxy-middleware';
3735

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"language": "en",
3-
"spellCheckDelayMs": 500,
43
"dictionaries": ["node", "npm", "typescript", "contributors"],
54
"ignorePaths": [
65
"node_modules/**",
@@ -46,6 +45,7 @@
4645
"restream",
4746
"snyk",
4847
"streamify",
48+
"trivago",
4949
"tseslint",
5050
"typicode",
5151
"vhosted",

eslint.config.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// @ts-check
2-
32
import eslint from '@eslint/js';
4-
import tseslint from 'typescript-eslint';
5-
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
63
import globals from 'globals';
4+
import tseslint from 'typescript-eslint';
75

86
export default tseslint.config(
97
// replacement of legacy `.eslintignore`
@@ -13,7 +11,6 @@ export default tseslint.config(
1311
// extends...
1412
eslint.configs.recommended,
1513
...tseslint.configs.recommended,
16-
eslintPluginPrettierRecommended,
1714
// base config
1815
{
1916
languageOptions: {
@@ -37,7 +34,6 @@ export default tseslint.config(
3734
'error',
3835
{ vars: 'all', args: 'none', ignoreRestSiblings: false },
3936
],
40-
'prettier/prettier': 'warn',
4137
},
4238
},
4339
{

examples/next-app/pages/api/_proxy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { NextApiRequest, NextApiResponse } from 'next';
2+
23
import { createProxyMiddleware } from '../../../../dist';
34

45
// Singleton

examples/next-app/pages/api/users.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { NextApiRequest, NextApiResponse, PageConfig } from 'next';
2+
23
import { proxyMiddleware } from './_proxy';
34

45
// https://nextjs.org/docs/pages/building-your-application/routing/api-routes

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@commitlint/cli": "19.8.0",
6060
"@commitlint/config-conventional": "19.8.0",
6161
"@eslint/js": "9.23.0",
62+
"@trivago/prettier-plugin-sort-imports": "5.2.2",
6263
"@types/debug": "4.1.12",
6364
"@types/eslint": "9.6.1",
6465
"@types/express": "4.17.21",
@@ -70,8 +71,6 @@
7071
"@types/ws": "8.18.0",
7172
"body-parser": "1.20.3",
7273
"eslint": "9.23.0",
73-
"eslint-config-prettier": "10.1.1",
74-
"eslint-plugin-prettier": "5.2.3",
7574
"express": "4.21.2",
7675
"get-port": "5.1.1",
7776
"globals": "16.0.0",

recipes/servers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export const proxyMiddleware = createProxyMiddleware<NextApiRequest, NextApiResp
105105

106106
```typescript
107107
// Next project: `/pages/api/users.ts`
108-
109108
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
110109
import type { NextApiRequest, NextApiResponse } from 'next';
110+
111111
import { proxyMiddleware } from './users.proxy';
112112

113113
export default function handler(req: NextApiRequest, res: NextApiResponse) {

src/factory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { HttpProxyMiddleware } from './http-proxy-middleware';
2-
import type { Options, RequestHandler, NextFunction } from './types';
31
import type * as http from 'http';
42

3+
import { HttpProxyMiddleware } from './http-proxy-middleware';
4+
import type { NextFunction, Options, RequestHandler } from './types';
5+
56
export function createProxyMiddleware<
67
TReq = http.IncomingMessage,
78
TRes = http.ServerResponse,

0 commit comments

Comments
 (0)