eslint-plugin-promise
Advanced tools
Comparing version 3.2.1 to 3.3.0
@@ -7,2 +7,4 @@ module.exports = { | ||
'catch-or-return': require('./rules/catch-or-return'), | ||
'prefer-await-to-callbacks': require('./rules/prefer-await-to-callbacks'), | ||
'prefer-await-to-then': require('./rules/prefer-await-to-then'), | ||
'no-native': require('./rules/no-native') | ||
@@ -9,0 +11,0 @@ }, |
{ | ||
"name": "eslint-plugin-promise", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Enforce best practices for JavaScript promises", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "^2.10 || ^3.0", | ||
"eslint": "^3.0", | ||
"mocha": "^2.3.4", | ||
@@ -22,0 +22,0 @@ "standard": "^7.1.2" |
@@ -55,2 +55,4 @@ # eslint-plugin-promise | ||
### Promise Rules | ||
- `catch-or-return` Enforces the use of `catch` on un-returned promises. | ||
@@ -62,3 +64,7 @@ - `no-return-wrap` Avoid wrapping values in `Promise.resolve` or `Promise.reject` when not needed. | ||
### Async/Await Rules | ||
- `prefer-await-to-then` Prefer `await` to `then()` for reading Promise values | ||
- `prefer-await-to-callbacks` Prefer async/await to the callback pattern | ||
### Rule: `catch-or-return` | ||
@@ -65,0 +71,0 @@ |
@@ -13,5 +13,5 @@ function isFunctionWithBlockStatement (node) { | ||
return ( | ||
node.type === 'CallExpression' && | ||
node.callee.type === 'MemberExpression' && | ||
node.callee.property.name === 'then' | ||
node.type === 'CallExpression' && | ||
node.callee.type === 'MemberExpression' && | ||
node.callee.property.name === 'then' | ||
) | ||
@@ -22,5 +22,5 @@ } | ||
return ( | ||
node.parent && | ||
node.parent.arguments && | ||
node.parent.arguments[0] === node | ||
node.parent && | ||
node.parent.arguments && | ||
node.parent.arguments[0] === node | ||
) | ||
@@ -31,5 +31,5 @@ } | ||
return ( | ||
isFunctionWithBlockStatement(node) && | ||
isThenCallExpression(node.parent) && | ||
isFirstArgument(node) | ||
isFunctionWithBlockStatement(node) && | ||
isThenCallExpression(node.parent) && | ||
isFirstArgument(node) | ||
) | ||
@@ -36,0 +36,0 @@ } |
@@ -14,22 +14,22 @@ /** | ||
return ( // hello.then() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.property.name === 'then' | ||
) || ( // hello.catch() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.property.name === 'catch' | ||
) || ( // somePromise.ANYTHING() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
isPromise(expression.callee.object) | ||
) || ( // Promise.STATIC_METHOD() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.object.type === 'Identifier' && | ||
expression.callee.object.name === 'Promise' && | ||
STATIC_METHODS.indexOf(expression.callee.property.name) !== -1 | ||
) | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.property.name === 'then' | ||
) || ( // hello.catch() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.property.name === 'catch' | ||
) || ( // somePromise.ANYTHING() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
isPromise(expression.callee.object) | ||
) || ( // Promise.STATIC_METHOD() | ||
expression.type === 'CallExpression' && | ||
expression.callee.type === 'MemberExpression' && | ||
expression.callee.object.type === 'Identifier' && | ||
expression.callee.object.name === 'Promise' && | ||
STATIC_METHODS.indexOf(expression.callee.property.name) !== -1 | ||
) | ||
} | ||
module.exports = isPromise |
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
35617
22
731
204