eslint-plugin-jest 24.0.2 → 24.1.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [24.1.3](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.2...v24.1.3) (2020-11-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * revert change causing regressions for test.each ([#713](https://github.com/jest-community/eslint-plugin-jest/issues/713)) ([7c8d75a](https://github.com/jest-community/eslint-plugin-jest/commit/7c8d75a4fcbd2c6ce005cf4f57d676c7c44ce0b2)), closes [#710](https://github.com/jest-community/eslint-plugin-jest/issues/710) [#711](https://github.com/jest-community/eslint-plugin-jest/issues/711)
7
+
8
+ ## [24.1.2](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.1...v24.1.2) (2020-11-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **no-done-callback:** fix regression with it.each ([#708](https://github.com/jest-community/eslint-plugin-jest/issues/708)) ([2f032f8](https://github.com/jest-community/eslint-plugin-jest/commit/2f032f8d890e3717359d099b1e93e0cc6b52996a))
14
+
15
+ ## [24.1.1](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.0...v24.1.1) (2020-11-12)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * improve support for it.each involving tagged template literals ([#701](https://github.com/jest-community/eslint-plugin-jest/issues/701)) ([2341814](https://github.com/jest-community/eslint-plugin-jest/commit/2341814060b38c55728c0b456d7b432f1e0e1a11))
21
+
22
+ # [24.1.0](https://github.com/jest-community/eslint-plugin-jest/compare/v24.0.2...v24.1.0) (2020-10-05)
23
+
24
+
25
+ ### Features
26
+
27
+ * **prefer-expect-assertions:** add `onlyFunctionsWithAsyncKeyword` option ([#677](https://github.com/jest-community/eslint-plugin-jest/issues/677)) ([d0cea37](https://github.com/jest-community/eslint-plugin-jest/commit/d0cea37ae0a8ab07b8082cedbaaf161bcc94c405))
28
+
1
29
  ## [24.0.2](https://github.com/jest-community/eslint-plugin-jest/compare/v24.0.1...v24.0.2) (2020-09-20)
2
30
 
3
31
 
@@ -55,3 +55,45 @@ test('my test', () => {
55
55
  expect(someThing()).toEqual('foo');
56
56
  });
57
57
  ```
58
+
59
+ ## Options
60
+
61
+ #### `onlyFunctionsWithAsyncKeyword`
62
+
63
+ When `true`, this rule will only warn for tests that use the `async` keyword.
64
+
65
+ ```json
66
+ {
67
+ "rules": {
68
+ "jest/prefer-expect-assertions": [
69
+ "warn",
70
+ { "onlyFunctionsWithAsyncKeyword": true }
71
+ ]
72
+ }
73
+ }
74
+ ```
75
+
76
+ When `onlyFunctionsWithAsyncKeyword` option is set to `true`, the following
77
+ pattern would be a warning:
78
+
79
+ ```js
80
+ test('my test', async () => {
81
+ const result = await someAsyncFunc();
82
+ expect(result).toBe('foo');
83
+ });
84
+ ```
85
+
86
+ While the following patterns would not be considered warnings:
87
+
88
+ ```js
89
+ test('my test', () => {
90
+ const result = someFunction();
91
+ expect(result).toBe('foo');
92
+ });
93
+
94
+ test('my test', async () => {
95
+ expect.assertions(1);
96
+ const result = await someAsyncFunc();
97
+ expect(result).toBe('foo');
98
+ });
99
+ ```
@@ -43,7 +43,7 @@ xtest('foo', () => {});
43
43
 
44
44
  **titleMustBeString**
45
45
 
46
- Titles for test blocks should always be a string literal or expression.
46
+ Titles for test blocks should always be a string.
47
47
 
48
48
  This is also applied to `describe` blocks by default, but can be turned off via
49
49
  the `ignoreTypeOfDescribeName` option:
@@ -39,13 +39,27 @@ var _default = (0, _utils.createRule)({
39
39
  suggestRemovingExtraArguments: 'Remove extra arguments'
40
40
  },
41
41
  type: 'suggestion',
42
- schema: []
42
+ schema: [{
43
+ type: 'object',
44
+ properties: {
45
+ onlyFunctionsWithAsyncKeyword: {
46
+ type: 'boolean'
47
+ }
48
+ },
49
+ additionalProperties: false
50
+ }]
43
51
  },
44
- defaultOptions: [],
52
+ defaultOptions: [{
53
+ onlyFunctionsWithAsyncKeyword: false
54
+ }],
45
55
 
46
- create(context) {
56
+ create(context, [options]) {
47
57
  return {
48
58
  'CallExpression[callee.name=/^(it|test)$/][arguments.1.body.body]'(node) {
59
+ if (options.onlyFunctionsWithAsyncKeyword && !node.arguments[1].async) {
60
+ return;
61
+ }
62
+
49
63
  const testFuncBody = node.arguments[1].body.body;
50
64
 
51
65
  if (!isFirstLineExprStmt(testFuncBody)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "24.0.2",
3
+ "version": "24.1.3",
4
4
  "description": "Eslint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",