eslint-plugin-jest 24.3.6 → 24.3.7

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,10 @@
1
+ ## [24.3.7](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.6...v24.3.7) (2021-07-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **valid-describe:** report on concise-body arrow functions ([#863](https://github.com/jest-community/eslint-plugin-jest/issues/863)) ([71c5299](https://github.com/jest-community/eslint-plugin-jest/commit/71c5299b14cac6d85ba8f8bd939461503a60468f))
7
+
1
8
  ## [24.3.6](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.5...v24.3.6) (2021-04-26)
2
9
 
3
10
 
package/README.md CHANGED
@@ -13,8 +13,8 @@
13
13
 
14
14
  ## Installation
15
15
 
16
- ```
17
- $ yarn add --dev eslint eslint-plugin-jest
16
+ ```bash
17
+ yarn add --dev eslint eslint-plugin-jest
18
18
  ```
19
19
 
20
20
  **Note:** If you installed ESLint globally then you must also install
@@ -27,7 +27,7 @@ are not using TypeScript.
27
27
  overrides: [
28
28
  {
29
29
  files: ['test/**'],
30
- extends: ['jest'],
30
+ plugins: ['jest'],
31
31
  rules: {
32
32
  // you should turn the original rule off *only* for test files
33
33
  '@typescript-eslint/unbound-method': 'off',
@@ -43,6 +43,12 @@ describe('myFunction', () => {
43
43
  });
44
44
  });
45
45
  });
46
+
47
+ // Returning a value from a describe block is not allowed
48
+ describe('myFunction', () =>
49
+ it('returns a truthy value', () => {
50
+ expect(myFunction()).toBeTruthy();
51
+ }));
46
52
  ```
47
53
 
48
54
  The following patterns are not considered warnings:
package/lib/index.js CHANGED
@@ -8,9 +8,9 @@ var _globals = _interopRequireDefault(require("./globals.json"));
8
8
 
9
9
  var snapshotProcessor = _interopRequireWildcard(require("./processors/snapshot-processor"));
10
10
 
11
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
 
13
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
 
@@ -24,10 +24,10 @@ const detectJestVersion = () => {
24
24
  try {
25
25
  const jestPath = require.resolve('jest/package.json', {
26
26
  paths: [process.cwd()]
27
- }); // eslint-disable-next-line @typescript-eslint/no-require-imports
27
+ });
28
28
 
29
-
30
- const jestPackageJson = require(jestPath);
29
+ const jestPackageJson = // eslint-disable-next-line @typescript-eslint/no-require-imports
30
+ require(jestPath);
31
31
 
32
32
  if (jestPackageJson.version) {
33
33
  const [majorVersion] = jestPackageJson.version.split('.');
@@ -84,6 +84,13 @@ var _default = (0, _utils.createRule)({
84
84
  });
85
85
  }
86
86
 
87
+ if (callback.body.type === _experimentalUtils.AST_NODE_TYPES.CallExpression) {
88
+ context.report({
89
+ messageId: 'unexpectedReturnInDescribe',
90
+ node: callback
91
+ });
92
+ }
93
+
87
94
  if (callback.body.type === _experimentalUtils.AST_NODE_TYPES.BlockStatement) {
88
95
  callback.body.body.forEach(node => {
89
96
  if (node.type === _experimentalUtils.AST_NODE_TYPES.ReturnStatement) {
@@ -123,13 +123,12 @@ var _default = (0, _utils.createRule)({
123
123
  return;
124
124
  }
125
125
 
126
- const testFunctionBody = body.body;
127
- const [fulfillmentCallback, rejectionCallback] = node.arguments; // then block can have two args, fulfillment & rejection
126
+ const testFunctionBody = body.body; // then block can have two args, fulfillment & rejection
128
127
  // then block can have one args, fulfillment
129
128
  // catch block can have one args, rejection
130
129
  // ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
131
130
 
132
- verifyExpectWithReturn([fulfillmentCallback, rejectionCallback], node.callee, context, testFunctionBody);
131
+ verifyExpectWithReturn(node.arguments.slice(0, 2), node.callee, context, testFunctionBody);
133
132
  }
134
133
  }
135
134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "24.3.6",
3
+ "version": "24.3.7",
4
4
  "description": "Eslint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -97,7 +97,7 @@
97
97
  "@types/prettier": "^2.0.0",
98
98
  "@typescript-eslint/eslint-plugin": "^4.0.1",
99
99
  "@typescript-eslint/parser": "^4.0.1",
100
- "babel-jest": "^26.0.1",
100
+ "babel-jest": "^27.0.0",
101
101
  "babel-plugin-replace-ts-export-assignment": "^0.0.2",
102
102
  "dedent": "^0.7.0",
103
103
  "eslint": "^5.1.0 || ^6.0.0 || ^7.0.0",
@@ -110,7 +110,7 @@
110
110
  "eslint-plugin-prettier": "^3.0.0",
111
111
  "husky": "^6.0.0",
112
112
  "is-ci": "^3.0.0",
113
- "jest": "^26.0.1",
113
+ "jest": "^27.0.0",
114
114
  "jest-runner-eslint": "^0.10.0",
115
115
  "lint-staged": "^10.2.2",
116
116
  "pinst": "^2.0.0",