Skip to content

Commit

Permalink
docs: add documentation for padding-around-related rules (#623)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
y-hsgw authored Dec 30, 2024
1 parent f99d6e2 commit 5dc4548
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export default [
| [no-test-prefixes](docs/rules/no-test-prefixes.md) | disallow using `test` as a prefix | | 🌐 | 🔧 | | |
| [no-test-return-statement](docs/rules/no-test-return-statement.md) | disallow return statements in tests | | 🌐 | | | |
| [padding-around-after-all-blocks](docs/rules/padding-around-after-all-blocks.md) | enforce padding around `afterAll` blocks | | 🌐 | 🔧 | | |
| [padding-around-after-each-blocks](docs/rules/padding-around-after-each-blocks.md) | enforce padding around `afterEach` blocks | | 🌐 | 🔧 | | |
| [padding-around-all](docs/rules/padding-around-all.md) | enforce padding around vitest functions | | 🌐 | 🔧 | | |
| [padding-around-before-all-blocks](docs/rules/padding-around-before-all-blocks.md) | enforce padding around `beforeAll` blocks | | 🌐 | 🔧 | | |
| [padding-around-before-each-blocks](docs/rules/padding-around-before-each-blocks.md) | enforce padding around `beforeEach` blocks | | 🌐 | 🔧 | | |
| [padding-around-describe-blocks](docs/rules/padding-around-describe-blocks.md) | enforce padding around `describe` blocks | | 🌐 | 🔧 | | |
| [padding-around-expect-groups](docs/rules/padding-around-expect-groups.md) | enforce padding around `expect` groups | | 🌐 | 🔧 | | |
| [prefer-called-with](docs/rules/prefer-called-with.md) | enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | 🌐 | 🔧 | | |
| [prefer-comparison-matcher](docs/rules/prefer-comparison-matcher.md) | enforce using the built-in comparison matchers | | 🌐 | 🔧 | | |
| [prefer-each](docs/rules/prefer-each.md) | enforce using `each` rather than manual loops | | 🌐 | | | |
Expand Down
33 changes: 33 additions & 0 deletions docs/rules/padding-around-after-each-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Enforce padding around `afterEach` blocks (`vitest/padding-around-after-each-blocks`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `afterEach`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope.

Examples of **incorrect** code for this rule:

```js
const someText = 'hoge';
afterEach(() => {});
describe('foo', () => {});
```

Examples of **correct** code for this rule:

```js
const someText = 'hoge';

afterEach(() => {});

describe('foo', () => {});
```
18 changes: 18 additions & 0 deletions docs/rules/padding-around-all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Enforce padding around vitest functions (`vitest/padding-around-all`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details
This is a meta rule that simply enables all of the following rules:

- [padding-around-after-all-blocks](padding-around-after-all-blocks.md)
- [padding-around-after-each-blocks](padding-around-after-each-blocks.md)
- [padding-around-before-all-blocks](padding-around-before-all-blocks.md)
- [padding-around-before-each-blocks](padding-around-before-each-blocks.md)
- [padding-around-expect-groups](padding-around-expect-groups.md)
- [padding-around-describe-blocks](padding-around-describe-blocks.md)
- [padding-around-test-blocks](padding-around-test-blocks.md)
33 changes: 33 additions & 0 deletions docs/rules/padding-around-before-all-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Enforce padding around `beforeAll` blocks (`vitest/padding-around-before-all-blocks`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `beforeAll`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope.

Examples of **incorrect** code for this rule:

```js
const someText = 'hoge';
beforeAll(() => {});
describe('foo', () => {});
```

Examples of **correct** code for this rule:

```js
const someText = 'hoge';

beforeAll(() => {});

describe('foo', () => {});
```
33 changes: 33 additions & 0 deletions docs/rules/padding-around-before-each-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Enforce padding around `beforeEach` blocks (`vitest/padding-around-before-each-blocks`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `beforeEach`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope.

Examples of **incorrect** code for this rule:

```js
const someText = 'hoge';
beforeEach(() => {});
describe('foo', () => {});
```

Examples of **correct** code for this rule:

```js
const someText = 'hoge';

beforeEach(() => {});

describe('foo', () => {});
```
33 changes: 33 additions & 0 deletions docs/rules/padding-around-describe-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Enforce padding around `describe` blocks (`vitest/padding-around-describe-blocks`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `describe`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope.

Examples of **incorrect** code for this rule:

```js
const someText = 'hoge';
describe("hoge" () => {});
describe('foo', () => {});
```

Examples of **correct** code for this rule:

```js
const someText = 'hoge';

describe("hoge" () => {});

describe('foo', () => {});
```
42 changes: 42 additions & 0 deletions docs/rules/padding-around-expect-groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Enforce padding around `expect` groups (`vitest/padding-around-expect-groups`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `expect`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope and it doesn't add/enforce padding between two or more adjacent expect statements.

Examples of **incorrect** code for this rule:

```js
test('test', () => {
let abc = 123;
expect(abc).toEqual(123);
expect(123).toEqual(abc);
abc = 456;
expect(abc).toEqual(456);
});
```

Examples of **correct** code for this rule:

```js
test('test', () => {
let abc = 123;

expect(abc).toEqual(123);
expect(123).toEqual(abc);

abc = 456;

expect(abc).toEqual(456);
});
```
47 changes: 47 additions & 0 deletions docs/rules/padding-around-test-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Enforce padding around `test` blocks (`vitest/padding-around-test-blocks`)

⚠️ This rule _warns_ in the 🌐 `all` config.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

## Rule Details

This rule enforces a line of padding before _and_ after 1 or more `test/it`
statements.

Note that it doesn't add/enforce a padding line if it's the last statement in
its scope.

Examples of **incorrect** code for this rule:

```js
const someText = 'hoge';
test("hoge" () => {});
test('foo', () => {});
```

```js
const someText = 'hoge';
it("hoge" () => {});
it('foo', () => {});
```

Examples of **correct** code for this rule:

```js
const someText = 'hoge';

test("hoge" () => {});

test('foo', () => {});
```

```js
const someText = 'hoge';

it("hoge" () => {});

it('foo', () => {});
```
2 changes: 1 addition & 1 deletion src/rules/padding-around-test-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export const config = [

export default createPaddingRule(
RULE_NAME,
'Enforce padding around afterAll blocks',
'Enforce padding around `test` blocks',
config
)

0 comments on commit 5dc4548

Please sign in to comment.