Skip to content

Commit 5dc4548

Browse files
authored
docs: add documentation for padding-around-related rules (#623)
* docs: add padding-around-after-each-blocks docs * docs: add padding-around-before-all-blocks docs * docs: add padding-around-before-each-blocks docs * docs: add padding-around-describe-blocks docs * docs: add padding-around-test-blocks docs * docs: add padding-around-expect-groups docs * docs: add padding-around-all docs * docs: update README
1 parent f99d6e2 commit 5dc4548

9 files changed

+246
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ export default [
179179
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using `test` as a prefix | | 🌐 | 🔧 | | |
180180
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | 🌐 | | | |
181181
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | enforce padding around `afterAll` blocks | | 🌐 | 🔧 | | |
182+
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | enforce padding around `afterEach` blocks | | 🌐 | 🔧 | | |
183+
| [padding-around-all](docs/rules/padding-around-all.md) | enforce padding around vitest functions | | 🌐 | 🔧 | | |
184+
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | enforce padding around `beforeAll` blocks | | 🌐 | 🔧 | | |
185+
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | enforce padding around `beforeEach` blocks | | 🌐 | 🔧 | | |
186+
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | enforce padding around `describe` blocks | | 🌐 | 🔧 | | |
187+
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | enforce padding around `expect` groups | | 🌐 | 🔧 | | |
182188
| [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | 🌐 | 🔧 | | |
183189
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | 🌐 | 🔧 | | |
184190
| [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | 🌐 | | | |
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Enforce padding around `afterEach` blocks (`vitest/padding-around-after-each-blocks`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `afterEach`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
const someText = 'hoge';
21+
afterEach(() => {});
22+
describe('foo', () => {});
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```js
28+
const someText = 'hoge';
29+
30+
afterEach(() => {});
31+
32+
describe('foo', () => {});
33+
```

docs/rules/padding-around-all.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Enforce padding around vitest functions (`vitest/padding-around-all`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
This is a meta rule that simply enables all of the following rules:
11+
12+
- [padding-around-after-all-blocks](padding-around-after-all-blocks.md)
13+
- [padding-around-after-each-blocks](padding-around-after-each-blocks.md)
14+
- [padding-around-before-all-blocks](padding-around-before-all-blocks.md)
15+
- [padding-around-before-each-blocks](padding-around-before-each-blocks.md)
16+
- [padding-around-expect-groups](padding-around-expect-groups.md)
17+
- [padding-around-describe-blocks](padding-around-describe-blocks.md)
18+
- [padding-around-test-blocks](padding-around-test-blocks.md)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Enforce padding around `beforeAll` blocks (`vitest/padding-around-before-all-blocks`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `beforeAll`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
const someText = 'hoge';
21+
beforeAll(() => {});
22+
describe('foo', () => {});
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```js
28+
const someText = 'hoge';
29+
30+
beforeAll(() => {});
31+
32+
describe('foo', () => {});
33+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Enforce padding around `beforeEach` blocks (`vitest/padding-around-before-each-blocks`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `beforeEach`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
const someText = 'hoge';
21+
beforeEach(() => {});
22+
describe('foo', () => {});
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```js
28+
const someText = 'hoge';
29+
30+
beforeEach(() => {});
31+
32+
describe('foo', () => {});
33+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Enforce padding around `describe` blocks (`vitest/padding-around-describe-blocks`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `describe`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
const someText = 'hoge';
21+
describe("hoge" () => {});
22+
describe('foo', () => {});
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```js
28+
const someText = 'hoge';
29+
30+
describe("hoge" () => {});
31+
32+
describe('foo', () => {});
33+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Enforce padding around `expect` groups (`vitest/padding-around-expect-groups`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `expect`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope and it doesn't add/enforce padding between two or more adjacent expect statements.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
test('test', () => {
21+
let abc = 123;
22+
expect(abc).toEqual(123);
23+
expect(123).toEqual(abc);
24+
abc = 456;
25+
expect(abc).toEqual(456);
26+
});
27+
```
28+
29+
Examples of **correct** code for this rule:
30+
31+
```js
32+
test('test', () => {
33+
let abc = 123;
34+
35+
expect(abc).toEqual(123);
36+
expect(123).toEqual(abc);
37+
38+
abc = 456;
39+
40+
expect(abc).toEqual(456);
41+
});
42+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Enforce padding around `test` blocks (`vitest/padding-around-test-blocks`)
2+
3+
⚠️ This rule _warns_ in the 🌐 `all` config.
4+
5+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6+
7+
<!-- end auto-generated rule header -->
8+
9+
## Rule Details
10+
11+
This rule enforces a line of padding before _and_ after 1 or more `test/it`
12+
statements.
13+
14+
Note that it doesn't add/enforce a padding line if it's the last statement in
15+
its scope.
16+
17+
Examples of **incorrect** code for this rule:
18+
19+
```js
20+
const someText = 'hoge';
21+
test("hoge" () => {});
22+
test('foo', () => {});
23+
```
24+
25+
```js
26+
const someText = 'hoge';
27+
it("hoge" () => {});
28+
it('foo', () => {});
29+
```
30+
31+
Examples of **correct** code for this rule:
32+
33+
```js
34+
const someText = 'hoge';
35+
36+
test("hoge" () => {});
37+
38+
test('foo', () => {});
39+
```
40+
41+
```js
42+
const someText = 'hoge';
43+
44+
it("hoge" () => {});
45+
46+
it('foo', () => {});
47+
```

src/rules/padding-around-test-blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ export const config = [
2929

3030
export default createPaddingRule(
3131
RULE_NAME,
32-
'Enforce padding around afterAll blocks',
32+
'Enforce padding around `test` blocks',
3333
config
3434
)

0 commit comments

Comments
 (0)