eslint-plugin-jest 26.5.1 → 26.5.2

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.
@@ -108,7 +108,10 @@ var _default = (0, _utils2.createRule)({
108
108
  return;
109
109
  }
110
110
 
111
- const preferredMatcher = determineMatcher(comparison.operator, (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value === !!modifier);
111
+ const negation = modifier !== null && modifier !== void 0 && modifier.negation ? {
112
+ node: modifier.negation
113
+ } : (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.not ? modifier : null;
114
+ const preferredMatcher = determineMatcher(comparison.operator, (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value === !!negation);
112
115
 
113
116
  if (!preferredMatcher) {
114
117
  return;
@@ -116,10 +119,12 @@ var _default = (0, _utils2.createRule)({
116
119
 
117
120
  context.report({
118
121
  fix(fixer) {
119
- const sourceCode = context.getSourceCode();
122
+ const sourceCode = context.getSourceCode(); // preserve the existing modifier if it's not a negation
123
+
124
+ const modifierText = modifier && (modifier === null || modifier === void 0 ? void 0 : modifier.node) !== (negation === null || negation === void 0 ? void 0 : negation.node) ? `.${modifier.name}` : '';
120
125
  return [// replace the comparison argument with the left-hand side of the comparison
121
126
  fixer.replaceText(comparison, sourceCode.getText(comparison.left)), // replace the current matcher & modifier with the preferred matcher
122
- fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], `.${preferredMatcher}`), // replace the matcher argument with the right-hand side of the comparison
127
+ fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], `${modifierText}.${preferredMatcher}`), // replace the matcher argument with the right-hand side of the comparison
123
128
  fixer.replaceText(matcher.arguments[0], sourceCode.getText(comparison.right))];
124
129
  },
125
130
 
@@ -127,7 +132,7 @@ var _default = (0, _utils2.createRule)({
127
132
  data: {
128
133
  preferredMatcher
129
134
  },
130
- node: (modifier || matcher).node.property
135
+ node: (negation || matcher).node.property
131
136
  });
132
137
  }
133
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.5.1",
3
+ "version": "26.5.2",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",