Socket
Socket
Sign inDemoInstall

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.0.0 to 3.1.0

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 3.0.1
- Removed deprecated `always-catch` rule
- FIX: always-return error with "fn && fn()"
## 3.0.0
- Updated column and line numbers
- Added flow analysis for better handling of if statements
## 2.0.1

@@ -2,0 +12,0 @@

2

index.js

@@ -5,3 +5,2 @@ module.exports = {

'always-return': require('./rules/always-return'),
'always-catch': require('./rules/always-catch'),
'catch-or-return': require('./rules/catch-or-return'),

@@ -13,3 +12,2 @@ 'no-native': require('./rules/no-native')

'always-return': 1,
'always-catch': 1,
'no-native': 0,

@@ -16,0 +14,0 @@ 'catch-or-return': 1

{
"name": "eslint-plugin-promise",
"version": "3.0.0",
"version": "3.1.0",
"description": "Enforce best practices for JavaScript promises",

@@ -5,0 +5,0 @@ "keywords": [

@@ -18,4 +18,2 @@ # eslint-plugin-promise

Formerly called `always-catch`.
#### Valid

@@ -50,2 +48,12 @@

This is useful for many non-standard Promise implementations.
You can also pass an array of methods such as
`{ terminationMethod: ['catch', 'asCallback', 'finally'] }`.
This will allow any of
```js
Promise.resolve(1).then(() => { throw new Error('oops') }).catch(logerror)
Promise.resolve(1).then(() => { throw new Error('oops') }).asCallback(cb)
Promise.resolve(1).then(() => { throw new Error('oops') }).finally(cleanUp)
```

@@ -149,3 +157,2 @@ ### `always-return`

"promise/always-return": 2,
"promise/always-catch": 2, // deprecated
"promise/catch-or-return": 2,

@@ -152,0 +159,0 @@ "promise/no-native": 0,

@@ -107,6 +107,13 @@ function isFunctionWithBlockStatement (node) {

var finalBranchIDs = path.finalSegments.map(x => x.id)
finalBranchIDs.forEach((id) => {
path.finalSegments.forEach((segment) => {
var id = segment.id
var branch = funcInfo.branchInfoMap[id]
if (!branch.good) {
// check shortcircuit syntax like `x && x()` and `y || x()``
var prevSegments = segment.prevSegments
for (var ii = prevSegments.length - 1; ii >= 0; --ii) {
var prevSegment = prevSegments[ii]
if (funcInfo.branchInfoMap[prevSegment.id].good) return
}
context.report({

@@ -113,0 +120,0 @@ message: 'Each then() should return a value or throw',

@@ -36,2 +36,6 @@ var STATIC_METHODS = [

if (typeof terminationMethod === 'string') {
terminationMethod = [terminationMethod]
}
return {

@@ -56,3 +60,3 @@ ExpressionStatement: function (node) {

node.expression.callee.type === 'MemberExpression' &&
node.expression.callee.property.name === terminationMethod
terminationMethod.indexOf(node.expression.callee.property.name) !== -1
) {

@@ -59,0 +63,0 @@ return

@@ -27,3 +27,5 @@ 'use strict'

{ code: 'hey.then(x => { return x; var y = "unreachable"; })', parserOptions: parserOptions },
{ code: 'hey.then(x => { return; }, err=>{ log(err); })', parserOptions: parserOptions }
{ code: 'hey.then(x => { return; }, err=>{ log(err); })', parserOptions: parserOptions },
{ code: 'hey.then(x => { return x && x(); }, err=>{ log(err); })', parserOptions: parserOptions },
{ code: 'hey.then(x => { return x.y || x(); }, err=>{ log(err); })', parserOptions: parserOptions }
],

@@ -30,0 +32,0 @@

@@ -18,2 +18,5 @@ 'use strict'

// arrow function use case
{ code: 'postJSON("/smajobber/api/reportJob.json")\n\t.then(()=>this.setState())\n\t.catch(()=>this.setState())', parserOptions: { ecmaVersion: 6 } },
// return

@@ -46,4 +49,8 @@ 'function a() { return frank().then(go) }',

// terminationMethod=done - .done(null, fn)
{ code: 'frank().then(go).done()', options: [{ 'terminationMethod': 'done' }] }
{ code: 'frank().then(go).done()', options: [{ 'terminationMethod': 'done' }] },
// terminationMethod=[catch, done] - .done(null, fn)
{ code: 'frank().then(go).catch()', options: [{ 'terminationMethod': ['catch', 'done'] }] },
{ code: 'frank().then(go).done()', options: [{ 'terminationMethod': ['catch', 'done'] }] },
{ code: 'frank().then(go).finally()', options: [{ 'terminationMethod': ['catch', 'finally'] }] }
],

@@ -50,0 +57,0 @@

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