Skip to content

Commit b605635

Browse files
chore: update eslint
1 parent 1cc4fe8 commit b605635

File tree

11 files changed

+3238
-1112
lines changed

11 files changed

+3238
-1112
lines changed

package-lock.json

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

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
"commitlint": "commitlint --from=master",
4444
"security": "npm audit",
4545
"lint:prettier": "prettier --cache --list-different .",
46-
"lint:js": "eslint --cache .",
46+
"lint:code": "eslint --cache .",
4747
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
4848
"lint:types": "tsc --pretty --noEmit",
4949
"lint": "npm-run-all -l -p \"lint:**\"",
50-
"fix:js": "npm run lint:js -- --fix",
50+
"fix:code": "npm run lint:code -- --fix",
5151
"fix:prettier": "npm run lint:prettier -- --write",
52-
"fix": "npm-run-all -l fix:js fix:prettier",
52+
"fix": "npm-run-all -l fix:code fix:prettier",
5353
"test:only": "cross-env NODE_ENV=test NODE_OPTIONS=\"--experimental-vm-modules\" jest",
5454
"test:watch": "npm run test:only -- --watch",
5555
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
@@ -72,17 +72,18 @@
7272
"@babel/preset-env": "^7.25.3",
7373
"@commitlint/cli": "^19.3.0",
7474
"@commitlint/config-conventional": "^19.2.2",
75+
"@eslint/js": "^9.32.0",
7576
"@eslint/markdown": "^7.0.0",
7677
"@parcel/css": "^1.8.3",
77-
"@stylistic/eslint-plugin": "^5.2.0",
78+
"@stylistic/eslint-plugin": "^5.2.2",
7879
"@swc/css": "^0.0.28",
7980
"@types/clean-css": "^4.2.11",
8081
"@types/csso": "^5.0.4",
8182
"@types/node": "^20.14.9",
8283
"@types/serialize-javascript": "^5.0.4",
83-
"babel-jest": "^29.7.0",
84+
"babel-jest": "^30.0.5",
8485
"clean-css": "^5.3.3",
85-
"copy-webpack-plugin": "^9.1.0",
86+
"copy-webpack-plugin": "^13.0.0",
8687
"cross-env": "^7.0.3",
8788
"cspell": "^8.13.1",
8889
"css-loader": "^6.10.0",
@@ -96,10 +97,11 @@
9697
"eslint-config-webpack": "^4.4.1",
9798
"eslint-plugin-import": "^2.32.0",
9899
"eslint-plugin-jest": "^29.0.1",
99-
"eslint-plugin-jsdoc": "^51.4.1",
100+
"eslint-plugin-jsdoc": "^52.0.0",
100101
"eslint-plugin-n": "^17.21.0",
101102
"eslint-plugin-prettier": "^5.5.3",
102103
"eslint-plugin-unicorn": "^60.0.0",
104+
"globals": "^16.3.0",
103105
"husky": "^9.1.4",
104106
"jest": "^30.0.5",
105107
"lightningcss": "^1.25.1",
@@ -111,7 +113,7 @@
111113
"sass": "^1.77.8",
112114
"sass-loader": "^16.0.5",
113115
"standard-version": "^9.5.0",
114-
"sugarss": "^4.0.1",
116+
"sugarss": "^5.0.0",
115117
"typescript": "^5.5.4",
116118
"webpack": "^5.93.0"
117119
},

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const {
2121
/** @typedef {import("webpack").Compilation} Compilation */
2222
/** @typedef {import("webpack").WebpackError} WebpackError */
2323
/** @typedef {import("jest-worker").Worker} JestWorker */
24-
/** @typedef {import("@jridgewell/trace-mapping").EncodedSourceMap} RawSourceMap */
24+
/** @typedef {import("@jridgewell/trace-mapping").EncodedSourceMap & { sources: string[], sourcesContent?: string[], file: string }} RawSourceMap */
2525
/** @typedef {import("webpack").Asset} Asset */
2626
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
2727
/** @typedef {import("postcss").Syntax} Syntax */

src/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @typedef {import("./index.js").Input} Input */
2-
/** @typedef {import("@jridgewell/trace-mapping").EncodedSourceMap} RawSourceMap */
2+
/** @typedef {import("./index.js").RawSourceMap} RawSourceMap */
33
/** @typedef {import("./index.js").MinimizedResult} MinimizedResult */
44
/** @typedef {import("./index.js").CustomOptions} CustomOptions */
55
/** @typedef {import("postcss").ProcessOptions} ProcessOptions */
@@ -180,7 +180,6 @@ async function cssnanoMinify(
180180

181181
return {
182182
code: result.css,
183-
184183
map: result.map
185184
? /** @type {RawSourceMap} */ (
186185
/** @type {unknown} */ (result.map.toJSON())

test/__snapshots__/CssMinimizerPlugin.test.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`CssMinimizerPlugin buildError method 1`] = `
44
[Error: test.css from Css Minimizer plugin
@@ -61,15 +61,15 @@ exports[`CssMinimizerPlugin should build error: error 1`] = `
6161

6262
exports[`CssMinimizerPlugin should build error: warning 1`] = `[]`;
6363

64-
exports[`CssMinimizerPlugin should build warning: error 1`] = `
64+
exports[`CssMinimizerPlugin should build warning: error 1`] = `[]`;
65+
66+
exports[`CssMinimizerPlugin should build warning: warning 1`] = `
6567
[
66-
"Error: foo.css from Css Minimizer plugin
67-
DataCloneError: [object Object] could not be cloned.",
68+
"Warning: foo.css from Css Minimizer plugin
69+
[warning-plugin] Warning webpack://./test/foo.css:2:2",
6870
]
6971
`;
7072

71-
exports[`CssMinimizerPlugin should build warning: warning 1`] = `[]`;
72-
7373
exports[`CssMinimizerPlugin should respect the hash options #1: assets 1`] = `
7474
{
7575
"entry.css": "a{text-align:center}",

test/__snapshots__/minify-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ exports[`"minify" option should work with "CssMinimizerPlugin.cssnanoMinify" min
190190

191191
exports[`"minify" option should work with "CssMinimizerPlugin.cssnanoMinify" minifier and generate source maps: warning 1`] = `[]`;
192192

193-
exports[`"minify" option should work with "CssMinimizerPlugin.cssnanoMinify" minifier and parser option as "String": entry.js.map 1`] = `"{"version":3,"file":"entry.js","mappings":";;UAAA;UACA;;;;;WCDA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;ACNO","sources":["webpack:///webpack/bootstrap","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./sugarss.js"],"sourcesContent":["// The require scope\\nvar __webpack_require__ = {};\\n\\n","// define getter functions for harmony exports\\n__webpack_require__.d = (exports, definition) => {\\n\\tfor(var key in definition) {\\n\\t\\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\\n\\t\\t\\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\\n\\t\\t}\\n\\t}\\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\\n__webpack_require__.r = (exports) => {\\n\\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\\n\\t\\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\\n\\t}\\n\\tObject.defineProperty(exports, '__esModule', { value: true });\\n};","export const foo = 'foo';\\n"],"names":[],"sourceRoot":""}"`;
193+
exports[`"minify" option should work with "CssMinimizerPlugin.cssnanoMinify" minifier and parser option as "String": entry.js.map 1`] = `"{"version":3,"file":"entry.js","mappings":";;UAAA;UACA;;;;;WCDA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;;;;;ACNO","sources":["webpack:///webpack/bootstrap","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./sugarss.js"],"sourcesContent":["// The require scope\\nvar __webpack_require__ = {};\\n\\n","// define getter functions for harmony exports\\n__webpack_require__.d = (exports, definition) => {\\n\\tfor(var key in definition) {\\n\\t\\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\\n\\t\\t\\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\\n\\t\\t}\\n\\t}\\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\\n__webpack_require__.r = (exports) => {\\n\\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\\n\\t\\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\\n\\t}\\n\\tObject.defineProperty(exports, '__esModule', { value: true });\\n};","export const foo = 'foo';\\n"],"names":[],"sourceRoot":""}"`;
194194

195195
exports[`"minify" option should work with "CssMinimizerPlugin.cssnanoMinify" minifier and parser option as "String": index.sss 1`] = `"a{color:#000}"`;
196196

test/__snapshots__/parallel-option.test.js.snap

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`parallel option should match snapshot for the "2" value: assets 1`] = `
44
{
@@ -30,8 +30,6 @@ exports[`parallel option should match snapshot for the "true" value and the numb
3030
{
3131
"entry-0.css": "body{color:red}a{color:blue}",
3232
"entry-1.css": "body{color:red}a{color:blue}",
33-
"entry-2.css": "body{color:red}a{color:blue}",
34-
"entry-3.css": "body{color:red}a{color:blue}",
3533
}
3634
`;
3735

@@ -62,10 +60,6 @@ exports[`parallel option should match snapshot for the "true" value and the numb
6260
"entry-1.css": "body{color:red}a{color:blue}",
6361
"entry-2.css": "body{color:red}a{color:blue}",
6462
"entry-3.css": "body{color:red}a{color:blue}",
65-
"entry-4.css": "body{color:red}a{color:blue}",
66-
"entry-5.css": "body{color:red}a{color:blue}",
67-
"entry-6.css": "body{color:red}a{color:blue}",
68-
"entry-7.css": "body{color:red}a{color:blue}",
6963
}
7064
`;
7165

test/helpers/normalizeErrors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ function removeCWD(str) {
88
let normalizedStr = str;
99

1010
if (isWin) {
11-
normalizedStr = normalizedStr.replace(/\\/g, "/");
12-
cwd = cwd.replace(/\\/g, "/");
11+
normalizedStr = normalizedStr.replaceAll("\\", "/");
12+
cwd = cwd.replaceAll("\\", "/");
1313
}
1414

15-
return normalizedStr.replace(new RegExp(cwd, "g"), "");
15+
return normalizedStr.replaceAll(new RegExp(cwd, "g"), "");
1616
}
1717

1818
/**

test/parallel-option.test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ import {
1313
readAssets,
1414
} from "./helpers";
1515

16-
// Mock removed - using real values
16+
jest.mock("node:os", () => {
17+
const actualOs = jest.requireActual("os");
18+
const isAvailableParallelism =
19+
typeof actualOs.availableParallelism !== "undefined";
20+
21+
const mocked = {
22+
availableParallelism: isAvailableParallelism ? jest.fn(() => 4) : undefined,
23+
cpus: jest.fn(() => ({ length: 4 })),
24+
};
25+
26+
return { ...actualOs, ...mocked };
27+
});
1728

1829
// Based on https://github.com/facebook/jest/blob/edde20f75665c2b1e3c8937f758902b5cf28a7b4/packages/jest-runner/src/__tests__/test_runner.test.js
1930
let workerTransform;
@@ -69,7 +80,7 @@ describe("parallel option", () => {
6980
expect(Worker).toHaveBeenCalledTimes(1);
7081
expect(Worker).toHaveBeenLastCalledWith(workerPath, {
7182
enableWorkerThreads: ENABLE_WORKER_THREADS,
72-
numWorkers: 4, // Math.min(4 files, 7 cores) = 4
83+
numWorkers: getParallelism() - 1,
7384
});
7485
expect(workerTransform).toHaveBeenCalledTimes(
7586
Object.keys(readAssets(compiler, stats, /\.css$/)).length,

types/index.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ declare class CssMinimizerPlugin<T = CssNanoOptionsExtended> {
4545
* @param {BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>=} options Plugin options
4646
*/
4747
constructor(
48-
options?: BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>,
48+
options?:
49+
| (BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>)
50+
| undefined,
4951
);
5052
/**
5153
* @private
@@ -126,7 +128,11 @@ type Compiler = import("webpack").Compiler;
126128
type Compilation = import("webpack").Compilation;
127129
type WebpackError = import("webpack").WebpackError;
128130
type JestWorker = import("jest-worker").Worker;
129-
type RawSourceMap = import("@jridgewell/trace-mapping").EncodedSourceMap;
131+
type RawSourceMap = import("@jridgewell/trace-mapping").EncodedSourceMap & {
132+
sources: string[];
133+
sourcesContent?: string[];
134+
file: string;
135+
};
130136
type Asset = import("webpack").Asset;
131137
type ProcessOptions = import("postcss").ProcessOptions;
132138
type Syntax = import("postcss").Syntax;

0 commit comments

Comments
 (0)