eslint-plugin-jest 26.1.1 → 26.1.4

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.
@@ -14,10 +14,26 @@ const isSnapshotMatcher = matcher => {
14
14
  };
15
15
 
16
16
  const isSnapshotMatcherWithoutHint = matcher => {
17
- var _matcher$arguments;
17
+ if (!matcher.arguments || matcher.arguments.length === 0) {
18
+ return true;
19
+ } // this matcher only supports one argument which is the hint
18
20
 
19
- const expectedNumberOfArgumentsWithHint = 1 + Number(matcher.name === 'toMatchSnapshot');
20
- return ((_matcher$arguments = matcher.arguments) === null || _matcher$arguments === void 0 ? void 0 : _matcher$arguments.length) !== expectedNumberOfArgumentsWithHint;
21
+
22
+ if (matcher.name !== 'toMatchSnapshot') {
23
+ return matcher.arguments.length !== 1;
24
+ } // if we're being passed two arguments,
25
+ // the second one should be the hint
26
+
27
+
28
+ if (matcher.arguments.length === 2) {
29
+ return false;
30
+ }
31
+
32
+ const [arg] = matcher.arguments; // the first argument to `toMatchSnapshot` can be _either_ a snapshot hint or
33
+ // an object with asymmetric matchers, so we can't just assume that the first
34
+ // argument is a hint when it's by itself.
35
+
36
+ return !(0, _utils.isStringNode)(arg);
21
37
  };
22
38
 
23
39
  const messages = {
@@ -43,6 +59,7 @@ var _default = (0, _utils.createRule)({
43
59
 
44
60
  create(context, [mode]) {
45
61
  const snapshotMatchers = [];
62
+ const depths = [];
46
63
  let expressionDepth = 0;
47
64
 
48
65
  const reportSnapshotMatchersWithoutHints = () => {
@@ -88,7 +105,21 @@ var _default = (0, _utils.createRule)({
88
105
  ArrowFunctionExpression: enterExpression,
89
106
  'ArrowFunctionExpression:exit': exitExpression,
90
107
 
108
+ 'CallExpression:exit'(node) {
109
+ if ((0, _utils.isDescribeCall)(node) || (0, _utils.isTestCaseCall)(node)) {
110
+ var _depths$pop;
111
+
112
+ /* istanbul ignore next */
113
+ expressionDepth = (_depths$pop = depths.pop()) !== null && _depths$pop !== void 0 ? _depths$pop : 0;
114
+ }
115
+ },
116
+
91
117
  CallExpression(node) {
118
+ if ((0, _utils.isDescribeCall)(node) || (0, _utils.isTestCaseCall)(node)) {
119
+ depths.push(expressionDepth);
120
+ expressionDepth = 0;
121
+ }
122
+
92
123
  if (!(0, _utils.isExpectCall)(node)) {
93
124
  return;
94
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.1.1",
3
+ "version": "26.1.4",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -112,13 +112,13 @@
112
112
  "eslint-plugin-node": "^11.0.0",
113
113
  "eslint-plugin-prettier": "^3.4.1",
114
114
  "eslint-remote-tester": "^2.1.0",
115
- "eslint-remote-tester-repositories": "^0.0.4",
115
+ "eslint-remote-tester-repositories": "^0.0.5",
116
116
  "husky": "^7.0.2",
117
117
  "is-ci": "^3.0.0",
118
118
  "jest": "^27.0.0",
119
119
  "jest-runner-eslint": "^1.0.0",
120
120
  "lint-staged": "^12.0.0",
121
- "pinst": "^2.0.0",
121
+ "pinst": "^3.0.0",
122
122
  "prettier": "^2.0.5",
123
123
  "rimraf": "^3.0.0",
124
124
  "semantic-release": "^19.0.0",
@@ -139,7 +139,7 @@
139
139
  }
140
140
  },
141
141
  "engines": {
142
- "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
142
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
143
143
  },
144
144
  "release": {
145
145
  "branches": [
@@ -163,5 +163,5 @@
163
163
  "@typescript-eslint/experimental-utils": "^5.0.0",
164
164
  "fsevents/node-gyp": "^7.0.0"
165
165
  },
166
- "packageManager": "yarn@3.1.1"
166
+ "packageManager": "yarn@3.2.0"
167
167
  }