Socket
Socket
Sign inDemoInstall

eslint-plugin-jest-dom

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jest-dom - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

22

dist/createBannedAttributeRule.js

@@ -13,3 +13,3 @@ "use strict";

}) => context => {
const getCorrectFunctionFor = (node, negated = false) => (node.arguments.length === 1 || node.arguments[1].value === true || typeof node.arguments[1].value === "string" && node.arguments[1].value.toLowerCase() === "true" || node.arguments[1].value === "") && !negated ? preferred : negatedPreferred;
const getCorrectFunctionFor = (node, negated = false) => (node.arguments.length === 1 || node.arguments[1].value === true || node.arguments[1].type !== "Literal" || typeof node.arguments[1].value === "string" && node.arguments[1].value.toLowerCase() === "true" || node.arguments[1].value === "") && !negated ? preferred : negatedPreferred;

@@ -33,3 +33,3 @@ const isBannedArg = node => attributes.some(attr => attr === node.arguments[0].value);

[`CallExpression[callee.property.name=/toBe(Truthy|Falsy)?|toEqual/][callee.object.callee.name='expect']`](node) {
"CallExpression[callee.property.name=/toBe(Truthy|Falsy)?|toEqual/][callee.object.callee.name='expect']"(node) {
const {

@@ -59,3 +59,3 @@ arguments: [{

[`CallExpression[callee.property.name=/toHaveProperty|toHaveAttribute/][callee.object.property.name='not'][callee.object.object.callee.name='expect']`](node) {
"CallExpression[callee.property.name=/toHaveProperty|toHaveAttribute/][callee.object.property.name='not'][callee.object.object.callee.name='expect']"(node) {
const arg = node.arguments[0].value;

@@ -76,3 +76,3 @@

[`CallExpression[callee.object.callee.name='expect'][callee.property.name=/toHaveProperty|toHaveAttribute/]`](node) {
"CallExpression[callee.object.callee.name='expect'][callee.property.name=/toHaveProperty|toHaveAttribute/]"(node) {
if (!isBannedArg(node)) {

@@ -85,8 +85,16 @@ return;

const message = `Use ${correctFunction}() instead of ${incorrectFunction}(${node.arguments.map(({
raw
}) => raw).join(", ")})`;
raw,
name
}) => raw || name).join(", ")})`;
const secondArgIsLiteral = node.arguments.length === 2 && node.arguments[1].type === "Literal";
context.report({
node: node.callee.property,
message,
fix: fixer => [fixer.replaceTextRange([node.callee.property.range[0], node.range[1]], `${correctFunction}()`)]
fix: fixer => {
if (node.arguments.length === 1 || secondArgIsLiteral) {
return [fixer.replaceTextRange([node.callee.property.range[0], node.range[1]], `${correctFunction}()`)];
}
return null;
}
});

@@ -93,0 +101,0 @@ }

{
"name": "eslint-plugin-jest-dom",
"version": "3.1.1",
"version": "3.1.2",
"description": "ESLint plugin to follow best practices and anticipate common mistakes when writing tests with jest-dom",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -154,2 +154,3 @@ <div align="center">

<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -156,0 +157,0 @@

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