Skip to content

Commit 775f2fb

Browse files
chore: migrate to eslint-config-webpack (#453)
There is only one things that we be potential broken - using directly in browser without es6 support, but today is 2025 year and time to drop such browsers and we have: ``` "engines": { "node": ">=10.13.0" }, ``` it means any features which supported in `10.13.0` can be used in our code and so if you want to support only `es3`/`es5` env you need to transpile
1 parent 6df312e commit 775f2fb

File tree

83 files changed

+6358
-3806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6358
-3806
lines changed

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"anotherhashishere",
88
"arcanis",
99
"Builtins",
10+
"camelcase",
1011
"complexm",
1112
"endregion",
1213
"entrypoints",

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: |
5151
yarn upgrade typescript@^4 --ignore-engines
5252
yarn --frozen-lockfile
53-
if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
53+
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x'
5454
- name: Install dependencies
5555
run: yarn --frozen-lockfile
5656
if: matrix.node-version != '10.x'

.prettierrc.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1+
"use strict";
2+
13
module.exports = {
24
printWidth: 80,
35
useTabs: true,
46
tabWidth: 2,
5-
trailingComma: "none",
7+
trailingComma: "all",
8+
arrowParens: "always",
69
overrides: [
710
{
811
files: "*.json",
912
options: {
1013
parser: "json",
11-
useTabs: false
12-
}
14+
useTabs: false,
15+
},
1316
},
1417
{
1518
files: "*.{cts,mts,ts}",
1619
options: {
17-
parser: "typescript"
18-
}
19-
}
20-
]
20+
parser: "typescript",
21+
},
22+
},
23+
],
2124
};

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ myResolver.resolve(
7777
lookupStartPath,
7878
request,
7979
resolveContext,
80-
(err /*Error*/, filepath /*string*/) => {
80+
(err /* Error */, filepath /* string */) => {
8181
// Do something with the path
8282
}
8383
);
@@ -151,7 +151,7 @@ enhanced-resolve will try to resolve requests containing `#` as path and as frag
151151

152152
## Tests
153153

154-
```javascript
154+
```sh
155155
yarn test
156156
```
157157

eslint.config.mjs

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

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"use strict";
2+
13
module.exports = {
2-
moduleFileExtensions: ["js", "mjs", "cjs", "ts"]
4+
prettierPath: require.resolve("prettier-2"),
5+
moduleFileExtensions: ["js", "mjs", "cjs", "ts"],
36
};

lib/AliasFieldPlugin.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,38 @@ module.exports = class AliasFieldPlugin {
3939
if (!innerRequest) return callback();
4040
const fieldData = DescriptionFileUtils.getField(
4141
request.descriptionFileData,
42-
this.field
42+
this.field,
4343
);
4444
if (fieldData === null || typeof fieldData !== "object") {
45-
if (resolveContext.log)
45+
if (resolveContext.log) {
4646
resolveContext.log(
47-
"Field '" +
48-
this.field +
49-
"' doesn't contain a valid alias configuration"
47+
`Field '${
48+
this.field
49+
}' doesn't contain a valid alias configuration`,
5050
);
51+
}
5152
return callback();
5253
}
5354
/** @type {JsonPrimitive | undefined} */
5455
const data = Object.prototype.hasOwnProperty.call(
5556
fieldData,
56-
innerRequest
57+
innerRequest,
5758
)
5859
? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[
5960
innerRequest
60-
]
61+
]
6162
: innerRequest.startsWith("./")
62-
? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[
63-
innerRequest.slice(2)
64-
]
65-
: undefined;
63+
? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[
64+
innerRequest.slice(2)
65+
]
66+
: undefined;
6667
if (data === innerRequest) return callback();
6768
if (data === undefined) return callback();
6869
if (data === false) {
6970
/** @type {ResolveRequest} */
7071
const ignoreObj = {
7172
...request,
72-
path: false
73+
path: false,
7374
};
7475
if (typeof resolveContext.yield === "function") {
7576
resolveContext.yield(ignoreObj);
@@ -82,26 +83,22 @@ module.exports = class AliasFieldPlugin {
8283
...request,
8384
path: /** @type {string} */ (request.descriptionFileRoot),
8485
request: /** @type {string} */ (data),
85-
fullySpecified: false
86+
fullySpecified: false,
8687
};
8788
resolver.doResolve(
8889
target,
8990
obj,
90-
"aliased from description file " +
91-
request.descriptionFilePath +
92-
" with mapping '" +
93-
innerRequest +
94-
"' to '" +
95-
/** @type {string} */ (data) +
96-
"'",
91+
`aliased from description file ${
92+
request.descriptionFilePath
93+
} with mapping '${innerRequest}' to '${/** @type {string} */ data}'`,
9794
resolveContext,
9895
(err, result) => {
9996
if (err) return callback(err);
10097

10198
// Don't allow other aliasing or raw request
10299
if (result === undefined) return callback(null, null);
103100
callback(null, result);
104-
}
101+
},
105102
);
106103
});
107104
}

lib/AliasPlugin.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = class AliasPlugin {
8686
/** @type {ResolveRequest} */
8787
const ignoreObj = {
8888
...request,
89-
path: false
89+
path: false,
9090
};
9191
if (typeof resolveContext.yield === "function") {
9292
resolveContext.yield(ignoreObj);
@@ -105,15 +105,15 @@ module.exports = class AliasPlugin {
105105
) {
106106
const match = innerRequest.slice(
107107
prefix.length,
108-
innerRequest.length - suffix.length
108+
innerRequest.length - suffix.length,
109109
);
110110
newRequestStr = item.alias.toString().replace("*", match);
111111
}
112112

113113
if (
114114
matchRequest &&
115115
innerRequest !== alias &&
116-
!innerRequest.startsWith(alias + "/")
116+
!innerRequest.startsWith(`${alias}/`)
117117
) {
118118
/** @type {string} */
119119
const remainingRequest = innerRequest.slice(item.name.length);
@@ -126,32 +126,28 @@ module.exports = class AliasPlugin {
126126
const obj = {
127127
...request,
128128
request: newRequestStr,
129-
fullySpecified: false
129+
fullySpecified: false,
130130
};
131131
return resolver.doResolve(
132132
target,
133133
obj,
134-
"aliased with mapping '" +
135-
item.name +
136-
"': '" +
137-
alias +
138-
"' to '" +
139-
newRequestStr +
140-
"'",
134+
`aliased with mapping '${item.name}': '${alias}' to '${
135+
newRequestStr
136+
}'`,
141137
resolveContext,
142138
(err, result) => {
143139
if (err) return callback(err);
144140
if (result) return callback(null, result);
145141
return callback();
146-
}
142+
},
147143
);
148144
}
149145
return callback();
150146
};
151147

152148
/**
153-
* @param {null|Error} [err] error
154-
* @param {null|ResolveRequest} [result] result
149+
* @param {(null | Error)=} err error
150+
* @param {(null | ResolveRequest)=} result result
155151
* @returns {void}
156152
*/
157153
const stoppingCallback = (err, result) => {
@@ -167,16 +163,15 @@ module.exports = class AliasPlugin {
167163
return forEachBail(
168164
item.alias,
169165
resolveWithAlias,
170-
stoppingCallback
166+
stoppingCallback,
171167
);
172-
} else {
173-
return resolveWithAlias(item.alias, stoppingCallback);
174168
}
169+
return resolveWithAlias(item.alias, stoppingCallback);
175170
}
176171

177172
return callback();
178173
},
179-
callback
174+
callback,
180175
);
181176
});
182177
}

lib/AppendPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ module.exports = class AppendPlugin {
3535
...request,
3636
path: request.path + this.appending,
3737
relativePath:
38-
request.relativePath && request.relativePath + this.appending
38+
request.relativePath && request.relativePath + this.appending,
3939
};
4040
resolver.doResolve(
4141
target,
4242
obj,
4343
this.appending,
4444
resolveContext,
45-
callback
45+
callback,
4646
);
4747
});
4848
}

0 commit comments

Comments
 (0)