Skip to content

Commit 1e73d98

Browse files
test: fix (#1160)
1 parent 0233180 commit 1e73d98

File tree

24 files changed

+1459
-924
lines changed

24 files changed

+1459
-924
lines changed

package-lock.json

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

package.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
"@babel/preset-env": "^7.24.4",
6262
"@commitlint/cli": "^17.5.1",
6363
"@commitlint/config-conventional": "^17.4.4",
64-
"@eslint/js": "^9.32.0",
65-
"@eslint/markdown": "^7.0.0",
66-
"@stylistic/eslint-plugin": "^5.2.2",
6764
"@types/node": "^18.15.11",
6865
"bootstrap": "^4.6.2",
6966
"cross-env": "^7.0.3",
@@ -73,16 +70,8 @@
7370
"del-cli": "^4.0.0",
7471
"es-check": "^7.1.0",
7572
"eslint": "^9.32.0",
76-
"eslint-config-prettier": "^10.1.8",
7773
"eslint-config-webpack": "^4.4.2",
78-
"eslint-plugin-import": "^2.32.0",
79-
"eslint-plugin-jest": "^29.0.1",
80-
"eslint-plugin-jsdoc": "^62.0.0",
81-
"eslint-plugin-n": "^17.21.0",
82-
"eslint-plugin-prettier": "^5.5.3",
83-
"eslint-plugin-unicorn": "^62.0.0",
8474
"file-loader": "^6.2.0",
85-
"globals": "^17.0.0",
8675
"husky": "^7.0.0",
8776
"jest": "^28.1.3",
8877
"jest-environment-jsdom": "^28.1.3",
@@ -96,7 +85,6 @@
9685
"sass-loader": "^12.6.0",
9786
"standard-version": "^9.3.0",
9887
"typescript": "^5.8.0",
99-
"typescript-eslint": "^8.38.0",
10088
"webpack": "^5.102.0",
10189
"webpack-cli": "^4.9.2",
10290
"webpack-dev-server": "^5.2.1"

src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const {
4949
* @property {boolean=} ignoreOrder true when need to ignore order, otherwise false
5050
* @property {string | ((linkTag: HTMLLinkElement) => void)=} insert link insert place or a custom insert function
5151
* @property {Record<string, string>=} attributes link attributes
52-
* @property {string | false | 'text/css'=} linkType value of a link type attribute
52+
* @property {string | false | "text/css"=} linkType value of a link type attribute
5353
* @property {boolean=} runtime true when need to generate runtime code, otherwise false
5454
* @property {boolean=} experimentalUseImportModule true when need to use `experimentalUseImportModule` API, otherwise false
5555
*/
@@ -61,15 +61,15 @@ const {
6161
* @property {boolean} ignoreOrder true when need to ignore order, otherwise false
6262
* @property {string | ((linkTag: HTMLLinkElement) => void)=} insert a link insert place or a custom insert function
6363
* @property {Record<string, string>=} attributes link attributes
64-
* @property {string | false | 'text/css'=} linkType value of a link type attribute
64+
* @property {string | false | "text/css"=} linkType value of a link type attribute
6565
* @property {boolean} runtime true when need to generate runtime code, otherwise false
6666
* @property {boolean=} experimentalUseImportModule true when need to use `experimentalUseImportModule` API, otherwise false
6767
*/
6868

6969
/**
7070
* @typedef {object} RuntimeOptions
7171
* @property {string | ((linkTag: HTMLLinkElement) => void)=} insert a link insert place or a custom insert function
72-
* @property {string | false | 'text/css'} linkType value of a link type attribute
72+
* @property {string | false | "text/css"} linkType value of a link type attribute
7373
* @property {Record<string, string>=} attributes link attributes
7474
*/
7575

@@ -90,12 +90,12 @@ const CODE_GENERATION_RESULT = {
9090
};
9191

9292
// eslint-disable-next-line jsdoc/reject-any-type
93-
/** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: any, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: Source }}} CssModuleDependency */
93+
/** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: any, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: Source } }} CssModuleDependency */
9494
/** @typedef {Module & { content: Buffer, media?: string, sourceMap?: Buffer, supports?: string, layer?: string, assets?: { [key: string]: Source }, assetsInfo?: Map<string, AssetInfo> }} CssModule */
95-
/** @typedef {{ new(dependency: CssModuleDependency): CssModule }} CssModuleConstructor */
95+
/** @typedef {{ new (dependency: CssModuleDependency): CssModule }} CssModuleConstructor */
9696
/** @typedef {Dependency & CssModuleDependency} CssDependency */
9797
/** @typedef {Omit<LoaderDependency, "context">} CssDependencyOptions */
98-
/** @typedef {{ new(loaderDependency: CssDependencyOptions, context: string | null, identifierIndex: number): CssDependency }} CssDependencyConstructor */
98+
/** @typedef {{ new (loaderDependency: CssDependencyOptions, context: string | null, identifierIndex: number): CssDependency }} CssDependencyConstructor */
9999

100100
/**
101101
* @typedef {object} VarNames

src/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const MiniCssExtractPlugin = require("./index");
2525
/** @typedef {import("./index.js").LoaderOptions} LoaderOptions */
2626

2727
// eslint-disable-next-line jsdoc/reject-function-type
28-
/** @typedef {{[key: string]: string | Function }} Locals */
28+
/** @typedef {{ [key: string]: string | Function }} Locals */
2929

3030
// eslint-disable-next-line jsdoc/reject-any-type
3131
/** @typedef {any} EXPECTED_ANY */

src/utils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const toSimpleString = (str) => {
233233
const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
234234

235235
/**
236-
* @param {Array<string>} items items
236+
* @param {string[]} items items
237237
* @returns {string} common prefix
238238
*/
239239
const getCommonPrefix = (items) => {
@@ -253,7 +253,7 @@ const getCommonPrefix = (items) => {
253253
};
254254

255255
/**
256-
* @param {Array<string>} items items
256+
* @param {string[]} items items
257257
* @returns {string} common suffix
258258
*/
259259
const getCommonSuffix = (items) => {
@@ -279,27 +279,27 @@ const getCommonSuffix = (items) => {
279279
/**
280280
* @param {Set<string>} itemsSet items set
281281
* @param {(str: string) => string | false} getKey get key function
282-
* @param {(str: Array<string>) => boolean} condition condition
283-
* @returns {Array<Array<string>>} list of common items
282+
* @param {(str: string[]) => boolean} condition condition
283+
* @returns {string[][]} list of common items
284284
*/
285285
const popCommonItems = (itemsSet, getKey, condition) => {
286-
/** @type {Map<string, Array<string>>} */
286+
/** @type {Map<string, string[]>} */
287287
const map = new Map();
288288

289289
for (const item of itemsSet) {
290290
const key = getKey(item);
291291
if (key) {
292292
let list = map.get(key);
293293
if (list === undefined) {
294-
/** @type {Array<string>} */
294+
/** @type {string[]} */
295295
list = [];
296296
map.set(key, list);
297297
}
298298
list.push(item);
299299
}
300300
}
301301

302-
/** @type {Array<Array<string>>} */
302+
/** @type {string[][]} */
303303
const result = [];
304304

305305
for (const list of map.values()) {
@@ -315,15 +315,15 @@ const popCommonItems = (itemsSet, getKey, condition) => {
315315
};
316316

317317
/**
318-
* @param {Array<string>} itemsArr array of items
318+
* @param {string[]} itemsArr array of items
319319
* @returns {string} regexp
320320
*/
321321
const itemsToRegexp = (itemsArr) => {
322322
if (itemsArr.length === 1) {
323323
return quoteMeta(itemsArr[0]);
324324
}
325325

326-
/** @type {Array<string>} */
326+
/** @type {string[]} */
327327
const finishedItems = [];
328328

329329
// merge single char items: (a|b|c|d|ef) => ([abcd]|ef)

test/HMR.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @jest-environment jsdom
33
*/
4-
/* global document */
54

65
import hotModuleReplacement from "../src/hmr/hotModuleReplacement";
76
import { hotLoader } from "../src/loader";
@@ -26,9 +25,9 @@ describe("HMR", () => {
2625
let consoleMock = null;
2726

2827
beforeEach(() => {
29-
consoleMock = jest.spyOn(console, "log").mockImplementation(() => () => {});
28+
consoleMock = jest.spyOn(console, "log").mockReturnValue(() => {});
3029

31-
jest.spyOn(Date, "now").mockImplementation(() => 1479427200000);
30+
jest.spyOn(Date, "now").mockReturnValue(1479427200000);
3231

3332
document.head.innerHTML = '<link rel="stylesheet" href="/dist/main.css" />';
3433
document.body.innerHTML = '<script src="/dist/main.js"></script>';
@@ -80,7 +79,7 @@ describe("HMR", () => {
8079

8180
expect(links[1].isLoaded).toBe(true);
8281

83-
jest.spyOn(Date, "now").mockImplementation(() => 1479427200001);
82+
jest.spyOn(Date, "now").mockReturnValue(1479427200001);
8483

8584
const update2 = hotModuleReplacement("./src/style.css", {});
8685

test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.656f51af10a65a287c7e.css renamed to test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.0ca34a06508c170bc52a.css

File renamed without changes.

test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/656f51af10a65a287c7e.css renamed to test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0ca34a06508c170bc52a.css

File renamed without changes.

test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ __webpack_require__.r(__webpack_exports__);
7373
/******/
7474
/******/ /* webpack/runtime/getFullHash */
7575
/******/ (() => {
76-
/******/ __webpack_require__.h = () => ("656f51af10a65a287c7e")
76+
/******/ __webpack_require__.h = () => ("0ca34a06508c170bc52a")
7777
/******/ })();
7878
/******/
7979
/******/ /* webpack/runtime/global */

test/cases/chunkFilename-fullhash/expected/webpack-5/0.ff368441c28faebc6a1c.css renamed to test/cases/chunkFilename-fullhash/expected/webpack-5/0.605c3e6592e34107bde4.css

File renamed without changes.

0 commit comments

Comments
 (0)