Skip to content

Commit 5f74295

Browse files
refactor: update eslint config (#457)
1 parent 86ff212 commit 5f74295

26 files changed

+433
-389
lines changed

eslint.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@ import config from "eslint-config-webpack";
44
export default defineConfig([
55
{
66
extends: [config],
7-
rules: {
8-
"n/prefer-global/process": "off",
9-
"n/prefer-node-protocol": "off",
10-
},
117
},
128
]);

lib/CachedInputFileSystem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
"use strict";
77

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

1011
/** @typedef {import("./Resolver").FileSystem} FileSystem */

lib/DescriptionFileUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,6 @@ function getField(content, field) {
195195
return content[field];
196196
}
197197

198-
module.exports.loadDescriptionFile = loadDescriptionFile;
199-
module.exports.getField = getField;
200198
module.exports.cdUp = cdUp;
199+
module.exports.getField = getField;
200+
module.exports.loadDescriptionFile = loadDescriptionFile;

lib/ExportsFieldPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const forEachBail = require("./forEachBail");
1010
const { processExportsField } = require("./util/entrypoints");
1111
const { parseIdentifier } = require("./util/identifier");
1212
const {
13-
invalidSegmentRegEx,
1413
deprecatedInvalidSegmentRegEx,
14+
invalidSegmentRegEx,
1515
} = require("./util/path");
1616

1717
/** @typedef {import("./Resolver")} Resolver */

lib/ImportsFieldPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const forEachBail = require("./forEachBail");
1010
const { processImportsField } = require("./util/entrypoints");
1111
const { parseIdentifier } = require("./util/identifier");
1212
const {
13-
invalidSegmentRegEx,
1413
deprecatedInvalidSegmentRegEx,
14+
invalidSegmentRegEx,
1515
} = require("./util/path");
1616

1717
/** @typedef {import("./Resolver")} Resolver */

lib/Resolver.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } = require("tapable");
99
const createInnerContext = require("./createInnerContext");
1010
const { parseIdentifier } = require("./util/identifier");
1111
const {
12-
normalize,
12+
PathType,
1313
cachedJoin: join,
1414
getType,
15-
PathType,
15+
normalize,
1616
} = require("./util/path");
1717

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

102-
/* eslint-disable jsdoc/require-template */
103102
/**
104103
* @template {string | Buffer} [T=string]
105104
* @typedef {object} Dirent
@@ -114,7 +113,6 @@ const {
114113
* @property {string} parentPath path
115114
* @property {string=} path path
116115
*/
117-
/* eslint-enable jsdoc/require-template */
118116

119117
/**
120118
* @typedef {object} StatOptions

lib/ResolverFactory.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55

66
"use strict";
77

8+
// eslint-disable-next-line n/prefer-global/process
89
const { versions } = require("process");
9-
const Resolver = require("./Resolver");
10-
const { getType, PathType } = require("./util/path");
11-
12-
const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
1310

1411
const AliasFieldPlugin = require("./AliasFieldPlugin");
1512
const AliasPlugin = require("./AliasPlugin");
@@ -29,14 +26,17 @@ const ModulesInRootPlugin = require("./ModulesInRootPlugin");
2926
const NextPlugin = require("./NextPlugin");
3027
const ParsePlugin = require("./ParsePlugin");
3128
const PnpPlugin = require("./PnpPlugin");
29+
const Resolver = require("./Resolver");
3230
const RestrictionsPlugin = require("./RestrictionsPlugin");
3331
const ResultPlugin = require("./ResultPlugin");
3432
const RootsPlugin = require("./RootsPlugin");
3533
const SelfReferencePlugin = require("./SelfReferencePlugin");
3634
const SymlinkPlugin = require("./SymlinkPlugin");
35+
const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
3736
const TryNextPlugin = require("./TryNextPlugin");
3837
const UnsafeCachePlugin = require("./UnsafeCachePlugin");
3938
const UseFilePlugin = require("./UseFilePlugin");
39+
const { PathType, getType } = require("./util/path");
4040

4141
/** @typedef {import("./AliasPlugin").AliasOption} AliasOptionEntry */
4242
/** @typedef {import("./ExtensionAliasPlugin").ExtensionAliasOption} ExtensionAliasOption */

lib/SymlinkPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
const forEachBail = require("./forEachBail");
99
const getPaths = require("./getPaths");
10-
const { getType, PathType } = require("./util/path");
10+
const { PathType, getType } = require("./util/path");
1111

1212
/** @typedef {import("./Resolver")} Resolver */
1313
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */

lib/util/path.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@ const PathType = Object.freeze({
3232
Internal: 5,
3333
});
3434

35-
module.exports.PathType = PathType;
36-
37-
const invalidSegmentRegEx =
38-
/(^|\\|\/)((\.|%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;
39-
40-
module.exports.invalidSegmentRegEx = invalidSegmentRegEx;
41-
4235
const deprecatedInvalidSegmentRegEx =
4336
/(^|\\|\/)((\.|%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;
4437

45-
module.exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
38+
const invalidSegmentRegEx =
39+
/(^|\\|\/)((\.|%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;
4640

4741
/**
4842
* @param {string} maybePath a path
@@ -126,8 +120,6 @@ const getType = (maybePath) => {
126120
return PathType.Normal;
127121
};
128122

129-
module.exports.getType = getType;
130-
131123
/**
132124
* @param {string} maybePath a path
133125
* @returns {string} the normalized path
@@ -146,8 +138,6 @@ const normalize = (maybePath) => {
146138
return posixNormalize(maybePath);
147139
};
148140

149-
module.exports.normalize = normalize;
150-
151141
/**
152142
* @param {string} rootPath the root path
153143
* @param {string | undefined} request the request path
@@ -181,8 +171,6 @@ const join = (rootPath, request) => {
181171
return posixNormalize(rootPath);
182172
};
183173

184-
module.exports.join = join;
185-
186174
/** @type {Map<string, Map<string, string | undefined>>} */
187175
const joinCache = new Map();
188176

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

197+
module.exports.PathType = PathType;
209198
module.exports.cachedJoin = cachedJoin;
199+
module.exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
200+
module.exports.getType = getType;
201+
module.exports.invalidSegmentRegEx = invalidSegmentRegEx;
202+
module.exports.join = join;
203+
module.exports.normalize = normalize;

package.json

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,76 @@
11
{
22
"name": "enhanced-resolve",
33
"version": "5.18.2",
4-
"author": "Tobias Koppers @sokra",
54
"description": "Offers a async require.resolve function. It's highly configurable.",
5+
"homepage": "http://github.com/webpack/enhanced-resolve",
6+
"repository": {
7+
"type": "git",
8+
"url": "git://github.com/webpack/enhanced-resolve.git"
9+
},
10+
"license": "MIT",
11+
"author": "Tobias Koppers @sokra",
12+
"main": "lib/index.js",
13+
"browser": {
14+
"process": "./lib/util/process-browser.js",
15+
"module": "./lib/util/module-browser.js"
16+
},
17+
"types": "types.d.ts",
618
"files": [
719
"lib",
820
"types.d.ts",
921
"LICENSE"
1022
],
11-
"browser": {
12-
"process": "./lib/util/process-browser.js",
13-
"module": "./lib/util/module-browser.js"
23+
"scripts": {
24+
"prepare": "husky install",
25+
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck",
26+
"lint:code": "eslint --cache .",
27+
"lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/generate-types",
28+
"lint:types": "tsc",
29+
"lint:types-test": "tsc -p tsconfig.types.test.json",
30+
"lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"",
31+
"fmt": "yarn fmt:base --loglevel warn --write",
32+
"fmt:check": "yarn fmt:base --check",
33+
"fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
34+
"fix": "yarn fix:code && yarn fix:special",
35+
"fix:code": "yarn lint:code --fix",
36+
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/generate-types --write",
37+
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
38+
"pretest": "yarn lint",
39+
"test": "yarn test:coverage",
40+
"test:only": "jest",
41+
"test:watch": "yarn test:only --watch",
42+
"test:coverage": "yarn test:only --collectCoverageFrom=\"lib/**/*.js\" --coverage"
43+
},
44+
"lint-staged": {
45+
"*.{js,cjs,mjs}": [
46+
"eslint --cache --fix"
47+
],
48+
"*": [
49+
"prettier --cache --write --ignore-unknown",
50+
"cspell --cache --no-must-find-files"
51+
]
1452
},
1553
"dependencies": {
1654
"graceful-fs": "^4.2.4",
1755
"tapable": "^2.2.0"
1856
},
19-
"license": "MIT",
2057
"devDependencies": {
21-
"@eslint/js": ">= 9.28.0",
22-
"@eslint/markdown": ">= 6.5.0",
58+
"@eslint/js": "^9.28.0",
59+
"@eslint/markdown": "^7.1.0",
2360
"@types/graceful-fs": "^4.1.6",
2461
"@types/jest": "^27.5.1",
2562
"@types/node": "^24.0.3",
26-
"@stylistic/eslint-plugin": ">= 4.4.1",
63+
"@stylistic/eslint-plugin": "^5.2.2",
2764
"cspell": "4.2.8",
2865
"eslint": "^9.28.0",
2966
"eslint-config-prettier": "^10.1.5",
3067
"eslint-config-webpack": "^4.1.2",
3168
"eslint-plugin-import": "^2.31.0",
3269
"eslint-plugin-jest": "^29.0.1",
33-
"eslint-plugin-jsdoc": "^51.2.2",
70+
"eslint-plugin-jsdoc": "^52.0.2",
3471
"eslint-plugin-n": "^17.19.0",
3572
"eslint-plugin-prettier": "^5.4.1",
36-
"eslint-plugin-unicorn": "^59.0.1",
73+
"eslint-plugin-unicorn": "^60.0.0",
3774
"globals": "^16.2.0",
3875
"husky": "^6.0.0",
3976
"jest": "^27.5.1",
@@ -46,42 +83,5 @@
4683
},
4784
"engines": {
4885
"node": ">=10.13.0"
49-
},
50-
"main": "lib/index.js",
51-
"types": "types.d.ts",
52-
"homepage": "http://github.com/webpack/enhanced-resolve",
53-
"scripts": {
54-
"prepare": "husky install",
55-
"lint": "yarn lint:code && yarn lint:types && yarn lint:types-test && yarn lint:special && yarn fmt:check && yarn lint:spellcheck",
56-
"lint:code": "eslint --cache .",
57-
"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",
58-
"lint:types": "tsc",
59-
"lint:types-test": "tsc -p tsconfig.types.test.json",
60-
"lint:spellcheck": "cspell --no-must-find-files \"**/*.*\"",
61-
"fmt": "yarn fmt:base --loglevel warn --write",
62-
"fmt:check": "yarn fmt:base --check",
63-
"fmt:base": "node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
64-
"fix": "yarn fix:code && yarn fix:special",
65-
"fix:code": "yarn lint:code --fix",
66-
"fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write",
67-
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
68-
"pretest": "yarn lint",
69-
"test": "yarn test:coverage",
70-
"test:only": "jest",
71-
"test:watch": "yarn test:only --watch",
72-
"test:coverage": "yarn test:only --collectCoverageFrom=\"lib/**/*.js\" --coverage"
73-
},
74-
"lint-staged": {
75-
"*.{js,cjs,mjs}": [
76-
"eslint --cache --fix"
77-
],
78-
"*": [
79-
"prettier --cache --write --ignore-unknown",
80-
"cspell --cache --no-must-find-files"
81-
]
82-
},
83-
"repository": {
84-
"type": "git",
85-
"url": "git://github.com/webpack/enhanced-resolve.git"
8686
}
8787
}

0 commit comments

Comments
 (0)