Skip to content

Commit 53511fe

Browse files
committed
chore: update ESlint from v8 to v9
1 parent fce38ba commit 53511fe

File tree

15 files changed

+633
-578
lines changed

15 files changed

+633
-578
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
"eslint-plugin-jest": "^29.0.1",
8383
"eslint-plugin-jsdoc": "^51.4.1",
8484
"eslint-plugin-n": "^17.21.0",
85+
"eslint-plugin-prettier": "^5.5.3",
86+
"eslint-plugin-unicorn": "^59.0.1",
8587
"file-loader": "^6.2.0",
8688
"husky": "^9.1.4",
8789
"is-gzip": "^2.0.0",

src/index.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class CopyPlugin {
177177
compilation.fileSystemInfo.createSnapshot(
178178
startTime,
179179
[dependency],
180-
// @ts-ignore
180+
// @ts-expect-error - webpack types are incomplete
181181
undefined,
182182

183183
undefined,
@@ -288,7 +288,7 @@ class CopyPlugin {
288288
let stats;
289289

290290
try {
291-
// @ts-ignore
291+
// @ts-expect-error - webpack types are incomplete
292292
stats = await stat(inputFileSystem, absoluteFrom);
293293
} catch {
294294
// Nothing
@@ -326,7 +326,7 @@ class CopyPlugin {
326326
};
327327

328328
// Will work when https://github.com/SuperchupuDev/tinyglobby/issues/81 will be resolved, so let's pass it to `tinyglobby` right now
329-
// @ts-ignore
329+
// @ts-expect-error - tinyglobby types are incomplete
330330
globOptions.fs = inputFileSystem;
331331

332332
let glob;
@@ -458,13 +458,13 @@ class CopyPlugin {
458458
: path.normalize(
459459
typeof pattern.to !== "undefined" ? pattern.to : "",
460460
);
461-
const toType = pattern.toType
462-
? pattern.toType
463-
: template.test(to)
461+
const toType =
462+
pattern.toType ||
463+
(template.test(to)
464464
? "template"
465465
: path.extname(to) === "" || to.slice(-1) === path.sep
466466
? "dir"
467-
: "file";
467+
: "file");
468468

469469
logger.log(`'to' option '${to}' determinated as '${toType}'`);
470470

@@ -550,7 +550,7 @@ class CopyPlugin {
550550
let data;
551551

552552
try {
553-
// @ts-ignore
553+
// @ts-expect-error - webpack types are incomplete
554554
data = await readFile(inputFileSystem, absoluteFilename);
555555
} catch (error) {
556556
compilation.errors.push(/** @type {WebpackError} */ (error));
@@ -856,10 +856,10 @@ class CopyPlugin {
856856
*/
857857
let filteredCopiedResult = copiedResult.filter(
858858
/**
859-
* @param {CopiedResult | undefined} result
860-
* @returns {result is CopiedResult}
859+
* @param {CopiedResult | undefined} result The result to filter
860+
* @returns {result is CopiedResult} True if the result is defined
861861
*/
862-
Boolean,
862+
(result) => result !== undefined,
863863
);
864864

865865
if (typeof normalizedPattern.transformAll !== "undefined") {
@@ -894,7 +894,7 @@ class CopyPlugin {
894894
* @param {number} i // Index of the asset in the array
895895
* @returns {Etag} // Merged Etag
896896
*/
897-
// @ts-ignore
897+
// @ts-expect-error - webpack cache types are incomplete
898898
(accumulator, asset, i) => {
899899
accumulator = cache.mergeEtags(
900900
i === 1
@@ -1005,7 +1005,7 @@ class CopyPlugin {
10051005
const sortedByIndex = [...val[1]].sort((a, b) => a[0] - b[0]);
10061006

10071007
for (const [, item] of sortedByIndex) {
1008-
acc = acc.concat(item);
1008+
acc = [...acc, ...item];
10091009
}
10101010

10111011
return acc;
@@ -1079,8 +1079,10 @@ class CopyPlugin {
10791079
.for("asset.info.copied")
10801080
.tap(PLUGIN_NAME, (copied, { green, formatFlag }) =>
10811081
copied
1082-
? /** @type {Function} */ (green)(
1083-
/** @type {Function} */ (formatFlag)("copied"),
1082+
? /** @type {(text: string) => string} */ (green)(
1083+
/** @type {(flag: string) => string} */ (formatFlag)(
1084+
"copied",
1085+
),
10841086
)
10851087
: "",
10861088
);

src/utils.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function stat(inputFileSystem, path) {
1414
* @param {null | undefined | NodeJS.ErrnoException} err // An error that occurred while trying to get the stats.
1515
* @param {undefined | Stats} stats // The stats of the file or directory, if available.
1616
*/
17-
// @ts-ignore
1817
(err, stats) => {
1918
if (err) {
2019
reject(err);
@@ -96,7 +95,7 @@ function throttleAll(limit, tasks) {
9695
const isLast = !result.includes(notSettled);
9796

9897
if (isLast) {
99-
resolve(/** @type{T[]} * */ (result));
98+
resolve(/** @type {T[]} */ (result));
10099
}
101100

102101
return;
@@ -105,24 +104,26 @@ function throttleAll(limit, tasks) {
105104
const [index, task] = value;
106105

107106
/**
108-
* @param {T} x // The result of the task that was fulfilled.
107+
* @param {T} taskResult The result of the task that was fulfilled.
109108
*/
110-
const onFulfilled = (x) => {
111-
result[index] = x;
109+
const onFulfilled = (taskResult) => {
110+
result[index] = taskResult;
112111
next();
113112
};
114113

115114
task().then(onFulfilled, reject);
116115
};
117116

118-
new Array(limit).fill(0).forEach(next);
117+
for (let i = 0; i < limit; i++) {
118+
next();
119+
}
119120
});
120121
}
121122

122123
/**
123124
* @template T
124-
* @param fn {(function(): any) | undefined} // The function to memoize.
125-
* @returns {function(): T} // A memoized function that returns the result of the original function.
125+
* @param {(() => unknown) | undefined} fn The function to memoize.
126+
* @returns {() => T} A memoized function that returns the result of the original function.
126127
*/
127128
function memoize(fn) {
128129
let cache = false;
@@ -134,7 +135,7 @@ function memoize(fn) {
134135
return result;
135136
}
136137

137-
result = /** @type {function(): any} */ (fn)();
138+
result = /** @type {T} */ (/** @type {() => unknown} */ (fn)());
138139
cache = true;
139140
// Allow to clean up memory for fn
140141
// and all dependent resources

0 commit comments

Comments
 (0)