Skip to content

Commit 1cab8f4

Browse files
chore: fix eslint
1 parent f1ef2ed commit 1cab8f4

File tree

162 files changed

+347
-408
lines changed

Some content is hidden

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

162 files changed

+347
-408
lines changed

.eslintignore

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
# Ignore node_modules
2-
node_modules
1+
# Ignore some test files
2+
test/**/*.*
3+
!test/*.js
4+
!test/**/webpack.config.js
5+
!test/**/test.config.js
6+
!test/**/test.filter.js
7+
test/cases/parsing/es2022/test.filter.js
8+
!test/**/errors.js
9+
!test/**/warnings.js
10+
!test/**/deprecations.js
11+
!test/helpers/*.*
312

413
# Ignore some folders
514
benchmark
615
coverage
716

17+
# Ignore generated files
18+
*.check.js
19+
820
# Ignore not supported files
9-
!.*.js
10-
.eslintrc.js
1121
*.d.ts
1222

1323
# Ignore precompiled schemas
1424
schemas/**/*.check.js
1525

16-
# Ignore some test files
17-
test/*
18-
!test/*Cases
19-
!test/helpers
20-
!test/*.js
21-
test/*Cases/**/*.js
22-
!test/*Cases/**/webpack.config.js
23-
2426
# Ignore some examples files
2527
examples/**/*.js
2628
!examples/*/webpack.config.js

.github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- Before creating an issue please make sure you are using the latest version of webpack. -->
33
<!-- Also consider trying the webpack@beta version, maybe it's already fixed. -->
44

5-
**Do you want to request a *feature* or report a *bug*?**
5+
**Do you want to request a _feature_ or report a _bug_?**
66

77
<!-- Please ask questions on StackOverflow or the webpack Gitter (https://gitter.im/webpack/webpack). -->
88
<!-- Issues which contain questions or support requests will be closed. -->

.github/ISSUE_TEMPLATE/Bug_report.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ about: Create a report to help us improve
1515

1616
**What is the current behavior?**
1717

18-
1918
**If the current behavior is a bug, please provide the steps to reproduce.**
2019

21-
2220
<!-- A great way to do this is to provide your configuration via a GitHub repository -->
2321
<!-- The most helpful is a minimal reproduction with instructions on how to reproduce -->
2422
<!-- Repositories with too many files or large `webpack.config.js` files are not suitable -->
@@ -28,12 +26,11 @@ about: Create a report to help us improve
2826

2927
**What is the expected behavior?**
3028

31-
3229
<!-- "It should work" is not a helpful explanation -->
3330
<!-- Explain exactly how it should behave -->
3431

3532
**Other relevant information:**
3633
webpack version:
37-
Node.js version:
38-
Operating System:
34+
Node.js version:
35+
Operating System:
3936
Additional tools:

.github/ISSUE_TEMPLATE/Feature_request.md

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
54
---
65

76
<!-- Please don't delete this template or we'll close your issue -->
@@ -16,12 +15,9 @@ about: Suggest an idea for this project
1615

1716
**What is the expected behavior?**
1817

19-
2018
**What is motivation or use case for adding/changing the behavior?**
2119

22-
2320
**How should this be implemented in your opinion?**
2421

25-
2622
**Are you willing to work on this yourself?**
2723
yes

.github/ISSUE_TEMPLATE/Other.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Other
33
about: Something else
4-
54
---
65

76
<!-- Bug reports and Feature requests must use other templates, or will be closed -->

.github/PULL_REQUEST_TEMPLATE.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
55
<!-- Try to link to an open issue for more information. -->
66

7-
## Summary
7+
## Summary
8+
89
<!-- cspell:disable-next-line -->
10+
911
copilot:summary
1012

11-
## Details
13+
## Details
14+
1215
<!-- cspell:disable-next-line -->
16+
1317
copilot:walkthrough

.github/PULL_REQUEST_TEMPLATE_ORIGINAL.md

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
33
<!-- Try to link to an open issue for more information. -->
44

5-
65
<!-- In addition to that please answer these questions: -->
76

87
**What kind of change does this PR introduce?**

.prettierignore

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
package.json
22

3-
# Ignore test fixtures
4-
test/*.*
3+
# Ignore some test files
4+
test/**/*.*
55
!test/*.js
66
!test/**/webpack.config.js
7+
!test/**/test.config.js
8+
!test/**/test.filter.js
9+
!test/**/errors.js
10+
!test/**/warnings.js
711
!test/**/deprecations.js
12+
!test/*.md
13+
!test/helpers/*.*
814

9-
# Ignore example fixtures
10-
examples/*.*
11-
!examples/**/webpack.config.js
15+
# Ignore some folders
16+
benchmark/
17+
coverage/
1218

1319
# Ignore generated files
1420
*.check.js
21+
22+
# Ignore not supported files
23+
*.d.ts
24+
25+
# Ignore precompiled schemas
26+
schemas/**/*.check.js
27+
28+
# Ignore example fixtures
29+
examples/
30+
!examples/**/webpack.config.js

assembly/tsconfig.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"extends": "assemblyscript/std/assembly.json",
3-
"include": [
4-
"./**/*.asm.ts"
5-
]
3+
"include": ["./**/*.asm.ts"]
64
}

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"pretest": "yarn lint",
151151
"prelint": "yarn setup",
152152
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-test && yarn module-typings-test && yarn yarn-lint && yarn pretty-lint && yarn spellcheck",
153-
"code-lint": "eslint . --ext '.js' --cache",
153+
"code-lint": "eslint --cache .",
154154
"type-lint": "tsc",
155155
"typings-test": "tsc -p tsconfig.types.test.json",
156156
"module-typings-test": "tsc -p tsconfig.module.test.json",
@@ -159,9 +159,8 @@
159159
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
160160
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
161161
"prepare": "husky install",
162-
"pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"",
163-
"pretty-lint-base-all": "yarn pretty-lint-base \"*.js\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.js\" \"module.d.ts\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases,benchmarkCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
164-
"pretty-lint-fix": "yarn pretty-lint-base-all --loglevel warn --write",
162+
"pretty-lint-base": "prettier --cache .",
163+
"pretty-lint-fix": "yarn pretty-lint-base --loglevel warn --write",
165164
"pretty-lint": "yarn pretty-lint-base --check",
166165
"yarn-lint": "yarn-deduplicate --fail --list -s highest yarn.lock",
167166
"yarn-lint-fix": "yarn-deduplicate -s highest yarn.lock",
@@ -179,11 +178,11 @@
179178
"cover:report": "nyc report -t coverage"
180179
},
181180
"lint-staged": {
182-
"*.js|{lib,setup,bin,hot,tooling,schemas}/**/*.js|test/*.js|{test,examples}/**/webpack.config.js}": [
183-
"eslint --cache"
181+
"*.{js,cjs,mjs}": [
182+
"eslint --cache --fix"
184183
],
185-
"*.{ts,json,yml,yaml,md}|examples/*.md": [
186-
"prettier --check"
184+
"*": [
185+
"prettier --cache --ignore-unknown"
187186
],
188187
"*.md|{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}": [
189188
"cspell"

test/README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
# Welcome to the webpack test suite!!!!
2+
23
Every pull request that you submit to webpack (besides README and spelling corrections in comments) requires tests that are created.
34

45
But don't give up hope!!! Although our tests may appear complex and overwhelming, once you become familiar with the test suite and structure, adding and creating tests will be fun and beneficial as you work inside the codebase! ❤
56

67
## tl;dr
8+
79
Run all tests (this automatically runs the setup):
10+
811
```sh
912
yarn test
1013
```
1114

1215
Run an individual suite:
16+
1317
```sh
1418
yarn jest ConfigTestCases
1519
```
1620

1721
Watch mode:
22+
1823
```sh
1924
yarn jest --watch ConfigTestCases
2025
```
2126

2227
See also: [Jest CLI docs](https://jestjs.io/docs/cli)
2328

2429
## Test suite overview
30+
2531
We use Jest for our tests. For more information on Jest you can visit their [homepage](https://jestjs.io/)!
2632

2733
### Class Tests
28-
All test files can be found in *.test.js. There are many tests that simply test APIs of a specific class/file (such as `Compiler`, `Errors`, Integration, `Parser`, `RuleSet`, Validation).
34+
35+
All test files can be found in \*.test.js. There are many tests that simply test APIs of a specific class/file (such as `Compiler`, `Errors`, Integration, `Parser`, `RuleSet`, Validation).
2936
If the feature you are contributing involves one of those classes, then best to start there to understand the structure.
3037

3138
### xCases
32-
In addition to Class specific tests, there are also directories that end in "Cases". The suites for these cases also have corresponding *.test.js files.
39+
40+
In addition to Class specific tests, there are also directories that end in "Cases". The suites for these cases also have corresponding \*.test.js files.
3341

3442
#### cases (`TestCases.test.js`) <sup>1</sup>
43+
3544
Cases are a set of general purpose tests that will run against a variety of permutations of webpack configurations. When you are making a general purpose change that doesn't require you to have a special configuration, you would likely add your tests here. Inside of the `./test/cases` directory you will find tests are broken into thematic sub directories. Take a moment to explore the different options.
3645

3746
To add a new case, create a new directory inside of the top level test groups, and then add an `index.js` file (and any other supporting files).
3847

3948
By default this file will be the entry point for the test suite and you can add your `it()`'s there. This will also become bundled so that node env support happens as well.
4049

4150
#### configCases (`ConfigTestCases.basictest.js`) <sup>1</sup>
51+
4252
If you are trying to solve a bug which is reproducible when x and y properties are used together in a config, then configCases is the place to be!!!!
4353

4454
In addition to an `index.js`, these configCases require a `webpack.config.js` is located inside of your test suite. This will run this specific config through `webpack` just as you were building individually. They will use the same loading/bundling technique of your `it()` tests, however you now have a more specific config use cases that you can write even before you start coding.
4555

4656
#### statsCases (`StatsTestCases.basictest.js`)
57+
4758
Stats cases are similar to configCases except specifically focusing on the `expected` output of your stats. Instead of writing to the console, however the output of stats will be written to disk.
4859

4960
By default, the "expected" outcome is a pain to write by hand so instead when statsCases are run, runner is checking output using jest's awesome snapshot functionality.
@@ -52,21 +63,23 @@ Basically you don't need to write any expected behaviors yourself. The assumptio
5263

5364
Please follow the approach described below:
5465

55-
* write your test code in `statsCases/` folder by creating a separate folder for it, for example `statsCases/some-file-import-stats/index.js`
66+
- write your test code in `statsCases/` folder by creating a separate folder for it, for example `statsCases/some-file-import-stats/index.js`
5667

5768
```javascript
5869
import("./someModule");
5970
```
60-
* don't forget the `webpack.config.js`
61-
* run the test
62-
* jest will automatically add the output from your test code to `StatsTestCases.test.js.snap` and you can always check your results there
63-
* Next time test will run -> runner will compare results against your output written to snapshot previously
71+
72+
- don't forget the `webpack.config.js`
73+
- run the test
74+
- jest will automatically add the output from your test code to `StatsTestCases.test.js.snap` and you can always check your results there
75+
- Next time test will run -> runner will compare results against your output written to snapshot previously
6476

6577
You can read more about SnapShot testing [right here](https://jestjs.io/docs/snapshot-testing)
6678

6779
## Questions? Comments?
68-
If you are still nervous or don't quite understand, please submit an issue and tag us in it, and provide a relevant PR while working on!
6980

81+
If you are still nervous or don't quite understand, please submit an issue and tag us in it, and provide a relevant PR while working on!
7082

7183
## Footnotes
84+
7285
<sup>1</sup> webpack's parser supports the use of ES2015 features like arrow functions, harmony exports, etc. However as a library we follow Node.js' timeline for dropping older versions of node. Because of this we expect your tests on GitHub Actions to pass all the way back to NodeJS v10; Therefore if you would like specific tests that use these features to be ignored if they are not supported, then you should add a `test.filter.js` file. This allows you to import the syntax needed for that test, meanwhile ignoring it on node versions (during CI) that don't support it. webpack has a variety of helpful examples you can refer to if you are just starting out. See the `./helpers` folder to find a list of the versions.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(config) {
1+
module.exports = function (config) {
22
// This test can't run in development mode as it depends on the flagIncludedChunks optimization
33
return config.mode !== "development";
44
};
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module.exports = [
2-
[/It's not allowed to load an initial chunk on demand\. The chunk name "main" is already used by an entrypoint\./],
2+
[
3+
/It's not allowed to load an initial chunk on demand\. The chunk name "main" is already used by an entrypoint\./
4+
]
35
];
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
module.exports = [
2-
[
3-
/Module build failed( \(from [^)]+\))?:\nMessage/,
4-
{details: /Stack/}
5-
]
2+
[/Module build failed( \(from [^)]+\))?:\nMessage/, { details: /Stack/ }]
63
];
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = [
2-
[/Critical dependency: Contexts can't use RegExps with the 'g' or 'y' flags/],
2+
[/Critical dependency: Contexts can't use RegExps with the 'g' or 'y' flags/]
33
];
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var fs = require("fs");
22
var path = require("path");
33

4-
module.exports = function(config) {
4+
module.exports = function (config) {
55
return fs.existsSync(path.join(__dirname, "TEST.FILTER.JS"));
66
};
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
module.exports = [
2-
[/There are multiple modules with names that only differ in casing/, /case-sensitive.A\.js/, /case-sensitive.a\.js/],
3-
[/There are multiple modules with names that only differ in casing/, /case-sensitive.B.file\.js/, /case-sensitive.b.file\.js/]
2+
[
3+
/There are multiple modules with names that only differ in casing/,
4+
/case-sensitive.A\.js/,
5+
/case-sensitive.a\.js/
6+
],
7+
[
8+
/There are multiple modules with names that only differ in casing/,
9+
/case-sensitive.B.file\.js/,
10+
/case-sensitive.b.file\.js/
11+
]
412
];
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
module.exports = [
2-
[/Module not found/],
3-
];
1+
module.exports = [[/Module not found/]];
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
module.exports = [
2-
[
3-
/Can't resolve '.\/missing'/
4-
]
5-
];
1+
module.exports = [[/Can't resolve '.\/missing'/]];
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
module.exports = [
2-
[
3-
/err: abc/,
4-
],
5-
[
6-
/The loaded module contains errors/,
7-
],
8-
];
1+
module.exports = [[/err: abc/], [/The loaded module contains errors/]];
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
module.exports = [
2-
[
3-
/abc/,
4-
/Emitted value instead of an instance of Error/,
5-
/error-loader\.js/
6-
],
7-
[
8-
/def/,
9-
/Emitted value instead of an instance of Error/,
10-
/error-loader\.js/
11-
]
2+
[/abc/, /Emitted value instead of an instance of Error/, /error-loader\.js/],
3+
[/def/, /Emitted value instead of an instance of Error/, /error-loader\.js/]
124
];
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module.exports = [
2-
[
3-
/xyz/,
4-
/Emitted value instead of an instance of Error/,
5-
/warning-loader\.js/
6-
]
2+
[/xyz/, /Emitted value instead of an instance of Error/, /warning-loader\.js/]
73
];

0 commit comments

Comments
 (0)