Skip to content

chore: upgrade eslint from v8 to v9 #1134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27,496 changes: 7,544 additions & 19,952 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@types/node": "^18.15.11",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^28.1.3",
"bootstrap": "^4.6.2",
"bootstrap": "^5.3.7",
"cross-env": "^7.0.3",
"cspell": "^6.31.1",
"css-loader": "^6.10.0",
Expand All @@ -80,7 +80,7 @@
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jsdom": "^19.0.0",
"lint-staged": "^13.2.1",
"lint-staged": "^16.1.2",
"memfs": "^3.4.13",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.7",
Expand All @@ -90,7 +90,7 @@
"typescript": "^4.9.5",
"webpack": "^5.91.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.13.2"
"webpack-dev-server": "^5.2.2"
},
"keywords": [
"webpack",
Expand Down
13 changes: 8 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class MiniCssExtractPlugin {
/**
* @private
* @param {string} hashFunction
* @returns {string | Buffer}
* @returns {string}
*/
_computeHash(hashFunction) {
const hash = webpack.util.createHash(hashFunction);
Expand All @@ -306,7 +306,7 @@ class MiniCssExtractPlugin {
hash.update(this.media || "");
hash.update(this.sourceMap || "");

return hash.digest("hex");
return /** @type {string} */ (hash.digest("hex"));
}

/**
Expand All @@ -316,9 +316,12 @@ class MiniCssExtractPlugin {
updateHash(hash, context) {
super.updateHash(hash, context);

hash.update(
/** @type {NonNullable<Module["buildInfo"]>} */ (this.buildInfo).hash
);
const buildInfoHash = /** @type {NonNullable<Module["buildInfo"]>} */ (
this.buildInfo
).hash;
if (buildInfoHash) {
hash.update(buildInfoHash);
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ function pitch(request) {
(loaderContext, module) => {
if (module.request === request) {
// eslint-disable-next-line no-param-reassign
module.loaders = loaders.map((loader) => {
module.loaders = loaders.map((loaderItem) => {
return {
type: null,
loader: loader.path,
options: loader.options,
ident: loader.ident,
loader: loaderItem.path,
options: loaderItem.options,
ident: loaderItem.ident,
};
});
}
Expand Down
18 changes: 10 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,11 @@ const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
* @returns {string} common prefix
*/
const getCommonPrefix = (items) => {
let prefix = items[0];
const [firstItem, ...restItems] = items;
let prefix = firstItem;

for (let i = 1; i < items.length; i++) {
const item = items[i];
for (let i = 0; i < restItems.length; i++) {
const item = restItems[i];
for (let p = 0; p < prefix.length; p++) {
if (item[p] !== prefix[p]) {
prefix = prefix.slice(0, p);
Expand All @@ -256,10 +257,11 @@ const getCommonPrefix = (items) => {
* @returns {string} common suffix
*/
const getCommonSuffix = (items) => {
let suffix = items[0];
const [firstItem, ...restItems] = items;
let suffix = firstItem;

for (let i = 1; i < items.length; i++) {
const item = items[i];
for (let i = 0; i < restItems.length; i++) {
const item = restItems[i];
for (let p = item.length - 1, s = suffix.length - 1; s >= 0; p--, s--) {
if (item[p] !== suffix[s]) {
suffix = suffix.slice(s + 1);
Expand All @@ -285,7 +287,7 @@ const popCommonItems = (itemsSet, getKey, condition) => {
const key = getKey(item);
if (key) {
let list = map.get(key);
if (list === undefined) {
if (!list) {
/** @type {Array<string>} */
list = [];
map.set(key, list);
Expand Down Expand Up @@ -358,7 +360,7 @@ const itemsToRegexp = (itemsArr) => {

if (prefix.length > 0 || suffix.length > 0) {
return `${quoteMeta(prefix)}${itemsToRegexp(
itemsArr.map((i) => i.slice(prefix.length, -suffix.length || undefined))
itemsArr.map((i) => i.slice(prefix.length, -suffix.length || 0))
)}${quoteMeta(suffix)}`;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/cases/new-url/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Test URL creation
const myURL = new URL("./style.css", import.meta.url);

console.log(myURL);
export default myURL;
4 changes: 1 addition & 3 deletions test/manual/src/worker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import "./worker.css";

// eslint-disable-next-line no-undef
self.onmessage = (event) => {
console.log(`Received message from application: ${event.data}`);

self.onmessage = () => {
// eslint-disable-next-line no-undef
self.postMessage("I'm alive!");
};
Expand Down
5 changes: 0 additions & 5 deletions test/manual/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ const ENABLE_ES_MODULE =
const OLD_API =
typeof process.env.OLD_API !== "undefined" ? yn(process.env.OLD_API) : false;

console.log("OPTIONS:");
console.log("ENABLE_HMR:", ENABLE_HMR);
console.log("ENABLE_ES_MODULE:", ENABLE_ES_MODULE);
console.log("OLD_API:", OLD_API);

module.exports = {
devtool: false,
mode: "development",
Expand Down
Loading