eslint-plugin-jest 27.4.0 → 27.4.1

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.
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _utils = require("@typescript-eslint/utils");
8
- var _utils2 = require("./utils");
9
- var _default = (0, _utils2.createRule)({
7
+ var _utils = require("./utils");
8
+ var _default = (0, _utils.createRule)({
10
9
  name: __filename,
11
10
  meta: {
12
11
  docs: {
@@ -35,39 +34,28 @@ var _default = (0, _utils2.createRule)({
35
34
  create(context, [{
36
35
  max
37
36
  }]) {
38
- const describeCallbackStack = [];
39
- function pushDescribeCallback(node) {
40
- const {
41
- parent
42
- } = node;
43
- if ((parent === null || parent === void 0 ? void 0 : parent.type) !== _utils.AST_NODE_TYPES.CallExpression || !(0, _utils2.isTypeOfJestFnCall)(parent, context, ['describe'])) {
44
- return;
45
- }
46
- describeCallbackStack.push(0);
47
- if (describeCallbackStack.length > max) {
48
- context.report({
49
- node: parent,
50
- messageId: 'exceededMaxDepth',
51
- data: {
52
- depth: describeCallbackStack.length,
53
- max
37
+ const describes = [];
38
+ return {
39
+ CallExpression(node) {
40
+ if ((0, _utils.isTypeOfJestFnCall)(node, context, ['describe'])) {
41
+ describes.unshift(node);
42
+ if (describes.length > max) {
43
+ context.report({
44
+ node,
45
+ messageId: 'exceededMaxDepth',
46
+ data: {
47
+ depth: describes.length,
48
+ max
49
+ }
50
+ });
54
51
  }
55
- });
56
- }
57
- }
58
- function popDescribeCallback(node) {
59
- const {
60
- parent
61
- } = node;
62
- if ((parent === null || parent === void 0 ? void 0 : parent.type) === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isTypeOfJestFnCall)(parent, context, ['describe'])) {
63
- describeCallbackStack.pop();
52
+ }
53
+ },
54
+ 'CallExpression:exit'(node) {
55
+ if (describes[0] === node) {
56
+ describes.shift();
57
+ }
64
58
  }
65
- }
66
- return {
67
- FunctionExpression: pushDescribeCallback,
68
- 'FunctionExpression:exit': popDescribeCallback,
69
- ArrowFunctionExpression: pushDescribeCallback,
70
- 'ArrowFunctionExpression:exit': popDescribeCallback
71
59
  };
72
60
  }
73
61
  });
@@ -33,7 +33,7 @@ var _default = (0, _utils2.createRule)({
33
33
  if (jestFnCall.name.startsWith('f')) {
34
34
  context.report({
35
35
  messageId: 'focusedTest',
36
- node,
36
+ node: jestFnCall.head.node,
37
37
  suggest: [{
38
38
  messageId: 'suggestRemoveFocus',
39
39
  fix(fixer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "27.4.0",
3
+ "version": "27.4.1",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",