Skip to content

Commit 8d98d11

Browse files
chore(deps): update
1 parent 1d5d6ee commit 8d98d11

10 files changed

Lines changed: 399 additions & 617 deletions

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/utils/ready.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("ready", () => {
99
};
1010
ready(context, cb);
1111

12-
expect(cb.mock.calls).toHaveLength(1);
12+
expect(cb).toHaveBeenCalledTimes(1);
1313
expect(cb.mock.calls[0]).toEqual(["stats"]);
1414
});
1515

@@ -29,7 +29,7 @@ describe("ready", () => {
2929
ready(context, cb, req);
3030

3131
expect(cb).not.toHaveBeenCalled();
32-
expect(context.logger.info.mock.calls).toHaveLength(1);
32+
expect(context.logger.info).toHaveBeenCalledTimes(1);
3333
expect(context.logger.info.mock.calls[0]).toEqual([
3434
"wait until bundle finished: url",
3535
]);
@@ -49,7 +49,7 @@ describe("ready", () => {
4949
ready(context, cb);
5050

5151
expect(cb).not.toHaveBeenCalled();
52-
expect(context.logger.info.mock.calls).toHaveLength(1);
52+
expect(context.logger.info).toHaveBeenCalledTimes(1);
5353
// mockConstructor is the name of the jest.fn() function
5454
expect(context.logger.info.mock.calls[0]).toEqual([
5555
"wait until bundle finished: mockConstructor",

test/utils/setupHooks.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ describe("setupHooks", () => {
5959

6060
it("taps watchRun, invalid, and done", () => {
6161
setupHooks(context);
62-
expect(watchRunHook.mock.calls).toHaveLength(1);
63-
expect(invalidHook.mock.calls).toHaveLength(1);
64-
expect(doneHook.mock.calls).toHaveLength(1);
62+
expect(watchRunHook).toHaveBeenCalledTimes(1);
63+
expect(invalidHook).toHaveBeenCalledTimes(1);
64+
expect(doneHook).toHaveBeenCalledTimes(1);
6565
});
6666

6767
it("watchRun hook invalidates", () => {
@@ -70,7 +70,7 @@ describe("setupHooks", () => {
7070
watchRunHook.mock.calls[0][1]();
7171
expect(context.state).toBe(false);
7272
expect(context.stats).toBeUndefined();
73-
expect(loggerInfo.mock.calls).toHaveLength(0);
73+
expect(loggerInfo).not.toHaveBeenCalled();
7474
});
7575

7676
it("invalid hook invalidates", () => {
@@ -79,7 +79,7 @@ describe("setupHooks", () => {
7979
invalidHook.mock.calls[0][1]();
8080
expect(context.state).toBe(false);
8181
expect(context.stats).toBeUndefined();
82-
expect(loggerInfo.mock.calls).toHaveLength(0);
82+
expect(loggerInfo).not.toHaveBeenCalled();
8383
});
8484

8585
it("logs if state is set on invalidate", () => {
@@ -101,12 +101,12 @@ describe("setupHooks", () => {
101101
});
102102
expect(context.stats).toBeTruthy();
103103
expect(context.state).toBeTruthy();
104-
expect(nextTick.mock.calls).toHaveLength(1);
104+
expect(nextTick).toHaveBeenCalledTimes(1);
105105

106106
nextTick.mock.calls[0][0]();
107107
expect(loggerInfo.mock.calls).toMatchSnapshot();
108-
expect(loggerError.mock.calls).toHaveLength(0);
109-
expect(loggerWarn.mock.calls).toHaveLength(0);
108+
expect(loggerError).not.toHaveBeenCalled();
109+
expect(loggerWarn).not.toHaveBeenCalled();
110110

111111
expect(cb1.mock.calls[0][0]).toEqual(context.stats);
112112
expect(cb2.mock.calls[0][0]).toEqual(context.stats);
@@ -117,10 +117,10 @@ describe("setupHooks", () => {
117117
doneHook.mock.calls[0][1]("stats");
118118
expect(context.stats).toBe("stats");
119119
expect(context.state).toBeTruthy();
120-
expect(nextTick.mock.calls).toHaveLength(1);
120+
expect(nextTick).toHaveBeenCalledTimes(1);
121121
context.state = false;
122122
nextTick.mock.calls[0][0]();
123-
expect(loggerInfo.mock.calls).toHaveLength(0);
123+
expect(loggerInfo).not.toHaveBeenCalled();
124124
});
125125

126126
it("handles multi compiler", () => {
@@ -155,7 +155,7 @@ describe("setupHooks", () => {
155155
});
156156
expect(context.stats).toBeTruthy();
157157
expect(context.state).toBeTruthy();
158-
expect(nextTick.mock.calls).toHaveLength(1);
158+
expect(nextTick).toHaveBeenCalledTimes(1);
159159

160160
nextTick.mock.calls[0][0]();
161161
expect(loggerInfo.mock.calls).toMatchSnapshot();

test/utils/setupOutputFileSystem.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("setupOutputFileSystem", () => {
2424
// make sure that this is the default fs created
2525
expect(context.compiler.outputFileSystem.testFs).toBeTruthy();
2626
expect(context.outputFileSystem.testFs).toBeTruthy();
27-
expect(createFsFromVolume.mock.calls).toHaveLength(1);
27+
expect(createFsFromVolume).toHaveBeenCalledTimes(1);
2828
});
2929

3030
it("should set fs for multi compiler", () => {

test/utils/setupWriteToDisk.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("setupWriteToDisk", () => {
5656
// this simulates the emit hook being called twice
5757
emitHook.mock.calls[0][1]();
5858
emitHook.mock.calls[0][1]();
59-
expect(assetEmittedHook.mock.calls).toHaveLength(1);
59+
expect(assetEmittedHook).toHaveBeenCalledTimes(1);
6060
});
6161

6262
it("filters out unwanted emits with writeToDisk", () => {
@@ -77,14 +77,14 @@ describe("setupWriteToDisk", () => {
7777
);
7878

7979
// the getPath helper is not needed for webpack@5
80-
expect(getPath.mock.calls).toHaveLength(0);
80+
expect(getPath).not.toHaveBeenCalled();
8181

82-
expect(filter.mock.calls).toHaveLength(1);
82+
expect(filter).toHaveBeenCalledTimes(1);
8383
expect(filter.mock.calls[0][0]).toBe("targetPath");
8484
// the callback should always be called
85-
expect(cb.mock.calls).toHaveLength(1);
85+
expect(cb).toHaveBeenCalledTimes(1);
8686
// the filter prevents a directory from being made
87-
expect(mkdirSpy.mock.calls).toHaveLength(0);
87+
expect(mkdirSpy).not.toHaveBeenCalled();
8888
});
8989

9090
const writeErrors = [
@@ -123,18 +123,18 @@ describe("setupWriteToDisk", () => {
123123
);
124124

125125
// the getPath helper is not needed for webpack@5
126-
expect(getPath.mock.calls).toHaveLength(0);
126+
expect(getPath).not.toHaveBeenCalled();
127127

128-
expect(mkdirSpy.mock.calls).toHaveLength(1);
128+
expect(mkdirSpy).toHaveBeenCalledTimes(1);
129129
expect(mkdirSpy.mock.calls[0][0]).toBe("/target/path");
130130

131131
// simulates the mkdir callback being called
132132
mkdirSpy.mock.calls[0][2](writeError.mkdirError);
133133

134134
if (writeError.mkdirError) {
135-
expect(writeFileSpy.mock.calls).toHaveLength(0);
135+
expect(writeFileSpy).not.toHaveBeenCalled();
136136
} else {
137-
expect(writeFileSpy.mock.calls).toHaveLength(1);
137+
expect(writeFileSpy).toHaveBeenCalledTimes(1);
138138
expect(writeFileSpy.mock.calls[0][0]).toBe("/target/path/file");
139139
expect(writeFileSpy.mock.calls[0][1]).toBe("content");
140140

@@ -147,7 +147,7 @@ describe("setupWriteToDisk", () => {
147147
expect(context.logger.log.mock.calls).toMatchSnapshot();
148148

149149
// the callback should always be called
150-
expect(cb.mock.calls).toHaveLength(1);
150+
expect(cb).toHaveBeenCalledTimes(1);
151151
// no errors are expected
152152
expect(cb.mock.calls).toMatchSnapshot();
153153
});

test/validation-options.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ describe("validation", () => {
8787
},
8888
};
8989

90-
// eslint-disable-next-line jsdoc/no-restricted-syntax
90+
// eslint-disable-next-line jsdoc/reject-any-type
91+
/** @typedef {any} EXPECTED_ANY */
92+
9193
/**
92-
* @param {any} value value
94+
* @param {EXPECTED_ANY} value value
9395
* @returns {string} stringified value
9496
*/
9597
function stringifyValue(value) {
@@ -103,10 +105,9 @@ describe("validation", () => {
103105
return value;
104106
}
105107

106-
// eslint-disable-next-line jsdoc/no-restricted-syntax
107108
/**
108109
* @param {string} key key
109-
* @param {any} value value
110+
* @param {EXPECTED_ANY} value value
110111
* @param {"success" | "failure"} type type
111112
*/
112113
function createTestCase(key, value, type) {

0 commit comments

Comments
 (0)