eslint-plugin-jest 24.1.8 → 24.2.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [24.2.1](https://github.com/jest-community/eslint-plugin-jest/compare/v24.2.0...v24.2.1) (2021-03-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **no-identical-titles:** support nested describes ([#790](https://github.com/jest-community/eslint-plugin-jest/issues/790)) ([ce26621](https://github.com/jest-community/eslint-plugin-jest/commit/ce26621a06169fb6728d2d015645d31401de523f))
7
+
8
+ # [24.2.0](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.10...v24.2.0) (2021-03-09)
9
+
10
+
11
+ ### Features
12
+
13
+ * **no-focused-tests:** make fixable ([#787](https://github.com/jest-community/eslint-plugin-jest/issues/787)) ([040871a](https://github.com/jest-community/eslint-plugin-jest/commit/040871a866b7803e5c48b40715d48437d3906b0f))
14
+
15
+ ## [24.1.10](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.9...v24.1.10) (2021-03-09)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **no-identical-titles:** ignore .each template cases ([#788](https://github.com/jest-community/eslint-plugin-jest/issues/788)) ([d27a6e6](https://github.com/jest-community/eslint-plugin-jest/commit/d27a6e6e013c518a47b9f219edeb5e63d7a974f9))
21
+
22
+ ## [24.1.9](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.8...v24.1.9) (2021-03-08)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **valid-describe:** false positive with template describe.each ([#785](https://github.com/jest-community/eslint-plugin-jest/issues/785)) ([aa946a6](https://github.com/jest-community/eslint-plugin-jest/commit/aa946a6f7ae7106b78996587760d92ace33227ad))
28
+
1
29
  ## [24.1.8](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.7...v24.1.8) (2021-03-07)
2
30
 
3
31
 
package/README.md CHANGED
@@ -143,7 +143,7 @@ installations requiring long-term consistency.
143
143
  | [no-done-callback](docs/rules/no-done-callback.md) | Avoid using a callback in asynchronous tests and hooks | ![recommended][] | ![suggest][] |
144
144
  | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | |
145
145
  | [no-export](docs/rules/no-export.md) | Disallow using `exports` in files containing tests | ![recommended][] | |
146
- | [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] |
146
+ | [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] |
147
147
  | [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
148
148
  | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
149
149
  | [no-if](docs/rules/no-if.md) | Disallow conditional logic | | |
@@ -26,12 +26,13 @@ var _default = (0, _utils.createRule)({
26
26
  docs: {
27
27
  category: 'Best Practices',
28
28
  description: 'Disallow focused tests',
29
- recommended: 'error'
29
+ recommended: 'error',
30
+ suggestion: true
30
31
  },
31
32
  messages: {
32
- focusedTest: 'Unexpected focused test.'
33
+ focusedTest: 'Unexpected focused test.',
34
+ suggestRemoveFocus: 'Remove focus from test.'
33
35
  },
34
- fixable: 'code',
35
36
  schema: [],
36
37
  type: 'suggestion'
37
38
  },
@@ -41,18 +42,40 @@ var _default = (0, _utils.createRule)({
41
42
  const callee = node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression ? node.callee.tag : node.callee;
42
43
 
43
44
  if (callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) {
44
- if (callee.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && isCallToFocusedTestFunction(callee.object)) {
45
+ const calleeObject = callee.object;
46
+
47
+ if (calleeObject.type === _experimentalUtils.AST_NODE_TYPES.Identifier && isCallToFocusedTestFunction(calleeObject)) {
45
48
  context.report({
46
49
  messageId: 'focusedTest',
47
- node: callee.object
50
+ node: calleeObject,
51
+ suggest: [{
52
+ messageId: 'suggestRemoveFocus',
53
+
54
+ fix(fixer) {
55
+ return fixer.removeRange([calleeObject.range[0], calleeObject.range[0] + 1]);
56
+ }
57
+
58
+ }]
48
59
  });
49
60
  return;
50
61
  }
51
62
 
52
- if (callee.object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isCallToTestOnlyFunction(callee.object)) {
63
+ if (calleeObject.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isCallToTestOnlyFunction(calleeObject)) {
53
64
  context.report({
54
65
  messageId: 'focusedTest',
55
- node: callee.object.property
66
+ node: calleeObject.property,
67
+ suggest: [{
68
+ messageId: 'suggestRemoveFocus',
69
+
70
+ fix(fixer) {
71
+ if (calleeObject.property.type === _experimentalUtils.AST_NODE_TYPES.Identifier && calleeObject.property.name === 'only') {
72
+ return fixer.removeRange([calleeObject.object.range[1], calleeObject.range[1]]);
73
+ }
74
+
75
+ return fixer.removeRange([calleeObject.range[1], callee.range[1]]);
76
+ }
77
+
78
+ }]
56
79
  });
57
80
  return;
58
81
  }
@@ -60,7 +83,15 @@ var _default = (0, _utils.createRule)({
60
83
  if (isCallToTestOnlyFunction(callee)) {
61
84
  context.report({
62
85
  messageId: 'focusedTest',
63
- node: callee.property
86
+ node: callee.property,
87
+ suggest: [{
88
+ messageId: 'suggestRemoveFocus',
89
+
90
+ fix(fixer) {
91
+ return fixer.removeRange([calleeObject.range[1], callee.range[1]]);
92
+ }
93
+
94
+ }]
64
95
  });
65
96
  return;
66
97
  }
@@ -69,7 +100,15 @@ var _default = (0, _utils.createRule)({
69
100
  if (callee.type === _experimentalUtils.AST_NODE_TYPES.Identifier && isCallToFocusedTestFunction(callee)) {
70
101
  context.report({
71
102
  messageId: 'focusedTest',
72
- node: callee
103
+ node: callee,
104
+ suggest: [{
105
+ messageId: 'suggestRemoveFocus',
106
+
107
+ fix(fixer) {
108
+ return fixer.removeRange([callee.range[0], callee.range[0] + 1]);
109
+ }
110
+
111
+ }]
73
112
  });
74
113
  }
75
114
  }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _experimentalUtils = require("@typescript-eslint/experimental-utils");
9
+
8
10
  var _utils = require("./utils");
9
11
 
10
12
  const newDescribeContext = () => ({
@@ -39,6 +41,10 @@ var _default = (0, _utils.createRule)({
39
41
  contexts.push(newDescribeContext());
40
42
  }
41
43
 
44
+ if (node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression) {
45
+ return;
46
+ }
47
+
42
48
  const [argument] = node.arguments;
43
49
 
44
50
  if (!argument || !(0, _utils.isStringNode)(argument)) {
@@ -41,7 +41,7 @@ var _default = (0, _utils.createRule)({
41
41
  create(context) {
42
42
  return {
43
43
  CallExpression(node) {
44
- if (!(0, _utils.isDescribe)(node)) {
44
+ if (!(0, _utils.isDescribe)(node) || node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression) {
45
45
  return;
46
46
  }
47
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "24.1.8",
3
+ "version": "24.2.1",
4
4
  "description": "Eslint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",