-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[reword] implement rules for remaining functions
- Loading branch information
Showing
13 changed files
with
745 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# padding-before-after-all-blocks | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before afterAll blocks | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
afterAll(() => { | ||
// more stuff | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
|
||
afterAll(() => { | ||
// more stuff | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# padding-before-after-each-blocks | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before afterEach blocks | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
afterEach(() => { | ||
// more stuff | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
|
||
afterEach(() => { | ||
// more stuff | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# padding-before-after-all-blocks | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before all Jest tokens. | ||
|
||
See each individual rules for examples. | ||
|
||
- [padding-before-after-all-blocks](docs/rules/padding-before-after-all-blocks.md) | ||
- [padding-before-after-each-blocks](docs/rules/padding-before-after-each-blocks.md) | ||
- [padding-before-before-all-blocks](docs/rules/padding-before-before-all-blocks.md) | ||
- [padding-before-before-each-blocks](docs/rules/padding-before-before-each-blocks.md) | ||
- [padding-before-describe-blocks](docs/rules/padding-before-describe-blocks.md) | ||
- [padding-before-expect-statements](docs/rules/padding-before-expect-statements.md) | ||
- [padding-before-test-blocks](docs/rules/padding-before-test-blocks.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# padding-before-before-all-blocks | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before beforeAll blocks | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
beforeAll(() => { | ||
// more stuff | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
|
||
beforeAll(() => { | ||
// more stuff | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# padding-before-before-each-blocks | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before beforeEach blocks | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
beforeEach(() => { | ||
// more stuff | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
|
||
beforeEach(() => { | ||
// more stuff | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# padding-before-expect-statements | ||
|
||
## Rule Details | ||
|
||
This rule enforces a line of padding before non-consecutive expect statements | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
expect(something).toEqual(123); | ||
expect(something).toBeGreaterThan(0); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const something = 123; | ||
|
||
expect(something).toEqual(123); | ||
expect(something).toBeGreaterThan(0); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
tests/lib/rules/padding-before-after-all-blocks.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @fileoverview Enforces single line padding before afterAll blocks | ||
*/ | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
const { RuleTester } = require('eslint'); | ||
const rule = require('../../../lib').rules['padding-before-after-all-blocks']; | ||
|
||
const ruleTester = new RuleTester({ | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
}, | ||
}); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Tests | ||
//------------------------------------------------------------------------------ | ||
|
||
const invalid = ` | ||
const someText = 'abc'; | ||
afterAll(() => { | ||
}); | ||
describe('someText', () => { | ||
const something = 'abc'; | ||
// A comment | ||
afterAll(() => { | ||
// stuff | ||
}); | ||
}); | ||
describe('someText', () => { | ||
const something = 'abc'; | ||
afterAll(() => { | ||
// stuff | ||
}); | ||
}); | ||
`; | ||
|
||
const valid = ` | ||
const someText = 'abc'; | ||
afterAll(() => { | ||
}); | ||
describe('someText', () => { | ||
const something = 'abc'; | ||
// A comment | ||
afterAll(() => { | ||
// stuff | ||
}); | ||
}); | ||
describe('someText', () => { | ||
const something = 'abc'; | ||
afterAll(() => { | ||
// stuff | ||
}); | ||
}); | ||
`; | ||
|
||
ruleTester.run('padding-before-after-all-blocks', rule, { | ||
valid: [ | ||
valid, | ||
{ | ||
code: invalid, | ||
filename: 'src/component.jsx' | ||
} | ||
], | ||
invalid: [ | ||
{ | ||
code: invalid, | ||
filename: 'src/component.test.jsx', | ||
errors: 3, | ||
output: valid, | ||
}, | ||
{ | ||
code: invalid, | ||
filename: 'src/component.test.js', | ||
errors: [ | ||
{ | ||
message: 'Expected blank line before this statement.', | ||
line: 3, | ||
column: 1 | ||
}, | ||
{ | ||
message: 'Expected blank line before this statement.', | ||
line: 9, | ||
column: 3 | ||
}, | ||
{ | ||
message: 'Expected blank line before this statement.', | ||
line: 16, | ||
column: 3 | ||
}, | ||
] | ||
}, | ||
] | ||
}); |
Oops, something went wrong.