Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-promise

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-promise - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

rules/prefer-await-to-callbacks.js

2

index.js

@@ -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 @@ },

4

package.json
{
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc