@fintechstudios/eslint-plugin-chai-as-promised
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -0,1 +1,6 @@ | ||
# [3.0.2](https://github.com/fintechstudios/eslint-plugin-chai-as-promised/compare/v3.0.1...v3.0.2) (2020-03-30) | ||
#### Fixes | ||
* no-await-in-condition: avoid error on Promise.all without array (#15) | ||
# [3.0.1](https://github.com/fintechstudios/eslint-plugin-chai-as-promised/compare/v3.0.0...v3.0.1) (2020-03-23) | ||
@@ -2,0 +7,0 @@ |
@@ -9,2 +9,9 @@ 'use strict'; | ||
const PromiseAllSelector = 'CallExpression' + | ||
'[callee.type="MemberExpression"]' + | ||
'[callee.object.name="Promise"]' + | ||
'[callee.object.type="Identifier"]' + | ||
'[callee.property.name="all"]' + | ||
'[callee.property.type="Identifier"]'; | ||
function checkHasAwait (context, node) { | ||
@@ -21,2 +28,5 @@ const [ | ||
':matches(.arguments[type="AwaitExpression"], .object[type="AwaitExpression"])' | ||
).length && !esquery( | ||
chaiCall.parent.parent, | ||
PromiseAllSelector | ||
).length) { | ||
@@ -53,12 +63,7 @@ context.report({ | ||
}, | ||
[ | ||
// Promise.all([...]) | ||
'CallExpression' + | ||
'[callee.type="MemberExpression"]' + | ||
'[callee.object.name="Promise"]' + | ||
'[callee.object.type="Identifier"]' + | ||
'[callee.property.name="all"]' + | ||
'[callee.property.type="Identifier"]' | ||
](node) { | ||
[PromiseAllSelector](node) { | ||
const [arrayExpression] = esquery(node, '.arguments[type="ArrayExpression"]'); | ||
if (!arrayExpression) { | ||
return; | ||
} | ||
arrayExpression.elements.some((element) => { | ||
@@ -65,0 +70,0 @@ return checkHasAwait(context, element); |
@@ -49,3 +49,5 @@ 'use strict'; | ||
`expect(func()).to.be.rejectedWith(Error, 'No good!') | ||
` | ||
`, | ||
'expect(Promise.all(arr)).to.eventually.be.true', | ||
'expect(Promise.all(await prom)).to.be.fulfilled' | ||
] | ||
@@ -52,0 +54,0 @@ ).map(function (code) { |
{ | ||
"name": "@fintechstudios/eslint-plugin-chai-as-promised", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Prevent common problems when using chai-as-promised", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
24885
366