Skip to content

refactor: update eslint config #457

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

Merged
merged 3 commits into from
Aug 5, 2025
Merged
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
4 changes: 0 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ import config from "eslint-config-webpack";
export default defineConfig([
{
extends: [config],
rules: {
"n/prefer-global/process": "off",
"n/prefer-node-protocol": "off",
},
},
]);
1 change: 1 addition & 0 deletions lib/CachedInputFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

"use strict";

// eslint-disable-next-line n/prefer-global/process
const { nextTick } = require("process");

/** @typedef {import("./Resolver").FileSystem} FileSystem */
Expand Down
4 changes: 2 additions & 2 deletions lib/DescriptionFileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ function getField(content, field) {
return content[field];
}

module.exports.loadDescriptionFile = loadDescriptionFile;
module.exports.getField = getField;
module.exports.cdUp = cdUp;
module.exports.getField = getField;
module.exports.loadDescriptionFile = loadDescriptionFile;
2 changes: 1 addition & 1 deletion lib/ExportsFieldPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const forEachBail = require("./forEachBail");
const { processExportsField } = require("./util/entrypoints");
const { parseIdentifier } = require("./util/identifier");
const {
invalidSegmentRegEx,
deprecatedInvalidSegmentRegEx,
invalidSegmentRegEx,
} = require("./util/path");

/** @typedef {import("./Resolver")} Resolver */
Expand Down
2 changes: 1 addition & 1 deletion lib/ImportsFieldPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const forEachBail = require("./forEachBail");
const { processImportsField } = require("./util/entrypoints");
const { parseIdentifier } = require("./util/identifier");
const {
invalidSegmentRegEx,
deprecatedInvalidSegmentRegEx,
invalidSegmentRegEx,
} = require("./util/path");

/** @typedef {import("./Resolver")} Resolver */
Expand Down
6 changes: 2 additions & 4 deletions lib/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } = require("tapable");
const createInnerContext = require("./createInnerContext");
const { parseIdentifier } = require("./util/identifier");
const {
normalize,
PathType,
cachedJoin: join,
getType,
PathType,
normalize,
} = require("./util/path");

/** @typedef {import("./ResolverFactory").ResolveOptions} ResolveOptions */
Expand Down Expand Up @@ -99,7 +99,6 @@ const {
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats
*/

/* eslint-disable jsdoc/require-template */
/**
* @template {string | Buffer} [T=string]
* @typedef {object} Dirent
Expand All @@ -114,7 +113,6 @@ const {
* @property {string} parentPath path
* @property {string=} path path
*/
/* eslint-enable jsdoc/require-template */

/**
* @typedef {object} StatOptions
Expand Down
8 changes: 4 additions & 4 deletions lib/ResolverFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

"use strict";

// eslint-disable-next-line n/prefer-global/process
const { versions } = require("process");
const Resolver = require("./Resolver");
const { getType, PathType } = require("./util/path");

const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");

const AliasFieldPlugin = require("./AliasFieldPlugin");
const AliasPlugin = require("./AliasPlugin");
Expand All @@ -29,14 +26,17 @@ const ModulesInRootPlugin = require("./ModulesInRootPlugin");
const NextPlugin = require("./NextPlugin");
const ParsePlugin = require("./ParsePlugin");
const PnpPlugin = require("./PnpPlugin");
const Resolver = require("./Resolver");
const RestrictionsPlugin = require("./RestrictionsPlugin");
const ResultPlugin = require("./ResultPlugin");
const RootsPlugin = require("./RootsPlugin");
const SelfReferencePlugin = require("./SelfReferencePlugin");
const SymlinkPlugin = require("./SymlinkPlugin");
const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
const TryNextPlugin = require("./TryNextPlugin");
const UnsafeCachePlugin = require("./UnsafeCachePlugin");
const UseFilePlugin = require("./UseFilePlugin");
const { PathType, getType } = require("./util/path");

/** @typedef {import("./AliasPlugin").AliasOption} AliasOptionEntry */
/** @typedef {import("./ExtensionAliasPlugin").ExtensionAliasOption} ExtensionAliasOption */
Expand Down
2 changes: 1 addition & 1 deletion lib/SymlinkPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const forEachBail = require("./forEachBail");
const getPaths = require("./getPaths");
const { getType, PathType } = require("./util/path");
const { PathType, getType } = require("./util/path");

/** @typedef {import("./Resolver")} Resolver */
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
Expand Down
22 changes: 8 additions & 14 deletions lib/util/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@ const PathType = Object.freeze({
Internal: 5,
});

module.exports.PathType = PathType;

const invalidSegmentRegEx =
/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;

module.exports.invalidSegmentRegEx = invalidSegmentRegEx;

const deprecatedInvalidSegmentRegEx =
/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;

module.exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
const invalidSegmentRegEx =
/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;

/**
* @param {string} maybePath a path
Expand Down Expand Up @@ -126,8 +120,6 @@ const getType = (maybePath) => {
return PathType.Normal;
};

module.exports.getType = getType;

/**
* @param {string} maybePath a path
* @returns {string} the normalized path
Expand All @@ -146,8 +138,6 @@ const normalize = (maybePath) => {
return posixNormalize(maybePath);
};

module.exports.normalize = normalize;

/**
* @param {string} rootPath the root path
* @param {string | undefined} request the request path
Expand Down Expand Up @@ -181,8 +171,6 @@ const join = (rootPath, request) => {
return posixNormalize(rootPath);
};

module.exports.join = join;

/** @type {Map<string, Map<string, string | undefined>>} */
const joinCache = new Map();

Expand All @@ -206,4 +194,10 @@ const cachedJoin = (rootPath, request) => {
return cacheEntry;
};

module.exports.PathType = PathType;
module.exports.cachedJoin = cachedJoin;
module.exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
module.exports.getType = getType;
module.exports.invalidSegmentRegEx = invalidSegmentRegEx;
module.exports.join = join;
module.exports.normalize = normalize;
94 changes: 47 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,76 @@
{
"name": "enhanced-resolve",
"version": "5.18.2",
"author": "Tobias Koppers @sokra",
"description": "Offers a async require.resolve function. It's highly configurable.",
"homepage": "http://github.com/webpack/enhanced-resolve",
"repository": {
"type": "git",
"url": "git://github.com/webpack/enhanced-resolve.git"
},
"license": "MIT",
"author": "Tobias Koppers @sokra",
"main": "lib/index.js",
"browser": {
"process": "./lib/util/process-browser.js",
"module": "./lib/util/module-browser.js"
},
"types": "types.d.ts",
"files": [
"lib",
"types.d.ts",
"LICENSE"
],
"browser": {
"process": "./lib/util/process-browser.js",
"module": "./lib/util/module-browser.js"
"scripts": {
"prepare": "husky install",
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck",
"lint:code": "eslint --cache .",
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/generate-types",
"lint:types": "tsc",
"lint:types-test": "tsc -p tsconfig.types.test.json",
"lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"",
"fmt": "yarn fmt:base --loglevel warn --write",
"fmt:check": "yarn fmt:base --check",
"fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
"fix": "yarn fix:code && yarn fix:special",
"fix:code": "yarn lint:code --fix",
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/generate-types --write",
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
"pretest": "yarn lint",
"test": "yarn test:coverage",
"test:only": "jest",
"test:watch": "yarn test:only --watch",
"test:coverage": "yarn test:only --collectCoverageFrom=\"lib/**/*.js\" --coverage"
},
"lint-staged": {
"*.{js,cjs,mjs}": [
"eslint --cache --fix"
],
"*": [
"prettier --cache --write --ignore-unknown",
"cspell --cache --no-must-find-files"
]
},
"dependencies": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
},
"license": "MIT",
"devDependencies": {
"@eslint/js": ">= 9.28.0",
"@eslint/markdown": ">= 6.5.0",
"@eslint/js": "^9.28.0",
"@eslint/markdown": "^7.1.0",
"@types/graceful-fs": "^4.1.6",
"@types/jest": "^27.5.1",
"@types/node": "^24.0.3",
"@stylistic/eslint-plugin": ">= 4.4.1",
"@stylistic/eslint-plugin": "^5.2.2",
"cspell": "4.2.8",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-config-webpack": "^4.1.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^51.2.2",
"eslint-plugin-jsdoc": "^52.0.2",
"eslint-plugin-n": "^17.19.0",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-unicorn": "^59.0.1",
"eslint-plugin-unicorn": "^60.0.0",
"globals": "^16.2.0",
"husky": "^6.0.0",
"jest": "^27.5.1",
Expand All @@ -46,42 +83,5 @@
},
"engines": {
"node": ">=10.13.0"
},
"main": "lib/index.js",
"types": "types.d.ts",
"homepage": "http://github.com/webpack/enhanced-resolve",
"scripts": {
"prepare": "husky install",
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck",
"lint:code": "eslint --cache .",
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types",
"lint:types": "tsc",
"lint:types-test": "tsc -p tsconfig.types.test.json",
"lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"",
"fmt": "yarn fmt:base --loglevel warn --write",
"fmt:check": "yarn fmt:base --check",
"fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
"fix": "yarn fix:code && yarn fix:special",
"fix:code": "yarn lint:code --fix",
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write",
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
"pretest": "yarn lint",
"test": "yarn test:coverage",
"test:only": "jest",
"test:watch": "yarn test:only --watch",
"test:coverage": "yarn test:only --collectCoverageFrom=\"lib/**/*.js\" --coverage"
},
"lint-staged": {
"*.{js,cjs,mjs}": [
"eslint --cache --fix"
],
"*": [
"prettier --cache --write --ignore-unknown",
"cspell --cache --no-must-find-files"
]
},
"repository": {
"type": "git",
"url": "git://github.com/webpack/enhanced-resolve.git"
}
}
2 changes: 1 addition & 1 deletion test/CachedInputFileSystem.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";

const { CachedInputFileSystem } = require("../");
const path = require("path");
const url = require("url");
const { CachedInputFileSystem } = require("../");

describe("cachedInputFileSystem OperationMergerBackend ('stat' and 'statSync')", () => {
let fs;
Expand Down
2 changes: 1 addition & 1 deletion test/alias.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const fs = require("fs");
const path = require("path");
const { Volume } = require("memfs");
const { ResolverFactory } = require("../");
const CachedInputFileSystem = require("../lib/CachedInputFileSystem");
const fs = require("fs");

const nodeFileSystem = new CachedInputFileSystem(fs, 4000);

Expand Down
2 changes: 1 addition & 1 deletion test/browserField.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const fs = require("fs");
const path = require("path");
const { ResolverFactory } = require("../");

const browserModule = path.join(__dirname, "fixtures", "browser-module");
Expand Down
6 changes: 3 additions & 3 deletions test/exportsField.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const path = require("path");
const fs = require("fs");
const { processExportsField } = require("../lib/util/entrypoints");
const ResolverFactory = require("../lib/ResolverFactory");
const path = require("path");
const CachedInputFileSystem = require("../lib/CachedInputFileSystem");
const ResolverFactory = require("../lib/ResolverFactory");
const { processExportsField } = require("../lib/util/entrypoints");

/** @typedef {import("../lib/util/entrypoints").ExportsField} ExportsField */

Expand Down
2 changes: 1 addition & 1 deletion test/extension-alias.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const fs = require("fs");
const path = require("path");

const CachedInputFileSystem = require("../lib/CachedInputFileSystem");
const ResolverFactory = require("../lib/ResolverFactory");
Expand Down
4 changes: 2 additions & 2 deletions test/extensions.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";

const path = require("path");
const fs = require("fs");
const { ResolverFactory, CachedInputFileSystem } = require("../");
const path = require("path");
const { CachedInputFileSystem, ResolverFactory } = require("../");

const nodeFileSystem = new CachedInputFileSystem(fs, 4000);

Expand Down
6 changes: 3 additions & 3 deletions test/importsField.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const path = require("path");
const fs = require("fs");
const { processImportsField } = require("../lib/util/entrypoints");
const ResolverFactory = require("../lib/ResolverFactory");
const path = require("path");
const CachedInputFileSystem = require("../lib/CachedInputFileSystem");
const ResolverFactory = require("../lib/ResolverFactory");
const { processImportsField } = require("../lib/util/entrypoints");

/** @typedef {import("../lib/util/entrypoints").ImportsField} ImportsField */

Expand Down
2 changes: 1 addition & 1 deletion test/incorrect-description-file.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const fs = require("fs");
const path = require("path");
const { CachedInputFileSystem, ResolverFactory } = require("../");

const fixtures = path.join(__dirname, "fixtures", "incorrect-package");
Expand Down
Loading
Loading