eslint-plugin-testing-library
Advanced tools
Comparing version 1.3.1 to 1.3.2
'use strict'; | ||
const { getDocsUrl, ALL_QUERIES_METHODS } = require('../utils'); | ||
const { findParent, getDocsUrl, ALL_QUERIES_METHODS } = require('../utils'); | ||
@@ -10,3 +10,3 @@ const ALL_GET_BY_QUERIES = ALL_QUERIES_METHODS.map( | ||
const findCallExpressionParent = node => | ||
node.type === 'CallExpression' ? node : findCallExpressionParent(node.parent); | ||
findParent(node, node => node.type === 'CallExpression'); | ||
@@ -23,3 +23,4 @@ const isValidQuery = (node, customQueryNames = []) => | ||
const isDeclared = node => node.parent.type === 'VariableDeclarator'; | ||
const isDeclared = node => | ||
!!findParent(node, node => node.type === 'VariableDeclarator'); | ||
@@ -29,2 +30,7 @@ const isReturnedByReturnStatement = node => | ||
const isInDestructuringStatement = node => | ||
(node.parent.type === 'Property' && | ||
node.parent.parent.type === 'ObjectPattern') || | ||
node.parent.type === 'ArrayPattern'; | ||
module.exports = { | ||
@@ -69,2 +75,3 @@ meta: { | ||
isValidQuery(node, customQueryNames) && | ||
!isInDestructuringStatement(node) && | ||
!isDirectlyCalledByFunction(callExpressionNode) && | ||
@@ -71,0 +78,0 @@ !isReturnedByArrowFunctionExpression(callExpressionNode) && |
@@ -51,3 +51,14 @@ 'use strict'; | ||
const findParent = (node, cb) => { | ||
if (cb(node)) { | ||
return node; | ||
} else if (node.parent) { | ||
return findParent(node.parent, cb); | ||
} | ||
return null; | ||
}; | ||
module.exports = { | ||
findParent, | ||
getDocsUrl, | ||
@@ -54,0 +65,0 @@ SYNC_QUERIES_VARIANTS, |
{ | ||
"name": "eslint-plugin-testing-library", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "ESLint rules for Testing Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -175,3 +175,3 @@ <div align="center"> | ||
<td align="center"><a href="https://aarongarciah.com"><img src="https://avatars0.githubusercontent.com/u/7225802?v=4" width="100px;" alt="Aarón García Hervás"/><br /><sub><b>Aarón García Hervás</b></sub></a><br /><a href="https://github.com/Belco90/eslint-plugin-testing-library/commits?author=aarongarciah" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://www.matej.snuderl.si/"><img src="https://avatars3.githubusercontent.com/u/8524109?v=4" width="100px;" alt="Matej Šnuderl"/><br /><sub><b>Matej Šnuderl</b></sub></a><br /><a href="#ideas-Meemaw" title="Ideas, Planning, & Feedback">🤔</a></td> | ||
<td align="center"><a href="https://www.matej.snuderl.si/"><img src="https://avatars3.githubusercontent.com/u/8524109?v=4" width="100px;" alt="Matej Šnuderl"/><br /><sub><b>Matej Šnuderl</b></sub></a><br /><a href="#ideas-Meemaw" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/Belco90/eslint-plugin-testing-library/commits?author=Meemaw" title="Documentation">📖</a></td> | ||
</tr> | ||
@@ -178,0 +178,0 @@ </table> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32083
618