eslint-plugin-jest-formatting 1.2.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +2 -2
- package/.eslintrc +17 -4
- package/.github/workflows/codeql-analysis.yml +71 -0
- package/CHANGELOG.md +6 -0
- package/README.md +10 -11
- package/lib/ast-utils.js +16 -8
- package/lib/index.js +9 -83
- package/lib/rules/padding.js +15 -8
- package/package.json +21 -20
- package/src/ast-utils.ts +5 -1
- package/src/index.ts +1 -110
- package/src/rules/padding.ts +61 -53
- package/tests/catfood.js +2 -0
- package/tests/dogfood.spec.js +2 -0
- package/tests/lib/rules/padding-around-after-all-blocks.spec.js +2 -1
- package/tests/lib/rules/padding-around-after-each-blocks.spec.js +2 -1
- package/tests/lib/rules/padding-around-before-all-blocks.spec.js +2 -1
- package/tests/lib/rules/padding-around-before-each-blocks.spec.js +2 -1
- package/tests/lib/rules/padding-around-describe-blocks.spec.js +2 -1
- package/tests/lib/rules/padding-around-expect-groups.spec.js +66 -3
- package/tests/lib/rules/padding-around-test-blocks.spec.js +1 -0
- package/.nvmrc +0 -1
- package/tests/lib/rules/padding-before-after-all-blocks.spec.js +0 -98
- package/tests/lib/rules/padding-before-after-each-blocks.spec.js +0 -98
- package/tests/lib/rules/padding-before-before-all-blocks.spec.js +0 -98
- package/tests/lib/rules/padding-before-before-each-blocks.spec.js +0 -98
- package/tests/lib/rules/padding-before-describe-blocks.spec.js +0 -144
- package/tests/lib/rules/padding-before-expect-statements.spec.js +0 -138
- package/tests/lib/rules/padding-before-test-blocks.spec.js +0 -153
- package/yarn.lock +0 -4234
package/src/rules/padding.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { AST, Rule, SourceCode } from 'eslint';
|
|
12
|
+
// This is because we are using @types/estree that are brought in with eslint
|
|
13
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
12
14
|
import { Node } from 'estree';
|
|
13
15
|
import * as astUtils from '../ast-utils';
|
|
14
16
|
|
|
@@ -40,12 +42,6 @@ export const enum PaddingType {
|
|
|
40
42
|
Always,
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
type PaddingTester = (
|
|
44
|
-
prevNode: Node,
|
|
45
|
-
nextNode: Node,
|
|
46
|
-
paddingContext: PaddingContext,
|
|
47
|
-
) => void;
|
|
48
|
-
|
|
49
45
|
// A configuration object for padding type and the two statement types
|
|
50
46
|
export interface Config {
|
|
51
47
|
paddingType: PaddingType;
|
|
@@ -53,14 +49,6 @@ export interface Config {
|
|
|
53
49
|
nextStatementType: StatementTypes;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
// Tracks position in scope and prevNode. Used to compare current and prev node
|
|
57
|
-
// and then to walk back up to the parent scope or down into the next one.
|
|
58
|
-
// And so on...
|
|
59
|
-
interface Scope {
|
|
60
|
-
upper: Scope | null;
|
|
61
|
-
prevNode: Node | null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
52
|
interface ScopeInfo {
|
|
65
53
|
prevNode: Node | null;
|
|
66
54
|
enter: () => void;
|
|
@@ -74,16 +62,37 @@ interface PaddingContext {
|
|
|
74
62
|
configs: Config[];
|
|
75
63
|
}
|
|
76
64
|
|
|
65
|
+
type PaddingTester = (
|
|
66
|
+
prevNode: Node,
|
|
67
|
+
nextNode: Node,
|
|
68
|
+
paddingContext: PaddingContext,
|
|
69
|
+
) => void;
|
|
70
|
+
|
|
71
|
+
// Tracks position in scope and prevNode. Used to compare current and prev node
|
|
72
|
+
// and then to walk back up to the parent scope or down into the next one.
|
|
73
|
+
// And so on...
|
|
74
|
+
interface Scope {
|
|
75
|
+
upper: Scope | null;
|
|
76
|
+
prevNode: Node | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
77
79
|
// Creates a StatementTester to test an ExpressionStatement's first token name
|
|
78
80
|
const createTokenTester = (tokenName: string): StatementTester => {
|
|
79
81
|
return (node: Node, sourceCode: SourceCode): boolean => {
|
|
80
|
-
|
|
82
|
+
let activeNode = node;
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
if (activeNode.type === 'ExpressionStatement') {
|
|
85
|
+
// In the case of `await`, we actually care about its argument
|
|
86
|
+
if (activeNode.expression.type === 'AwaitExpression') {
|
|
87
|
+
activeNode = activeNode.expression.argument;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const token = sourceCode.getFirstToken(activeNode);
|
|
91
|
+
|
|
92
|
+
return token.type === 'Identifier' && token.value === tokenName;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false;
|
|
87
96
|
};
|
|
88
97
|
};
|
|
89
98
|
|
|
@@ -134,35 +143,34 @@ const paddingAlwaysTester = (
|
|
|
134
143
|
message: 'Expected blank line before this statement.',
|
|
135
144
|
fix(fixer: Rule.RuleFixer): Rule.Fix {
|
|
136
145
|
let prevToken = astUtils.getActualLastToken(sourceCode, prevNode);
|
|
137
|
-
const nextToken =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}) || nextNode;
|
|
146
|
+
const nextToken = (sourceCode.getFirstTokenBetween(prevToken, nextNode, {
|
|
147
|
+
includeComments: true,
|
|
148
|
+
/**
|
|
149
|
+
* Skip the trailing comments of the previous node.
|
|
150
|
+
* This inserts a blank line after the last trailing comment.
|
|
151
|
+
*
|
|
152
|
+
* For example:
|
|
153
|
+
*
|
|
154
|
+
* foo(); // trailing comment.
|
|
155
|
+
* // comment.
|
|
156
|
+
* bar();
|
|
157
|
+
*
|
|
158
|
+
* Get fixed to:
|
|
159
|
+
*
|
|
160
|
+
* foo(); // trailing comment.
|
|
161
|
+
*
|
|
162
|
+
* // comment.
|
|
163
|
+
* bar();
|
|
164
|
+
*/
|
|
165
|
+
filter(token: AST.Token): boolean {
|
|
166
|
+
if (astUtils.areTokensOnSameLine(prevToken, token)) {
|
|
167
|
+
prevToken = token;
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return true;
|
|
172
|
+
},
|
|
173
|
+
}) || nextNode) as AST.Token;
|
|
166
174
|
|
|
167
175
|
const insertText = astUtils.areTokensOnSameLine(prevToken, nextToken)
|
|
168
176
|
? '\n\n'
|
|
@@ -219,7 +227,7 @@ const nodeMatchesType = (
|
|
|
219
227
|
// If it's an array recursively check if any of the statement types match
|
|
220
228
|
// the node
|
|
221
229
|
if (Array.isArray(statementType)) {
|
|
222
|
-
return statementType.some(type =>
|
|
230
|
+
return statementType.some((type) =>
|
|
223
231
|
nodeMatchesType(innerStatementNode, type, paddingContext),
|
|
224
232
|
);
|
|
225
233
|
}
|
|
@@ -271,8 +279,8 @@ const verifyNode = (node: Node, paddingContext: PaddingContext): void => {
|
|
|
271
279
|
// ESTree.Node doesn't support the parent property which is added by
|
|
272
280
|
// ESLint during traversal. Our best bet is to ignore the property access
|
|
273
281
|
// here as it's the only place that it's checked.
|
|
274
|
-
// @
|
|
275
|
-
if (!astUtils.isValidParent(node.parent.type)) {
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
283
|
+
if (!astUtils.isValidParent((node as any).parent.type)) {
|
|
276
284
|
return;
|
|
277
285
|
}
|
|
278
286
|
|
|
@@ -314,7 +322,7 @@ const verifyNode = (node: Node, paddingContext: PaddingContext): void => {
|
|
|
314
322
|
*/
|
|
315
323
|
export const createRule = (
|
|
316
324
|
configs: Config[],
|
|
317
|
-
deprecated
|
|
325
|
+
deprecated = false,
|
|
318
326
|
): Rule.RuleModule => ({
|
|
319
327
|
meta: {
|
|
320
328
|
fixable: 'whitespace',
|
package/tests/catfood.js
CHANGED
package/tests/dogfood.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const rule = require('../../../lib').rules['padding-around-expect-groups'];
|
|
|
11
11
|
|
|
12
12
|
const ruleTester = new RuleTester({
|
|
13
13
|
parserOptions: {
|
|
14
|
-
ecmaVersion:
|
|
14
|
+
ecmaVersion: 2017,
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -63,6 +63,29 @@ describe('someText', () => {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
test('awaited expect', async () => {
|
|
68
|
+
const abc = 123;
|
|
69
|
+
const hasAPromise = () => Promise.resolve('foo');
|
|
70
|
+
|
|
71
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
72
|
+
expect(abc).toEqual(123);
|
|
73
|
+
|
|
74
|
+
const efg = 456;
|
|
75
|
+
|
|
76
|
+
expect(123).toEqual(abc);
|
|
77
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
78
|
+
|
|
79
|
+
const hij = 789;
|
|
80
|
+
|
|
81
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
82
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
83
|
+
|
|
84
|
+
const somethingElseAsync = () => Promise.resolve('bar');
|
|
85
|
+
await somethingElseAsync();
|
|
86
|
+
|
|
87
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
88
|
+
});
|
|
66
89
|
`;
|
|
67
90
|
|
|
68
91
|
const invalid = `
|
|
@@ -103,6 +126,25 @@ describe('someText', () => {
|
|
|
103
126
|
});
|
|
104
127
|
});
|
|
105
128
|
});
|
|
129
|
+
|
|
130
|
+
test('awaited expect', async () => {
|
|
131
|
+
const abc = 123;
|
|
132
|
+
const hasAPromise = () => Promise.resolve('foo');
|
|
133
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
134
|
+
expect(abc).toEqual(123);
|
|
135
|
+
|
|
136
|
+
const efg = 456;
|
|
137
|
+
expect(123).toEqual(abc);
|
|
138
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
139
|
+
|
|
140
|
+
const hij = 789;
|
|
141
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
142
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
143
|
+
|
|
144
|
+
const somethingElseAsync = () => Promise.resolve('bar');
|
|
145
|
+
await somethingElseAsync();
|
|
146
|
+
await expect(hasAPromise()).resolves.toEqual('foo');
|
|
147
|
+
});
|
|
106
148
|
`;
|
|
107
149
|
|
|
108
150
|
ruleTester.run('padding-around-expect-groups', rule, {
|
|
@@ -111,7 +153,7 @@ ruleTester.run('padding-around-expect-groups', rule, {
|
|
|
111
153
|
{
|
|
112
154
|
code: invalid,
|
|
113
155
|
filename: 'src/component.test.jsx',
|
|
114
|
-
errors:
|
|
156
|
+
errors: 10,
|
|
115
157
|
output: valid,
|
|
116
158
|
},
|
|
117
159
|
{
|
|
@@ -148,7 +190,28 @@ ruleTester.run('padding-around-expect-groups', rule, {
|
|
|
148
190
|
line: 32,
|
|
149
191
|
column: 7
|
|
150
192
|
},
|
|
151
|
-
|
|
193
|
+
{
|
|
194
|
+
message: 'Expected blank line before this statement.',
|
|
195
|
+
line: 43,
|
|
196
|
+
column: 3
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
message: 'Expected blank line before this statement.',
|
|
200
|
+
line: 47,
|
|
201
|
+
column: 3
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
message: 'Expected blank line before this statement.',
|
|
205
|
+
line: 51,
|
|
206
|
+
column: 3
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
message: 'Expected blank line before this statement.',
|
|
210
|
+
line: 56,
|
|
211
|
+
column: 3
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
output: valid,
|
|
152
215
|
},
|
|
153
216
|
]
|
|
154
217
|
});
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v8.10.0
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Enforces single line padding before afterAll blocks
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
//------------------------------------------------------------------------------
|
|
6
|
-
// Requirements
|
|
7
|
-
//------------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const { RuleTester } = require('eslint');
|
|
10
|
-
const rule = require('../../../lib').rules['padding-before-after-all-blocks'];
|
|
11
|
-
|
|
12
|
-
const ruleTester = new RuleTester({
|
|
13
|
-
parserOptions: {
|
|
14
|
-
ecmaVersion: 6,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
//------------------------------------------------------------------------------
|
|
19
|
-
// Tests
|
|
20
|
-
//------------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
const invalid = `
|
|
23
|
-
const someText = 'abc';
|
|
24
|
-
afterAll(() => {
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('someText', () => {
|
|
28
|
-
const something = 'abc';
|
|
29
|
-
// A comment
|
|
30
|
-
afterAll(() => {
|
|
31
|
-
// stuff
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('someText', () => {
|
|
36
|
-
const something = 'abc';
|
|
37
|
-
afterAll(() => {
|
|
38
|
-
// stuff
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const valid = `
|
|
44
|
-
const someText = 'abc';
|
|
45
|
-
|
|
46
|
-
afterAll(() => {
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('someText', () => {
|
|
50
|
-
const something = 'abc';
|
|
51
|
-
|
|
52
|
-
// A comment
|
|
53
|
-
afterAll(() => {
|
|
54
|
-
// stuff
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('someText', () => {
|
|
59
|
-
const something = 'abc';
|
|
60
|
-
|
|
61
|
-
afterAll(() => {
|
|
62
|
-
// stuff
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
ruleTester.run('padding-before-after-all-blocks', rule, {
|
|
68
|
-
valid: [valid],
|
|
69
|
-
invalid: [
|
|
70
|
-
{
|
|
71
|
-
code: invalid,
|
|
72
|
-
filename: 'src/component.test.jsx',
|
|
73
|
-
errors: 3,
|
|
74
|
-
output: valid,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
code: invalid,
|
|
78
|
-
filename: 'src/component.test.js',
|
|
79
|
-
errors: [
|
|
80
|
-
{
|
|
81
|
-
message: 'Expected blank line before this statement.',
|
|
82
|
-
line: 3,
|
|
83
|
-
column: 1
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
message: 'Expected blank line before this statement.',
|
|
87
|
-
line: 9,
|
|
88
|
-
column: 3
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
message: 'Expected blank line before this statement.',
|
|
92
|
-
line: 16,
|
|
93
|
-
column: 3
|
|
94
|
-
},
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
]
|
|
98
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Enforces single line padding before afterEach blocks
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
//------------------------------------------------------------------------------
|
|
6
|
-
// Requirements
|
|
7
|
-
//------------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const { RuleTester } = require('eslint');
|
|
10
|
-
const rule = require('../../../lib').rules['padding-before-after-each-blocks'];
|
|
11
|
-
|
|
12
|
-
const ruleTester = new RuleTester({
|
|
13
|
-
parserOptions: {
|
|
14
|
-
ecmaVersion: 6,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
//------------------------------------------------------------------------------
|
|
19
|
-
// Tests
|
|
20
|
-
//------------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
const invalid = `
|
|
23
|
-
const someText = 'abc';
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('someText', () => {
|
|
28
|
-
const something = 'abc';
|
|
29
|
-
// A comment
|
|
30
|
-
afterEach(() => {
|
|
31
|
-
// stuff
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('someText', () => {
|
|
36
|
-
const something = 'abc';
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
// stuff
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const valid = `
|
|
44
|
-
const someText = 'abc';
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('someText', () => {
|
|
50
|
-
const something = 'abc';
|
|
51
|
-
|
|
52
|
-
// A comment
|
|
53
|
-
afterEach(() => {
|
|
54
|
-
// stuff
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('someText', () => {
|
|
59
|
-
const something = 'abc';
|
|
60
|
-
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
// stuff
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
ruleTester.run('padding-before-after-each-blocks', rule, {
|
|
68
|
-
valid: [valid],
|
|
69
|
-
invalid: [
|
|
70
|
-
{
|
|
71
|
-
code: invalid,
|
|
72
|
-
errors: 3,
|
|
73
|
-
filename: 'src/component.test.jsx',
|
|
74
|
-
output: valid,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
code: invalid,
|
|
78
|
-
filename: 'src/component.test.js',
|
|
79
|
-
errors: [
|
|
80
|
-
{
|
|
81
|
-
message: 'Expected blank line before this statement.',
|
|
82
|
-
line: 3,
|
|
83
|
-
column: 1
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
message: 'Expected blank line before this statement.',
|
|
87
|
-
line: 9,
|
|
88
|
-
column: 3
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
message: 'Expected blank line before this statement.',
|
|
92
|
-
line: 16,
|
|
93
|
-
column: 3
|
|
94
|
-
},
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
]
|
|
98
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Enforces single line padding before beforeAll blocks
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
//------------------------------------------------------------------------------
|
|
6
|
-
// Requirements
|
|
7
|
-
//------------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const { RuleTester } = require('eslint');
|
|
10
|
-
const rule = require('../../../lib').rules['padding-before-before-all-blocks'];
|
|
11
|
-
|
|
12
|
-
const ruleTester = new RuleTester({
|
|
13
|
-
parserOptions: {
|
|
14
|
-
ecmaVersion: 6,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
//------------------------------------------------------------------------------
|
|
19
|
-
// Tests
|
|
20
|
-
//------------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
const invalid = `
|
|
23
|
-
const someText = 'abc';
|
|
24
|
-
beforeAll(() => {
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('someText', () => {
|
|
28
|
-
const something = 'abc';
|
|
29
|
-
// A comment
|
|
30
|
-
beforeAll(() => {
|
|
31
|
-
// stuff
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('someText', () => {
|
|
36
|
-
const something = 'abc';
|
|
37
|
-
beforeAll(() => {
|
|
38
|
-
// stuff
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const valid = `
|
|
44
|
-
const someText = 'abc';
|
|
45
|
-
|
|
46
|
-
beforeAll(() => {
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('someText', () => {
|
|
50
|
-
const something = 'abc';
|
|
51
|
-
|
|
52
|
-
// A comment
|
|
53
|
-
beforeAll(() => {
|
|
54
|
-
// stuff
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('someText', () => {
|
|
59
|
-
const something = 'abc';
|
|
60
|
-
|
|
61
|
-
beforeAll(() => {
|
|
62
|
-
// stuff
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
ruleTester.run('padding-before-before-all-blocks', rule, {
|
|
68
|
-
valid: [valid],
|
|
69
|
-
invalid: [
|
|
70
|
-
{
|
|
71
|
-
code: invalid,
|
|
72
|
-
filename: 'src/component.test.jsx',
|
|
73
|
-
errors: 3,
|
|
74
|
-
output: valid,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
code: invalid,
|
|
78
|
-
filename: 'src/component.test.js',
|
|
79
|
-
errors: [
|
|
80
|
-
{
|
|
81
|
-
message: 'Expected blank line before this statement.',
|
|
82
|
-
line: 3,
|
|
83
|
-
column: 1
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
message: 'Expected blank line before this statement.',
|
|
87
|
-
line: 9,
|
|
88
|
-
column: 3
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
message: 'Expected blank line before this statement.',
|
|
92
|
-
line: 16,
|
|
93
|
-
column: 3
|
|
94
|
-
},
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
]
|
|
98
|
-
});
|