eslint-plugin-jest-dom 4.0.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -180,7 +180,7 @@ MIT
|
|
|
180
180
|
<!-- prettier-ignore-start -->
|
|
181
181
|
[npm]: https://www.npmjs.com
|
|
182
182
|
[node]: https://nodejs.org
|
|
183
|
-
[build-badge]: https://img.shields.io/github/workflow/status/testing-library/eslint-plugin-jest-dom/validate?logo=github&style=flat-square
|
|
183
|
+
[build-badge]: https://img.shields.io/github/actions/workflow/status/testing-library/eslint-plugin-jest-dom/validate.yml?logo=github&style=flat-square
|
|
184
184
|
[build]: https://github.com/testing-library/eslint-plugin-jest-dom/actions?query=workflow%3Avalidate
|
|
185
185
|
[coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/eslint-plugin-jest-dom.svg?style=flat-square
|
|
186
186
|
[coverage]: https://codecov.io/github/testing-library/eslint-plugin-jest-dom
|
|
@@ -196,6 +196,7 @@ MIT
|
|
|
196
196
|
[coc]: https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/other/CODE_OF_CONDUCT.md
|
|
197
197
|
[emojis]: https://github.com/all-contributors/all-contributors#emoji-key
|
|
198
198
|
[all-contributors]: https://github.com/all-contributors/all-contributors
|
|
199
|
+
[all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/eslint-plugin-jest-dom?style=flat-square
|
|
199
200
|
[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
|
|
200
201
|
[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
|
|
201
202
|
[good-first-issue]: 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+label%3A%22good+first+issue%22
|
package/dist/assignment-ast.js
CHANGED
|
@@ -12,17 +12,20 @@ var _queries = require("./queries");
|
|
|
12
12
|
* await someAsyncFunc() => someAsyncFunc()
|
|
13
13
|
* someElement as HTMLDivElement => someElement
|
|
14
14
|
*
|
|
15
|
+
* @param {Object} context - Context for a rule
|
|
15
16
|
* @param {Object} expression - An expression node
|
|
16
17
|
* @returns {Object} - A node
|
|
17
18
|
*/
|
|
18
|
-
function getInnerNodeFrom(expression) {
|
|
19
|
+
function getInnerNodeFrom(context, expression) {
|
|
19
20
|
switch (expression.type) {
|
|
21
|
+
case "Identifier":
|
|
22
|
+
return getAssignmentForIdentifier(context, expression.name);
|
|
20
23
|
case "TSAsExpression":
|
|
21
|
-
return getInnerNodeFrom(expression.expression);
|
|
24
|
+
return getInnerNodeFrom(context, expression.expression);
|
|
22
25
|
case "AwaitExpression":
|
|
23
|
-
return getInnerNodeFrom(expression.argument);
|
|
26
|
+
return getInnerNodeFrom(context, expression.argument);
|
|
24
27
|
case "MemberExpression":
|
|
25
|
-
return getInnerNodeFrom(expression.object);
|
|
28
|
+
return getInnerNodeFrom(context, expression.object);
|
|
26
29
|
default:
|
|
27
30
|
return expression;
|
|
28
31
|
}
|
|
@@ -42,7 +45,7 @@ function getAssignmentForIdentifier(context, identifierName) {
|
|
|
42
45
|
let assignmentNode;
|
|
43
46
|
if (init) {
|
|
44
47
|
// let foo = bar;
|
|
45
|
-
assignmentNode = getInnerNodeFrom(init);
|
|
48
|
+
assignmentNode = getInnerNodeFrom(context, init);
|
|
46
49
|
} else {
|
|
47
50
|
// let foo;
|
|
48
51
|
// foo = bar;
|
|
@@ -50,7 +53,7 @@ function getAssignmentForIdentifier(context, identifierName) {
|
|
|
50
53
|
if (!assignmentRef) {
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
|
-
assignmentNode = getInnerNodeFrom(assignmentRef.writeExpr);
|
|
56
|
+
assignmentNode = getInnerNodeFrom(context, assignmentRef.writeExpr);
|
|
54
57
|
}
|
|
55
58
|
return assignmentNode;
|
|
56
59
|
}
|
|
@@ -64,7 +67,7 @@ function getAssignmentForIdentifier(context, identifierName) {
|
|
|
64
67
|
* @returns {Object} - Object with query, queryArg & isDTLQuery
|
|
65
68
|
*/
|
|
66
69
|
function getQueryNodeFrom(context, nodeWithValueProp) {
|
|
67
|
-
const queryNode =
|
|
70
|
+
const queryNode = getInnerNodeFrom(context, nodeWithValueProp);
|
|
68
71
|
if (!queryNode || !queryNode.callee) {
|
|
69
72
|
return {
|
|
70
73
|
isDTLQuery: false,
|
|
@@ -13,7 +13,6 @@ var _assignmentAst = require("../assignment-ast");
|
|
|
13
13
|
//------------------------------------------------------------------------------
|
|
14
14
|
// Rule Definition
|
|
15
15
|
//------------------------------------------------------------------------------
|
|
16
|
-
|
|
17
16
|
const messageId = "use-to-have-class";
|
|
18
17
|
const meta = {
|
|
19
18
|
docs: {
|
|
@@ -102,7 +102,7 @@ const create = context => {
|
|
|
102
102
|
const startOfStyleMemberExpression = node.object.range[1];
|
|
103
103
|
const endOfStyleMemberExpression = node.parent.parent.arguments[0].range[1];
|
|
104
104
|
let fix = null;
|
|
105
|
-
if (typeof styleValue.value !== "number" && !(styleValue.value instanceof RegExp)) {
|
|
105
|
+
if (typeof styleValue.value !== "number" && !(styleValue.value instanceof RegExp) && styleName.type !== "Identifier") {
|
|
106
106
|
fix = fixer => {
|
|
107
107
|
return [fixer.removeRange([startOfStyleMemberExpression, endOfStyleMemberExpression]), fixer.replaceText(matcher, "toHaveStyle"), fixer.replaceText(styleValue, typeof styleName.value === "number" ? `{${getReplacementObjectProperty(styleValue)}: expect.anything()}` : getReplacementStyleParam(styleName, styleValue))];
|
|
108
108
|
};
|
|
@@ -120,7 +120,7 @@ const create = context => {
|
|
|
120
120
|
const matcher = node.parent.parent.parent.parent.property;
|
|
121
121
|
const endOfStyleMemberExpression = node.parent.parent.arguments[0].range[1];
|
|
122
122
|
let fix = null;
|
|
123
|
-
if (typeof styleName.value !== "number") {
|
|
123
|
+
if (typeof styleName.value !== "number" && styleName.type !== "Identifier") {
|
|
124
124
|
fix = fixer => {
|
|
125
125
|
return [fixer.removeRange([node.object.range[1], endOfStyleMemberExpression]), fixer.replaceText(matcher, "toHaveStyle"), fixer.replaceText(styleValue, getReplacementStyleParam(styleName, styleValue))];
|
|
126
126
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-jest-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "ESLint plugin to follow best practices and anticipate common mistakes when writing tests with jest-dom",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -42,20 +42,21 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "^7.16.3",
|
|
45
|
-
"@testing-library/dom": "^8.11.1",
|
|
46
45
|
"requireindex": "^1.2.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
48
|
+
"@testing-library/dom": "^8.20.0",
|
|
49
49
|
"@typescript-eslint/parser": "^5.9.1",
|
|
50
50
|
"eslint": "^8.7.0",
|
|
51
|
-
"eslint-doc-generator": "^0.
|
|
51
|
+
"eslint-doc-generator": "^1.0.0",
|
|
52
52
|
"eslint-remote-tester": "^3.0.0",
|
|
53
|
-
"eslint-remote-tester-repositories": "^
|
|
53
|
+
"eslint-remote-tester-repositories": "^1.0.1",
|
|
54
54
|
"kcd-scripts": "^12.0.0",
|
|
55
55
|
"typescript": "^4.5.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"eslint": "^6.8.0 || ^7.0.0 || ^8.0.0"
|
|
58
|
+
"eslint": "^6.8.0 || ^7.0.0 || ^8.0.0",
|
|
59
|
+
"@testing-library/dom": "^8.0.0 || ^9.0.0"
|
|
59
60
|
},
|
|
60
61
|
"eslintConfig": {
|
|
61
62
|
"extends": "./node_modules/kcd-scripts/eslint.js",
|