eslint-plugin-jest-formatting 1.2.0 → 2.0.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.
@@ -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
- });
@@ -1,98 +0,0 @@
1
- /**
2
- * @fileoverview Enforces single line padding before beforeEach blocks
3
- */
4
-
5
- //------------------------------------------------------------------------------
6
- // Requirements
7
- //------------------------------------------------------------------------------
8
-
9
- const { RuleTester } = require('eslint');
10
- const rule = require('../../../lib').rules['padding-before-before-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
- beforeEach(() => {
25
- });
26
-
27
- describe('someText', () => {
28
- const something = 'abc';
29
- // A comment
30
- beforeEach(() => {
31
- // stuff
32
- });
33
- });
34
-
35
- describe('someText', () => {
36
- const something = 'abc';
37
- beforeEach(() => {
38
- // stuff
39
- });
40
- });
41
- `;
42
-
43
- const valid = `
44
- const someText = 'abc';
45
-
46
- beforeEach(() => {
47
- });
48
-
49
- describe('someText', () => {
50
- const something = 'abc';
51
-
52
- // A comment
53
- beforeEach(() => {
54
- // stuff
55
- });
56
- });
57
-
58
- describe('someText', () => {
59
- const something = 'abc';
60
-
61
- beforeEach(() => {
62
- // stuff
63
- });
64
- });
65
- `;
66
-
67
- ruleTester.run('padding-before-before-each-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,144 +0,0 @@
1
- /**
2
- * @fileoverview Enforces single line padding around describe blocks
3
- * @author Dan Green-Leipciger
4
- */
5
-
6
- //------------------------------------------------------------------------------
7
- // Requirements
8
- //------------------------------------------------------------------------------
9
-
10
- const { RuleTester } = require('eslint');
11
- const rule = require('../../../lib').rules['padding-before-describe-blocks'];
12
-
13
- const ruleTester = new RuleTester({
14
- parserOptions: {
15
- ecmaVersion: 6,
16
- },
17
- });
18
-
19
- //------------------------------------------------------------------------------
20
- // Tests
21
- //------------------------------------------------------------------------------
22
-
23
- const valid = `
24
- foo();
25
- bar();
26
-
27
- const someText = 'abc';
28
- const someObject = {
29
- one: 1,
30
- two: 2,
31
- };
32
-
33
- // A comment before describe
34
- describe('someText', () => {
35
- describe('some condition', () => {
36
- });
37
-
38
- describe('some other condition', () => {
39
- });
40
- });
41
-
42
- describe('someObject', () => {
43
- // Another comment
44
- describe('some condition', () => {
45
- const anotherThing = 500;
46
-
47
- describe('yet another condition', () => { // A comment over here!
48
- });
49
- });
50
- });
51
-
52
- describe('weird', () => {});
53
-
54
- describe.skip('skip me', () => {});
55
-
56
- describe
57
- .skip('skip me too', () => {
58
- // stuff
59
- });
60
- `;
61
-
62
- const invalid = `
63
- foo();
64
- bar();
65
-
66
- const someText = 'abc';
67
- const someObject = {
68
- one: 1,
69
- two: 2,
70
- };
71
- // A comment before describe
72
- describe('someText', () => {
73
- describe('some condition', () => {
74
- });
75
- describe('some other condition', () => {
76
- });
77
- });
78
- describe('someObject', () => {
79
- // Another comment
80
- describe('some condition', () => {
81
- const anotherThing = 500;
82
- describe('yet another condition', () => { // A comment over here!
83
- });
84
- });
85
- });describe('weird', () => {});
86
- describe.skip('skip me', () => {});
87
- describe
88
- .skip('skip me too', () => {
89
- // stuff
90
- });
91
- `;
92
-
93
- ruleTester.run('padding-before-describe-blocks', rule, {
94
- valid: [valid],
95
- invalid: [
96
- {
97
- code: invalid,
98
- filename: 'src/component.test.jsx',
99
- errors: 7,
100
- output: valid,
101
- },
102
- {
103
- code: invalid,
104
- filename: 'src/component.test.js',
105
- errors: [
106
- {
107
- message: 'Expected blank line before this statement.',
108
- line: 11,
109
- column: 1
110
- },
111
- {
112
- message: 'Expected blank line before this statement.',
113
- line: 14,
114
- column: 3
115
- },
116
- {
117
- message: 'Expected blank line before this statement.',
118
- line: 17,
119
- column: 1
120
- },
121
- {
122
- message: 'Expected blank line before this statement.',
123
- line: 21,
124
- column: 5
125
- },
126
- {
127
- message: 'Expected blank line before this statement.',
128
- line: 24,
129
- column: 4
130
- },
131
- {
132
- message: 'Expected blank line before this statement.',
133
- line: 25,
134
- column: 1
135
- },
136
- {
137
- message: 'Expected blank line before this statement.',
138
- line: 26,
139
- column: 1
140
- },
141
- ]
142
- },
143
- ]
144
- });
@@ -1,138 +0,0 @@
1
- /**
2
- * @fileoverview Enforces single line padding before expect statements
3
- */
4
-
5
- //------------------------------------------------------------------------------
6
- // Requirements
7
- //------------------------------------------------------------------------------
8
-
9
- const { RuleTester } = require('eslint');
10
- const rule = require('../../../lib').rules['padding-before-expect-statements'];
11
-
12
- const ruleTester = new RuleTester({
13
- parserOptions: {
14
- ecmaVersion: 6,
15
- },
16
- });
17
-
18
- //------------------------------------------------------------------------------
19
- // Tests
20
- //------------------------------------------------------------------------------
21
-
22
- const valid = `
23
- foo();
24
- bar();
25
-
26
- const someText = 'abc';
27
- const someObject = {
28
- one: 1,
29
- two: 2,
30
- };
31
-
32
- test('thing one', () => {
33
- const abc = 123;
34
-
35
- expect(abc).toEqual(123);
36
- expect(123).toEqual(abc); // Line comment
37
- });
38
-
39
- test('thing one', () => {
40
- const abc = 123;
41
-
42
- expect(abc).toEqual(123);
43
-
44
- const xyz = 987;
45
-
46
- expect(123).toEqual(abc); // Line comment
47
- });
48
-
49
- describe('someText', () => {
50
- describe('some condition', () => {
51
- test('foo', () => {
52
- const xyz = 987;
53
-
54
- // Comment
55
- expect(xyz).toEqual(987);
56
- expect(1)
57
- .toEqual(1);
58
- expect(true).toEqual(true);
59
- });
60
- });
61
- });
62
- `;
63
-
64
- const invalid = `
65
- foo();
66
- bar();
67
-
68
- const someText = 'abc';
69
- const someObject = {
70
- one: 1,
71
- two: 2,
72
- };
73
-
74
- test('thing one', () => {
75
- const abc = 123;
76
- expect(abc).toEqual(123);
77
- expect(123).toEqual(abc); // Line comment
78
- });
79
-
80
- test('thing one', () => {
81
- const abc = 123;
82
- expect(abc).toEqual(123);
83
-
84
- const xyz = 987;
85
- expect(123).toEqual(abc); // Line comment
86
- });
87
-
88
- describe('someText', () => {
89
- describe('some condition', () => {
90
- test('foo', () => {
91
- const xyz = 987;
92
- // Comment
93
- expect(xyz).toEqual(987);
94
- expect(1)
95
- .toEqual(1);
96
- expect(true).toEqual(true);
97
- });
98
- });
99
- });
100
- `;
101
-
102
- ruleTester.run('padding-before-expect-statements', rule, {
103
- valid: [valid],
104
- invalid: [
105
- {
106
- code: invalid,
107
- filename: 'src/component.test.jsx',
108
- errors: 4,
109
- output: valid,
110
- },
111
- {
112
- code: invalid,
113
- filename: 'src/component.test.js',
114
- errors: [
115
- {
116
- message: 'Expected blank line before this statement.',
117
- line: 13,
118
- column: 3
119
- },
120
- {
121
- message: 'Expected blank line before this statement.',
122
- line: 19,
123
- column: 3
124
- },
125
- {
126
- message: 'Expected blank line before this statement.',
127
- line: 22,
128
- column: 3
129
- },
130
- {
131
- message: 'Expected blank line before this statement.',
132
- line: 30,
133
- column: 7
134
- },
135
- ]
136
- },
137
- ]
138
- });