eslint-plugin-jest-dom
Advanced tools
Comparing version 4.0.3 to 5.0.1
@@ -15,13 +15,16 @@ "use strict"; | ||
* | ||
* @param {Object} context - Context for a rule | ||
* @param {Object} expression - An expression node | ||
* @returns {Object} - A node | ||
*/ | ||
function getInnerNodeFrom(expression) { | ||
function getInnerNodeFrom(context, expression) { | ||
switch (expression.type) { | ||
case "Identifier": | ||
return getAssignmentForIdentifier(context, expression.name); | ||
case "TSAsExpression": | ||
return getInnerNodeFrom(expression.expression); | ||
return getInnerNodeFrom(context, expression.expression); | ||
case "AwaitExpression": | ||
return getInnerNodeFrom(expression.argument); | ||
return getInnerNodeFrom(context, expression.argument); | ||
case "MemberExpression": | ||
return getInnerNodeFrom(expression.object); | ||
return getInnerNodeFrom(context, expression.object); | ||
default: | ||
@@ -46,3 +49,3 @@ return expression; | ||
// let foo = bar; | ||
assignmentNode = getInnerNodeFrom(init); | ||
assignmentNode = getInnerNodeFrom(context, init); | ||
} else { | ||
@@ -55,3 +58,3 @@ // let foo; | ||
} | ||
assignmentNode = getInnerNodeFrom(assignmentRef.writeExpr); | ||
assignmentNode = getInnerNodeFrom(context, assignmentRef.writeExpr); | ||
} | ||
@@ -70,3 +73,3 @@ return assignmentNode; | ||
function getQueryNodeFrom(context, nodeWithValueProp) { | ||
const queryNode = nodeWithValueProp.type === "Identifier" ? getAssignmentForIdentifier(context, nodeWithValueProp.name) : getInnerNodeFrom(nodeWithValueProp); | ||
const queryNode = getInnerNodeFrom(context, nodeWithValueProp); | ||
if (!queryNode || !queryNode.callee) { | ||
@@ -73,0 +76,0 @@ return { |
@@ -16,3 +16,2 @@ "use strict"; | ||
//------------------------------------------------------------------------------ | ||
const messageId = "use-to-have-class"; | ||
@@ -19,0 +18,0 @@ const meta = { |
@@ -105,3 +105,3 @@ "use strict"; | ||
let fix = null; | ||
if (typeof styleValue.value !== "number" && !(styleValue.value instanceof RegExp)) { | ||
if (typeof styleValue.value !== "number" && !(styleValue.value instanceof RegExp) && styleName.type !== "Identifier") { | ||
fix = fixer => { | ||
@@ -124,3 +124,3 @@ return [fixer.removeRange([startOfStyleMemberExpression, endOfStyleMemberExpression]), fixer.replaceText(matcher, "toHaveStyle"), fixer.replaceText(styleValue, typeof styleName.value === "number" ? `{${getReplacementObjectProperty(styleValue)}: expect.anything()}` : getReplacementStyleParam(styleName, styleValue))]; | ||
let fix = null; | ||
if (typeof styleName.value !== "number") { | ||
if (typeof styleName.value !== "number" && styleName.type !== "Identifier") { | ||
fix = fixer => { | ||
@@ -127,0 +127,0 @@ return [fixer.removeRange([node.object.range[1], endOfStyleMemberExpression]), fixer.replaceText(matcher, "toHaveStyle"), fixer.replaceText(styleValue, getReplacementStyleParam(styleName, styleValue))]; |
{ | ||
"name": "eslint-plugin-jest-dom", | ||
"version": "4.0.3", | ||
"version": "5.0.1", | ||
"description": "ESLint plugin to follow best practices and anticipate common mistakes when writing tests with jest-dom", | ||
@@ -45,11 +45,11 @@ "main": "dist/index.js", | ||
"@babel/runtime": "^7.16.3", | ||
"@testing-library/dom": "^8.11.1", | ||
"requireindex": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/dom": "^8.20.0", | ||
"@typescript-eslint/parser": "^5.9.1", | ||
"eslint": "^8.7.0", | ||
"eslint-doc-generator": "^0.19.0", | ||
"eslint-doc-generator": "^1.0.0", | ||
"eslint-remote-tester": "^3.0.0", | ||
"eslint-remote-tester-repositories": "^0.0.7", | ||
"eslint-remote-tester-repositories": "^1.0.1", | ||
"kcd-scripts": "^12.0.0", | ||
@@ -59,3 +59,4 @@ "typescript": "^4.5.3" | ||
"peerDependencies": { | ||
"eslint": "^6.8.0 || ^7.0.0 || ^8.0.0" | ||
"eslint": "^6.8.0 || ^7.0.0 || ^8.0.0", | ||
"@testing-library/dom": "^8.0.0 || ^9.0.0" | ||
}, | ||
@@ -62,0 +63,0 @@ "eslintConfig": { |
@@ -183,3 +183,3 @@ <div align="center"> | ||
[node]: https://nodejs.org | ||
[build-badge]: https://img.shields.io/github/workflow/status/testing-library/eslint-plugin-jest-dom/validate?logo=github&style=flat-square | ||
[build-badge]: https://img.shields.io/github/actions/workflow/status/testing-library/eslint-plugin-jest-dom/validate.yml?logo=github&style=flat-square | ||
[build]: https://github.com/testing-library/eslint-plugin-jest-dom/actions?query=workflow%3Avalidate | ||
@@ -200,2 +200,3 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/eslint-plugin-jest-dom.svg?style=flat-square | ||
[all-contributors]: https://github.com/all-contributors/all-contributors | ||
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/eslint-plugin-jest-dom?style=flat-square | ||
[bugs]: https://github.com/testing-library/eslint-plugin-jest-dom/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug | ||
@@ -202,0 +203,0 @@ [requests]: https://github.com/testing-library/eslint-plugin-jest-dom/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement |
79706
1270
204
8
+ Added@testing-library/dom@9.3.4(transitive)
- Removed@testing-library/dom@^8.11.1
- Removed@testing-library/dom@8.20.1(transitive)
- Removedacorn@8.11.3(transitive)