eslint-plugin-jest 23.5.0 → 23.6.0

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,11 @@
1
+ # [23.6.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.5.0...v23.6.0) (2020-01-12)
2
+
3
+ ### Features
4
+
5
+ - **no-if:** support `switch` statements
6
+ ([#515](https://github.com/jest-community/eslint-plugin-jest/issues/515))
7
+ ([be4e49d](https://github.com/jest-community/eslint-plugin-jest/commit/be4e49dcecd64711e743f5e09d1ff24e4c6e1648))
8
+
1
9
  # [23.5.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.4.0...v23.5.0) (2020-01-12)
2
10
 
3
11
  ### Features
@@ -13,6 +13,12 @@ const testCaseNames = new Set([...Object.keys(_utils.TestCaseName), 'it.only', '
13
13
 
14
14
  const isTestArrowFunction = node => node.parent !== undefined && node.parent.type === _experimentalUtils.AST_NODE_TYPES.CallExpression && testCaseNames.has((0, _utils.getNodeName)(node.parent.callee));
15
15
 
16
+ const conditionName = {
17
+ [_experimentalUtils.AST_NODE_TYPES.ConditionalExpression]: 'conditional',
18
+ [_experimentalUtils.AST_NODE_TYPES.SwitchStatement]: 'switch',
19
+ [_experimentalUtils.AST_NODE_TYPES.IfStatement]: 'if'
20
+ };
21
+
16
22
  var _default = (0, _utils.createRule)({
17
23
  name: __filename,
18
24
  meta: {
@@ -22,8 +28,7 @@ var _default = (0, _utils.createRule)({
22
28
  recommended: false
23
29
  },
24
30
  messages: {
25
- noIf: 'Tests should not contain if statements.',
26
- noConditional: 'Tests should not contain conditional statements.'
31
+ noConditionalExpect: 'Test should not contain { condition } statements.'
27
32
  },
28
33
  schema: [],
29
34
  type: 'suggestion'
@@ -36,13 +41,15 @@ var _default = (0, _utils.createRule)({
36
41
  function validate(node) {
37
42
  const lastElementInStack = stack[stack.length - 1];
38
43
 
39
- if (stack.length === 0 || lastElementInStack === false) {
44
+ if (stack.length === 0 || !lastElementInStack) {
40
45
  return;
41
46
  }
42
47
 
43
- const messageId = node.type === _experimentalUtils.AST_NODE_TYPES.ConditionalExpression ? 'noConditional' : 'noIf';
44
48
  context.report({
45
- messageId,
49
+ data: {
50
+ condition: conditionName[node.type]
51
+ },
52
+ messageId: 'noConditionalExpect',
46
53
  node
47
54
  });
48
55
  }
@@ -67,6 +74,7 @@ var _default = (0, _utils.createRule)({
67
74
  },
68
75
 
69
76
  IfStatement: validate,
77
+ SwitchStatement: validate,
70
78
  ConditionalExpression: validate,
71
79
 
72
80
  'CallExpression:exit'() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "23.5.0",
3
+ "version": "23.6.0",
4
4
  "description": "Eslint rules for Jest",
5
5
  "repository": "jest-community/eslint-plugin-jest",
6
6
  "license": "MIT",