diff --git a/.all-contributorsrc b/.all-contributorsrc
index 538d9fa8..2fbd11ca 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -74,7 +74,8 @@
"avatar_url": "https://avatars3.githubusercontent.com/u/8524109?v=4",
"profile": "https://www.matej.snuderl.si/",
"contributions": [
- "ideas"
+ "ideas",
+ "doc"
]
}
],
diff --git a/README.md b/README.md
index 5d795f44..a4784192 100644
--- a/README.md
+++ b/README.md
@@ -172,7 +172,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Ben Monro 💻 📖 ⚠️ |
 Nicola Molinari 💻 ⚠️ 📖 👀 |
 Aarón García Hervás 📖 |
-  Matej Šnuderl 🤔 |
+  Matej Šnuderl 🤔 📖 |
diff --git a/lib/rules/prefer-explicit-assert.js b/lib/rules/prefer-explicit-assert.js
index 60331c67..64e3f2c5 100644
--- a/lib/rules/prefer-explicit-assert.js
+++ b/lib/rules/prefer-explicit-assert.js
@@ -24,6 +24,12 @@ const isDeclared = node => node.parent.type === 'VariableDeclarator';
const isReturnedByReturnStatement = node =>
node.parent.type === 'ReturnStatement';
+const isInDestructuringStatement = node =>
+ (node.parent.type === 'Property' &&
+ node.parent.parent.type === 'ObjectPattern') ||
+ (node.parent.type === 'ArrayPattern' &&
+ node.parent.parent.type === 'VariableDeclarator');
+
module.exports = {
meta: {
type: 'suggestion',
@@ -63,6 +69,7 @@ module.exports = {
if (
isValidQuery(node, customQueryNames) &&
+ !isInDestructuringStatement(node) &&
!isDirectlyCalledByFunction(callExpressionNode) &&
!isReturnedByArrowFunctionExpression(callExpressionNode) &&
!isDeclared(callExpressionNode) &&
diff --git a/tests/lib/rules/prefer-explicit-assert.js b/tests/lib/rules/prefer-explicit-assert.js
index 9ca26f79..936a6667 100644
--- a/tests/lib/rules/prefer-explicit-assert.js
+++ b/tests/lib/rules/prefer-explicit-assert.js
@@ -16,7 +16,7 @@ ruleTester.run('prefer-explicit-assert', rule, {
},
{
code: `const utils = render()
-
+
utils.getByText
`,
},
@@ -25,7 +25,7 @@ ruleTester.run('prefer-explicit-assert', rule, {
},
{
code: `const utils = render()
-
+
expect(utils.getByText('foo')).toBeDefined()
`,
},
@@ -50,6 +50,15 @@ ruleTester.run('prefer-explicit-assert', rule, {
{
code: `getByIcon('foo')`, // custom `getBy` query not extended through options
},
+ {
+ code: `const { getByText } = render()`,
+ },
+ {
+ code: `it('test', () => { const { getByText } = render() })`,
+ },
+ {
+ code: `it('test', () => { const [ getByText ] = render() })`,
+ },
],
invalid: [