Skip to content

Commit a9b78d5

Browse files
authored
feat: Add enforce-consistent-spacing-between-blocks rule (#411)
1 parent 4e8461d commit a9b78d5

File tree

8 files changed

+1131
-58
lines changed

8 files changed

+1131
-58
lines changed

README.md

Lines changed: 56 additions & 55 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Enforce consistent spacing between test blocks (`enforce-consistent-spacing-between-blocks`)
2+
3+
Ensure that there is a consistent spacing between test blocks.
4+
5+
## Rule Details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```javascript
10+
test('example 1', () => {
11+
expect(true).toBe(true)
12+
})
13+
test('example 2', () => {
14+
expect(true).toBe(true)
15+
})
16+
```
17+
18+
```javascript
19+
test.beforeEach(() => {})
20+
test('example 3', () => {
21+
await test.step('first', async () => {
22+
expect(true).toBe(true)
23+
})
24+
await test.step('second', async () => {
25+
expect(true).toBe(true)
26+
})
27+
})
28+
```
29+
30+
Examples of **correct** code for this rule:
31+
32+
```javascript
33+
test('example 1', () => {
34+
expect(true).toBe(true)
35+
})
36+
37+
test('example 2', () => {
38+
expect(true).toBe(true)
39+
})
40+
```
41+
42+
```javascript
43+
test.beforeEach(() => {})
44+
45+
test('example 3', () => {
46+
await test.step('first', async () => {
47+
expect(true).toBe(true)
48+
})
49+
50+
await test.step('second', async () => {
51+
expect(true).toBe(true)
52+
})
53+
})
54+
```

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"lint": "eslint .",
3636
"format": "prettier --write .",
3737
"format:check": "prettier --check .",
38-
"test": "vitest --run --hideSkippedTests",
39-
"test:watch": "vitest --reporter=dot --run",
38+
"test": "vitest --hideSkippedTests",
39+
"test:watch": "vitest --reporter=dot",
4040
"ts": "tsc --noEmit"
4141
},
4242
"peerDependencies": {

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import globals from 'globals'
2+
import consistentSpacingBetweenBlocks from './rules/consistent-spacing-between-blocks.js'
23
import expectExpect from './rules/expect-expect.js'
34
import maxExpects from './rules/max-expects.js'
45
import maxNestedDescribe from './rules/max-nested-describe.js'
@@ -56,6 +57,7 @@ import validTitle from './rules/valid-title.js'
5657
const index = {
5758
configs: {},
5859
rules: {
60+
'consistent-spacing-between-blocks': consistentSpacingBetweenBlocks,
5961
'expect-expect': expectExpect,
6062
'max-expects': maxExpects,
6163
'max-nested-describe': maxNestedDescribe,
@@ -115,6 +117,7 @@ const index = {
115117
const sharedConfig = {
116118
rules: {
117119
'no-empty-pattern': 'off',
120+
'playwright/consistent-spacing-between-blocks': 'warn',
118121
'playwright/expect-expect': 'warn',
119122
'playwright/max-nested-describe': 'warn',
120123
'playwright/missing-playwright-await': 'error',

0 commit comments

Comments
 (0)