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.6.4 to 3.6.5

56

dist/rules/prefer-to-have-value.js

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

const create = context => {
function validateQueryNode(nodeWithValueProp) {
function isValidQueryNode(nodeWithValueProp) {
const {

@@ -40,15 +40,3 @@ query,

} = (0, _assignmentAst.getQueryNodeFrom)(context, nodeWithValueProp);
if (!query) {
return {
isDTLQuery: false,
isValidElement: false
};
}
const isValidElement = query.match(/^(get|find|query)ByRole$/) && ["textbox", "dropdown"].includes(queryArg);
return {
isDTLQuery,
isValidElement
};
return !!query && isDTLQuery && !!query.match(/^(get|find|query)(All)?ByRole$/) && ["textbox", "dropdown"].includes(queryArg);
}

@@ -64,20 +52,12 @@

const queryNode = node.callee.object.arguments[0].object;
const {
isDTLQuery,
isValidElement
} = validateQueryNode(queryNode);
function fix(fixer) {
return [fixer.remove(context.getSourceCode().getTokenBefore(valueProp)), fixer.remove(valueProp), fixer.replaceText(matcher, "toHaveValue")];
}
if (isDTLQuery) {
if (isValidQueryNode(queryNode)) {
context.report({
messageId,
node,
fix: isValidElement ? fix : undefined,
suggest: isValidElement ? undefined : [{
desc: `Replace ${matcher.name} with toHaveValue`,
fix
}]
fix(fixer) {
return [fixer.remove(context.getSourceCode().getTokenBefore(valueProp)), fixer.remove(valueProp), fixer.replaceText(matcher, "toHaveValue")];
}
});

@@ -94,20 +74,12 @@ }

const matcher = node.callee.property;
const {
isDTLQuery,
isValidElement
} = validateQueryNode(queryNode);
function fix(fixer) {
return [fixer.removeRange([context.getSourceCode().getTokenBefore(valueProp).range[0], valueProp.range[1]]), fixer.replaceText(matcher, "toHaveValue")];
}
if (isDTLQuery) {
if (isValidQueryNode(queryNode)) {
context.report({
messageId,
node,
fix: isValidElement ? fix : undefined,
suggest: isValidElement ? undefined : [{
desc: `Replace ${matcher.name} with toHaveValue`,
fix
}]
fix(fixer) {
return [fixer.removeRange([context.getSourceCode().getTokenBefore(valueProp).range[0], valueProp.range[1]]), fixer.replaceText(matcher, "toHaveValue")];
}
});

@@ -114,0 +86,0 @@ }

{
"name": "eslint-plugin-jest-dom",
"version": "3.6.4",
"version": "3.6.5",
"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",

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