Socket
Socket
Sign inDemoInstall

eslint-plugin-jest

Package Overview
Dependencies
Maintainers
11
Versions
325
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jest - npm Package Compare versions

Comparing version 26.5.2 to 26.5.3

20

lib/rules/prefer-equality-matcher.js

@@ -67,12 +67,22 @@ "use strict";

const matcherValue = (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value; // we need to negate the expectation if the current expected
const matcherValue = (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value;
const negation = modifier !== null && modifier !== void 0 && modifier.negation ? {
node: modifier.negation
} : (modifier === null || modifier === void 0 ? void 0 : modifier.name) === _utils2.ModifierName.not ? modifier : null; // we need to negate the expectation if the current expected
// value is itself negated by the "not" modifier
const addNotModifier = (comparison.operator === '!==' ? !matcherValue : matcherValue) === !!modifier;
const addNotModifier = (comparison.operator === '!==' ? !matcherValue : matcherValue) === !!negation;
const buildFixer = equalityMatcher => fixer => {
const sourceCode = context.getSourceCode();
const sourceCode = context.getSourceCode(); // preserve the existing modifier if it's not a negation
let modifierText = modifier && (modifier === null || modifier === void 0 ? void 0 : modifier.node) !== (negation === null || negation === void 0 ? void 0 : negation.node) ? `.${modifier.name}` : '';
if (addNotModifier) {
modifierText += `.${_utils2.ModifierName.not}`;
}
return [// replace the comparison argument with the left-hand side of the comparison
fixer.replaceText(comparison, sourceCode.getText(comparison.left)), // replace the current matcher & modifier with the preferred matcher
fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], addNotModifier ? `.${_utils2.ModifierName.not}.${equalityMatcher}` : `.${equalityMatcher}`), // replace the matcher argument with the right-hand side of the comparison
fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], `${modifierText}.${equalityMatcher}`), // replace the matcher argument with the right-hand side of the comparison
fixer.replaceText(matcher.arguments[0], sourceCode.getText(comparison.right))];

@@ -90,3 +100,3 @@ };

})),
node: (modifier || matcher).node.property
node: (negation || matcher).node.property
});

@@ -93,0 +103,0 @@ }

{
"name": "eslint-plugin-jest",
"version": "26.5.2",
"version": "26.5.3",
"description": "ESLint rules for Jest",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc