eslint-plugin-jest-formatting 3.0.0 → 4.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.
Files changed (47) hide show
  1. package/AGENTS.md +110 -0
  2. package/CHANGELOG.md +33 -0
  3. package/README.md +44 -1
  4. package/docs/rules/padding-around-after-all-blocks.md +73 -11
  5. package/docs/rules/padding-around-after-each-blocks.md +67 -11
  6. package/docs/rules/padding-around-all.md +102 -9
  7. package/docs/rules/padding-around-before-all-blocks.md +67 -13
  8. package/docs/rules/padding-around-before-each-blocks.md +65 -11
  9. package/docs/rules/padding-around-describe-blocks.md +64 -5
  10. package/docs/rules/padding-around-expect-groups.md +64 -6
  11. package/docs/rules/padding-around-test-blocks.md +76 -13
  12. package/lib/ast-utils.js +15 -8
  13. package/lib/index.js +84 -54
  14. package/lib/rules/padding.js +47 -21
  15. package/llms.txt +29 -0
  16. package/package.json +28 -21
  17. package/.circleci/config.yml +0 -67
  18. package/.eslintignore +0 -3
  19. package/.eslintrc +0 -34
  20. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  21. package/.github/ISSUE_TEMPLATE/rule-request.md +0 -21
  22. package/.prettierignore +0 -4
  23. package/.prettierrc +0 -4
  24. package/docs/rules/padding-before-after-all-blocks.md +0 -24
  25. package/docs/rules/padding-before-after-each-blocks.md +0 -24
  26. package/docs/rules/padding-before-all.md +0 -15
  27. package/docs/rules/padding-before-before-all-blocks.md +0 -24
  28. package/docs/rules/padding-before-before-each-blocks.md +0 -24
  29. package/docs/rules/padding-before-describe-blocks.md +0 -28
  30. package/docs/rules/padding-before-expect-statements.md +0 -22
  31. package/docs/rules/padding-before-test-blocks.md +0 -31
  32. package/jest.config.js +0 -4
  33. package/renovate.json +0 -3
  34. package/src/ast-utils.ts +0 -80
  35. package/src/index.ts +0 -182
  36. package/src/rules/padding.ts +0 -357
  37. package/tests/catfood.js +0 -41
  38. package/tests/dogfood.spec.js +0 -32
  39. package/tests/lib/ast-utils.spec.ts +0 -94
  40. package/tests/lib/rules/padding-around-after-all-blocks.spec.js +0 -115
  41. package/tests/lib/rules/padding-around-after-each-blocks.spec.js +0 -113
  42. package/tests/lib/rules/padding-around-before-all-blocks.spec.js +0 -115
  43. package/tests/lib/rules/padding-around-before-each-blocks.spec.js +0 -115
  44. package/tests/lib/rules/padding-around-describe-blocks.spec.js +0 -153
  45. package/tests/lib/rules/padding-around-expect-groups.spec.js +0 -217
  46. package/tests/lib/rules/padding-around-test-blocks.spec.js +0 -162
  47. package/tsconfig.json +0 -12
@@ -1,217 +0,0 @@
1
- /**
2
- * @fileoverview Enforces single line padding around groups of expect statements
3
- */
4
-
5
- //------------------------------------------------------------------------------
6
- // Requirements
7
- //------------------------------------------------------------------------------
8
-
9
- const { RuleTester } = require('eslint');
10
- const rule = require('../../../lib').rules['padding-around-expect-groups'];
11
-
12
- const ruleTester = new RuleTester({
13
- parserOptions: {
14
- ecmaVersion: 2017,
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
- let abc = 123;
34
-
35
- expect(abc).toEqual(123);
36
- expect(123).toEqual(abc); // Line comment
37
-
38
- abc = 456;
39
-
40
- expect(abc).toEqual(456);
41
- });
42
-
43
- test('thing one', () => {
44
- const abc = 123;
45
-
46
- expect(abc).toEqual(123);
47
-
48
- const xyz = 987;
49
-
50
- expect(123).toEqual(abc); // Line comment
51
- });
52
-
53
- describe('someText', () => {
54
- describe('some condition', () => {
55
- test('foo', () => {
56
- const xyz = 987;
57
-
58
- // Comment
59
- expect(xyz).toEqual(987);
60
- expect(1)
61
- .toEqual(1);
62
- expect(true).toEqual(true);
63
- });
64
- });
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
- });
89
- `;
90
-
91
- const invalid = `
92
- foo();
93
- bar();
94
-
95
- const someText = 'abc';
96
- const someObject = {
97
- one: 1,
98
- two: 2,
99
- };
100
-
101
- test('thing one', () => {
102
- let abc = 123;
103
- expect(abc).toEqual(123);
104
- expect(123).toEqual(abc); // Line comment
105
- abc = 456;
106
- expect(abc).toEqual(456);
107
- });
108
-
109
- test('thing one', () => {
110
- const abc = 123;
111
- expect(abc).toEqual(123);
112
-
113
- const xyz = 987;
114
- expect(123).toEqual(abc); // Line comment
115
- });
116
-
117
- describe('someText', () => {
118
- describe('some condition', () => {
119
- test('foo', () => {
120
- const xyz = 987;
121
- // Comment
122
- expect(xyz).toEqual(987);
123
- expect(1)
124
- .toEqual(1);
125
- expect(true).toEqual(true);
126
- });
127
- });
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
- });
148
- `;
149
-
150
- ruleTester.run('padding-around-expect-groups', rule, {
151
- valid: [valid],
152
- invalid: [
153
- {
154
- code: invalid,
155
- filename: 'src/component.test.jsx',
156
- errors: 10,
157
- output: valid,
158
- },
159
- {
160
- code: invalid,
161
- filename: 'src/component.test.js',
162
- errors: [
163
- {
164
- message: 'Expected blank line before this statement.',
165
- line: 13,
166
- column: 3
167
- },
168
- {
169
- message: 'Expected blank line before this statement.',
170
- line: 15,
171
- column: 3
172
- },
173
- {
174
- message: 'Expected blank line before this statement.',
175
- line: 16,
176
- column: 3
177
- },
178
- {
179
- message: 'Expected blank line before this statement.',
180
- line: 21,
181
- column: 3
182
- },
183
- {
184
- message: 'Expected blank line before this statement.',
185
- line: 24,
186
- column: 3
187
- },
188
- {
189
- message: 'Expected blank line before this statement.',
190
- line: 32,
191
- column: 7
192
- },
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,
215
- },
216
- ]
217
- });
@@ -1,162 +0,0 @@
1
- /**
2
- * @fileoverview Enforces padding line around test/it blocks
3
- * @author Dan Green-Leipciger
4
- */
5
-
6
- //------------------------------------------------------------------------------
7
- // Requirements
8
- //------------------------------------------------------------------------------
9
- const { RuleTester } = require('eslint');
10
- const rule = require('../../../lib').rules['padding-around-test-blocks'];
11
-
12
- const ruleTester = new RuleTester({
13
- parserOptions: {
14
- ecmaVersion: 6,
15
- },
16
- });
17
-
18
- //------------------------------------------------------------------------------
19
- // Tests
20
- //------------------------------------------------------------------------------
21
-
22
- const valid = `
23
- const foo = 'bar';
24
- const bar = 'baz';
25
-
26
- it('foo', () => {
27
- // stuff
28
- });
29
-
30
- fit('bar', () => {
31
- // stuff
32
- });
33
-
34
- test('foo foo', () => {});
35
-
36
- test('bar bar', () => {});
37
-
38
- // Nesting
39
- describe('other bar', () => {
40
- const thing = 123;
41
-
42
- test('is another bar w/ test', () => {
43
- });
44
-
45
- // With a comment
46
- it('is another bar w/ it', () => {
47
- });
48
-
49
- test.skip('skipping', () => {}); // Another comment
50
-
51
- it.skip('skipping too', () => {});
52
- });
53
-
54
- xtest('weird', () => {});
55
-
56
- test
57
- .skip('skippy skip', () => {});
58
-
59
- xit('bar foo', () => {});
60
- `;
61
-
62
- const invalid = `
63
- const foo = 'bar';
64
- const bar = 'baz';
65
- it('foo', () => {
66
- // stuff
67
- });
68
- fit('bar', () => {
69
- // stuff
70
- });
71
- test('foo foo', () => {});
72
- test('bar bar', () => {});
73
-
74
- // Nesting
75
- describe('other bar', () => {
76
- const thing = 123;
77
- test('is another bar w/ test', () => {
78
- });
79
- // With a comment
80
- it('is another bar w/ it', () => {
81
- });
82
- test.skip('skipping', () => {}); // Another comment
83
- it.skip('skipping too', () => {});
84
- });xtest('weird', () => {});
85
- test
86
- .skip('skippy skip', () => {});
87
- xit('bar foo', () => {});
88
- `;
89
-
90
- ruleTester.run('padding-around-test-blocks', rule, {
91
- valid: [valid],
92
- invalid: [
93
- {
94
- code: invalid,
95
- filename: 'src/component.test.jsx',
96
- errors: 11,
97
- output: valid,
98
- },
99
- {
100
- code: invalid,
101
- filename: 'src/component.test.js',
102
- errors: [
103
- {
104
- message: 'Expected blank line before this statement.',
105
- line: 4,
106
- column: 1
107
- },
108
- {
109
- message: 'Expected blank line before this statement.',
110
- line: 7,
111
- column: 1
112
- },
113
- {
114
- message: 'Expected blank line before this statement.',
115
- line: 10,
116
- column: 1
117
- },
118
- {
119
- message: 'Expected blank line before this statement.',
120
- line: 11,
121
- column: 1
122
- },
123
- {
124
- message: 'Expected blank line before this statement.',
125
- line: 16,
126
- column: 3
127
- },
128
- {
129
- message: 'Expected blank line before this statement.',
130
- line: 19,
131
- column: 3
132
- },
133
- {
134
- message: 'Expected blank line before this statement.',
135
- line: 21,
136
- column: 3
137
- },
138
- {
139
- message: 'Expected blank line before this statement.',
140
- line: 22,
141
- column: 3
142
- },
143
- {
144
- message: 'Expected blank line before this statement.',
145
- line: 23,
146
- column: 4
147
- },
148
- {
149
- message: 'Expected blank line before this statement.',
150
- line: 24,
151
- column: 1
152
- },
153
- {
154
- message: 'Expected blank line before this statement.',
155
- line: 26,
156
- column: 1
157
- },
158
- ],
159
- output: valid,
160
- },
161
- ],
162
- });
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "noImplicitAny": true,
5
- "removeComments": true,
6
- "preserveConstEnums": true,
7
- "target": "es2015",
8
- "typeRoots": ["node_modules/@types"],
9
- "outDir": "lib"
10
- },
11
- "exclude": ["node_modules/**/*", "**/*.spec.ts"]
12
- }