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.1 to 26.5.2

13

lib/rules/prefer-comparison-matcher.js

@@ -111,3 +111,6 @@ "use strict";

const preferredMatcher = determineMatcher(comparison.operator, (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value === !!modifier);
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;
const preferredMatcher = determineMatcher(comparison.operator, (0, _utils2.followTypeAssertionChain)(matcher.arguments[0]).value === !!negation);

@@ -120,6 +123,8 @@ if (!preferredMatcher) {

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = context.getSourceCode(); // preserve the existing modifier if it's not a negation
const modifierText = modifier && (modifier === null || modifier === void 0 ? void 0 : modifier.node) !== (negation === null || negation === void 0 ? void 0 : negation.node) ? `.${modifier.name}` : '';
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]], `.${preferredMatcher}`), // replace the matcher argument with the right-hand side of the comparison
fixer.replaceTextRange([expectCallEnd, matcher.node.range[1]], `${modifierText}.${preferredMatcher}`), // replace the matcher argument with the right-hand side of the comparison
fixer.replaceText(matcher.arguments[0], sourceCode.getText(comparison.right))];

@@ -132,3 +137,3 @@ },

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

@@ -135,0 +140,0 @@ }

{
"name": "eslint-plugin-jest",
"version": "26.5.1",
"version": "26.5.2",
"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