Skip to content

Commit 3825f9b

Browse files
chore(deps): update (#2227)
1 parent 1d5d6ee commit 3825f9b

14 files changed

+500
-703
lines changed

package-lock.json

Lines changed: 338 additions & 553 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"clean": "del-cli dist types",
3737
"prebuild": "npm run clean",
3838
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
39-
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
39+
"build:code": "babel src -d dist --copy-files",
4040
"build": "npm-run-all -p \"build:**\"",
41-
"test:only": "cross-env NODE_ENV=test jest",
41+
"test:only": "jest",
4242
"test:watch": "npm run test:only -- --watch",
4343
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
4444
"pretest": "npm run lint",
@@ -60,8 +60,8 @@
6060
"@babel/preset-env": "^7.16.7",
6161
"@eslint/js": "^9.28.0",
6262
"@eslint/markdown": "^7.1.0",
63-
"@commitlint/cli": "^19.0.3",
64-
"@commitlint/config-conventional": "^19.0.3",
63+
"@commitlint/cli": "^20.2.0",
64+
"@commitlint/config-conventional": "^20.2.0",
6565
"@fastify/express": "^4.0.2",
6666
"@hapi/hapi": "^21.3.7",
6767
"@hono/node-server": "^1.12.0",
@@ -73,7 +73,6 @@
7373
"@types/on-finished": "^2.3.4",
7474
"babel-jest": "^30.1.2",
7575
"connect": "^3.7.0",
76-
"cross-env": "^7.0.3",
7776
"cspell": "^8.3.2",
7877
"deepmerge": "^4.2.2",
7978
"del-cli": "^6.0.0",
@@ -83,10 +82,10 @@
8382
"eslint-config-prettier": "^10.1.5",
8483
"eslint-plugin-import": "^2.31.0",
8584
"eslint-plugin-jest": "^29.0.1",
86-
"eslint-plugin-jsdoc": "^56.1.2",
85+
"eslint-plugin-jsdoc": "^61.5.0",
8786
"eslint-plugin-n": "^17.19.0",
8887
"eslint-plugin-prettier": "^5.4.1",
89-
"eslint-plugin-unicorn": "^61.0.2",
88+
"eslint-plugin-unicorn": "^62.0.0",
9089
"execa": "^5.1.1",
9190
"express-4": "npm:express@^4",
9291
"express": "^5.1.0",

src/index.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ const noop = () => {};
2727
/** @typedef {import("http").IncomingMessage} IncomingMessage */
2828
/** @typedef {import("http").ServerResponse & ExtendedServerResponse} ServerResponse */
2929

30-
// eslint-disable-next-line jsdoc/no-restricted-syntax
30+
// eslint-disable-next-line jsdoc/reject-any-type
31+
/** @typedef {any} EXPECTED_ANY */
32+
// eslint-disable-next-line jsdoc/reject-function-type
33+
/** @typedef {Function} EXPECTED_FUNCTION */
34+
3135
/**
3236
* @callback NextFunction
33-
* @param {any=} err error
37+
* @param {EXPECTED_ANY=} err error
3438
* @returns {void}
3539
*/
3640

@@ -386,21 +390,19 @@ function hapiWrapper() {
386390

387391
wdm.hapiWrapper = hapiWrapper;
388392

389-
// eslint-disable-next-line jsdoc/no-restricted-syntax
390393
/**
391394
* @template {IncomingMessage} [RequestInternal=IncomingMessage]
392395
* @template {ServerResponse} [ResponseInternal=ServerResponse]
393396
* @param {Compiler | MultiCompiler} compiler compiler
394397
* @param {Options<RequestInternal, ResponseInternal>=} options options
395-
* @returns {(ctx: any, next: Function) => Promise<void> | void} kow wrapper
398+
* @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void} kow wrapper
396399
*/
397400
function koaWrapper(compiler, options) {
398401
const devMiddleware = wdm(compiler, options);
399402

400-
// eslint-disable-next-line jsdoc/no-restricted-syntax
401403
/**
402404
* @param {{req: RequestInternal, res: ResponseInternal & import("./utils/compatibleAPI").ExpectedServerResponse, status: number, body: string | Buffer | import("fs").ReadStream | {message: string}, state: object}} ctx context
403-
* @param {Function} next next
405+
* @param {EXPECTED_FUNCTION} next next
404406
* @returns {Promise<void>}
405407
*/
406408
async function webpackDevMiddleware(ctx, next) {
@@ -501,21 +503,19 @@ function koaWrapper(compiler, options) {
501503

502504
wdm.koaWrapper = koaWrapper;
503505

504-
// eslint-disable-next-line jsdoc/no-restricted-syntax
505506
/**
506507
* @template {IncomingMessage} [RequestInternal=IncomingMessage]
507508
* @template {ServerResponse} [ResponseInternal=ServerResponse]
508509
* @param {Compiler | MultiCompiler} compiler compiler
509510
* @param {Options<RequestInternal, ResponseInternal>=} options options
510-
* @returns {(ctx: any, next: Function) => Promise<void> | void} hono wrapper
511+
* @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void} hono wrapper
511512
*/
512513
function honoWrapper(compiler, options) {
513514
const devMiddleware = wdm(compiler, options);
514515

515-
// eslint-disable-next-line jsdoc/no-restricted-syntax
516516
/**
517-
* @param {{ env: any, body: any, json: any, status: any, set: any, req: RequestInternal & import("./utils/compatibleAPI").ExpectedIncomingMessage & { header: (name: string) => string }, res: ResponseInternal & import("./utils/compatibleAPI").ExpectedServerResponse & { headers: any, status: any } }} context context
518-
* @param {Function} next next function
517+
* @param {{ env: EXPECTED_ANY, body: EXPECTED_ANY, json: EXPECTED_ANY, status: EXPECTED_ANY, set: EXPECTED_ANY, req: RequestInternal & import("./utils/compatibleAPI").ExpectedIncomingMessage & { header: (name: string) => string }, res: ResponseInternal & import("./utils/compatibleAPI").ExpectedServerResponse & { headers: EXPECTED_ANY, status: EXPECTED_ANY } }} context context
518+
* @param {EXPECTED_FUNCTION} next next function
519519
* @returns {Promise<void>}
520520
*/
521521
async function webpackDevMiddleware(context, next) {
@@ -559,11 +559,10 @@ function honoWrapper(compiler, options) {
559559
*/
560560
res.getHeader = (name) => context.res.headers.get(name);
561561

562-
// eslint-disable-next-line jsdoc/no-restricted-syntax
563562
/**
564563
* @param {string} name header name
565564
* @param {string | number | Readonly<string[]>} value value
566-
* @returns {ResponseInternal & import("./utils/compatibleAPI").ExpectedServerResponse & { headers: any, status: any }} response
565+
* @returns {ResponseInternal & import("./utils/compatibleAPI").ExpectedServerResponse & { headers: EXPECTED_ANY, status: EXPECTED_ANY }} response
567566
*/
568567
res.setHeader = (name, value) => {
569568
context.res.headers.append(name, value);

src/utils/compatibleAPI.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/** @typedef {import("../index.js").IncomingMessage} IncomingMessage */
2-
/** @typedef {import("../index.js").ServerResponse} ServerResponse */
1+
/** @typedef {import("../index").IncomingMessage} IncomingMessage */
2+
/** @typedef {import("../index").ServerResponse} ServerResponse */
33
/** @typedef {import("../index").OutputFileSystem} OutputFileSystem */
4+
/** @typedef {import("../index").EXPECTED_ANY} EXPECTED_ANY */
45

56
/**
67
* @typedef {object} ExpectedIncomingMessage
@@ -9,7 +10,6 @@
910
* @property {(() => string | undefined)=} getURL get URL extra method
1011
*/
1112

12-
// eslint-disable-next-line jsdoc/no-restricted-syntax
1313
/**
1414
* @typedef {object} ExpectedServerResponse
1515
* @property {((status: number) => void)=} setStatusCode set status code
@@ -21,9 +21,9 @@
2121
* @property {((data?: string | Buffer) => void)=} finish finish
2222
* @property {(() => string[])=} getResponseHeaders get response header
2323
* @property {(() => boolean)=} getHeadersSent get headers sent
24-
* @property {((data: any) => void)=} stream stream
25-
* @property {(() => any)=} getOutgoing get outgoing
26-
* @property {((name: string, value: any) => void)=} setState set state
24+
* @property {((data: EXPECTED_ANY) => void)=} stream stream
25+
* @property {(() => EXPECTED_ANY)=} getOutgoing get outgoing
26+
* @property {((name: string, value: EXPECTED_ANY) => void)=} setState set state
2727
*/
2828

2929
/**
@@ -280,12 +280,11 @@ function initState(res) {
280280
res.locals ||= {};
281281
}
282282

283-
// eslint-disable-next-line jsdoc/no-restricted-syntax
284283
/**
285284
* @template {ServerResponse & ExpectedServerResponse} Response
286285
* @param {Response} res res
287286
* @param {string} name name
288-
* @param {any} value state
287+
* @param {EXPECTED_ANY} value state
289288
* @returns {void}
290289
*/
291290
function setState(res, name, value) {
@@ -295,8 +294,7 @@ function setState(res, name, value) {
295294
return;
296295
}
297296

298-
// eslint-disable-next-line jsdoc/no-restricted-syntax
299-
/** @type {any} */
297+
/** @type {Record<string, EXPECTED_ANY>} */
300298
(res.locals)[name] = value;
301299
}
302300

src/utils/memorize.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/** @typedef {import("../index").EXPECTED_ANY} EXPECTED_ANY */
2+
13
const cacheStore = new WeakMap();
24

3-
// eslint-disable-next-line jsdoc/no-restricted-syntax
45
/**
56
* @template T
6-
* @typedef {(...args: any) => T} FunctionReturning
7+
* @typedef {(...args: EXPECTED_ANY) => T} FunctionReturning
78
*/
89

910
/**
@@ -14,10 +15,9 @@ const cacheStore = new WeakMap();
1415
* @returns {FunctionReturning<T>} new function
1516
*/
1617
function memorize(fn, { cache = new Map() } = {}, callback = undefined) {
17-
// eslint-disable-next-line jsdoc/no-restricted-syntax
1818
/**
19-
* @param {any} arguments_ args
20-
* @returns {any} result
19+
* @param {EXPECTED_ANY[]} arguments_ args
20+
* @returns {EXPECTED_ANY} result
2121
*/
2222
const memoized = (...arguments_) => {
2323
const [key] = arguments_;

test/middleware.test.js

Lines changed: 71 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,7 @@ describe.each([
31613161

31623162
describe("should handle custom fs errors and response 500 code without `fs.createReadStream`", () => {
31633163
let compiler;
3164+
// Try to disable this
31643165

31653166
const outputPath = path.resolve(
31663167
__dirname,
@@ -4004,83 +4005,87 @@ describe.each([
40044005
});
40054006

40064007
describe("writeToDisk option", () => {
4007-
describe('should work with "true" value', () => {
4008-
let compiler;
4008+
(name === "hono" ? describe.only : describe)(
4009+
'should work with "true" value',
4010+
() => {
4011+
let compiler;
40094012

4010-
const outputPath = path.resolve(
4011-
__dirname,
4012-
"./outputs/write-to-disk-true",
4013-
);
4013+
const outputPath = path.resolve(
4014+
__dirname,
4015+
"./outputs/write-to-disk-true",
4016+
);
40144017

4015-
beforeAll(async () => {
4016-
compiler = getCompiler({
4017-
...webpackConfig,
4018-
output: {
4019-
filename: "bundle.js",
4020-
path: outputPath,
4021-
publicPath: "/public/",
4022-
},
4023-
});
4018+
beforeAll(async () => {
4019+
compiler = getCompiler({
4020+
...webpackConfig,
4021+
output: {
4022+
filename: "bundle.js",
4023+
path: outputPath,
4024+
publicPath: "/public/",
4025+
},
4026+
});
40244027

4025-
[server, req, instance] = await frameworkFactory(
4026-
name,
4027-
framework,
4028-
compiler,
4029-
{ writeToDisk: true },
4030-
);
4031-
});
4028+
[server, req, instance] = await frameworkFactory(
4029+
name,
4030+
framework,
4031+
compiler,
4032+
{ writeToDisk: true },
4033+
);
4034+
});
40324035

4033-
afterAll(async () => {
4034-
await fs.promises.rm(outputPath, {
4035-
recursive: true,
4036-
force: true,
4036+
afterAll(async () => {
4037+
await fs.promises.rm(outputPath, {
4038+
recursive: true,
4039+
force: true,
4040+
});
4041+
await close(server, instance);
40374042
});
4038-
await close(server, instance);
4039-
});
40404043

4041-
it("should find the bundle file on disk", (done) => {
4042-
req.get("/public/bundle.js").expect(200, (error) => {
4043-
if (error) {
4044-
return done(error);
4045-
}
4044+
it("should find the bundle file on disk", (done) => {
4045+
req.get("/public/bundle.js").expect(200, (error) => {
4046+
if (error) {
4047+
return done(error);
4048+
}
40464049

4047-
const bundlePath = path.resolve(
4048-
__dirname,
4049-
"./outputs/write-to-disk-true/bundle.js",
4050-
);
4050+
const bundlePath = path.resolve(
4051+
__dirname,
4052+
"./outputs/write-to-disk-true/bundle.js",
4053+
);
40514054

4052-
expect(
4053-
compiler.hooks.assetEmitted.taps.filter(
4054-
(hook) => hook.name === "DevMiddleware",
4055-
),
4056-
).toHaveLength(1);
4057-
expect(fs.existsSync(bundlePath)).toBe(true);
4055+
expect(
4056+
compiler.hooks.assetEmitted.taps.filter(
4057+
(hook) => hook.name === "DevMiddleware",
4058+
),
4059+
).toHaveLength(1);
4060+
expect(fs.existsSync(bundlePath)).toBe(true);
40584061

4059-
instance.invalidate();
4062+
instance.invalidate();
40604063

4061-
return compiler.hooks.done.tap(
4062-
"DevMiddlewareWriteToDiskTest",
4063-
() => {
4064-
expect(
4065-
compiler.hooks.assetEmitted.taps.filter(
4066-
(hook) => hook.name === "DevMiddleware",
4067-
),
4068-
).toHaveLength(1);
4064+
return compiler.hooks.done.tap(
4065+
"DevMiddlewareWriteToDiskTest",
4066+
() => {
4067+
expect(
4068+
compiler.hooks.assetEmitted.taps.filter(
4069+
(hook) => hook.name === "DevMiddleware",
4070+
),
4071+
).toHaveLength(1);
40694072

4070-
done();
4071-
},
4072-
);
4073+
done();
4074+
},
4075+
);
4076+
});
40734077
});
4074-
});
40754078

4076-
it("should not allow to get files above root", async () => {
4077-
const response = await req.get("/public/..%2f../middleware.test.js");
4079+
it("should not allow to get files above root", async () => {
4080+
const response = await req.get(
4081+
"/public/..%2f../middleware.test.js",
4082+
);
40784083

4079-
expect(response.statusCode).toBe(403);
4080-
expect(response.headers["content-type"]).toBe(
4081-
"text/html; charset=utf-8",
4082-
);
4083-
expect(response.text).toBe(`<!DOCTYPE html>
4084+
expect(response.statusCode).toBe(403);
4085+
expect(response.headers["content-type"]).toBe(
4086+
"text/html; charset=utf-8",
4087+
);
4088+
expect(response.text).toBe(`<!DOCTYPE html>
40844089
<html lang="en">
40854090
<head>
40864091
<meta charset="utf-8">
@@ -4090,8 +4095,9 @@ describe.each([
40904095
<pre>Forbidden</pre>
40914096
</body>
40924097
</html>`);
4093-
});
4094-
});
4098+
});
4099+
},
4100+
);
40954101

40964102
describe('should work with "true" value when the `output.clean` is `true`', () => {
40974103
const outputPath = path.resolve(

0 commit comments

Comments
 (0)