Commit 625758a
feat(linter/vitest): Implement padding-around-after-all-blocks rule (#21788)
Related to: #4656
## Summary
Implements the `vitest/padding-around-after-all-blocks` linter rule,
which enforces a blank line of padding before `afterAll` blocks in test
files. Ports the rule from
[eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest).
## AI disclosure
I used Claude Code to help me with onboarding, since I am unfamiliar
with the code. It explained to me how certain things like
`run_on_jest_node`, `report_missing_padding_before_jest_block`, and
other things work under the hood. I also used it to help me with
generating additional test cases for this rule.
And it also generated this PR description for me as well, based on the
file changes.
## Description
This rule helps keep test files readable by visually separating
`afterAll` hooks from surrounding code.
**Incorrect:**
```js
const thing = 123;
afterAll(() => {});
```
**Correct:**
```js
const thing = 123;
afterAll(() => {});
```
The rule:
- Category: `style`
- Plugin: `vitest`
- Auto-fixable: yes (inserts the missing blank line)
- Runs on Jest/Vitest nodes via `run_on_jest_node`, filters to `Hook`
kind calls named `afterAll`, and delegates reporting to the shared
`report_missing_padding_before_jest_block` helper.
---------
Co-authored-by: Kapobajza <kapobajza@gmail.com>1 parent 64a7c11 commit 625758a
11 files changed
Lines changed: 294 additions & 50 deletions
File tree
- apps/oxlint/src-js/package
- crates/oxc_linter/src
- generated
- rules
- jest
- vitest
- snapshots
- npm/oxlint
- tasks/website_linter/src/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1241 | 1241 | | |
1242 | 1242 | | |
1243 | 1243 | | |
| 1244 | + | |
1244 | 1245 | | |
1245 | 1246 | | |
1246 | 1247 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
771 | 772 | | |
772 | 773 | | |
773 | 774 | | |
| |||
Lines changed: 4 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 14 | | |
44 | 15 | | |
45 | 16 | | |
46 | 17 | | |
| 18 | + | |
47 | 19 | | |
48 | 20 | | |
49 | 21 | | |
| |||
53 | 25 | | |
54 | 26 | | |
55 | 27 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 28 | + | |
74 | 29 | | |
75 | 30 | | |
76 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments