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

eslint-plugin-should-promised

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-should-promised - npm Package Compare versions

Comparing version 1.0.8 to 2.0.0

58

lib/rules/return-promise.js
'use strict';
var assertion_properties = [
'Promise',
'fulfilled',
'fulfilledWith',
'rejected',
'rejectedWith',
'finally',
'eventually'
];
function isPromiseAssertionProperty(property) {
var name = property && (property.name || property.value);
return name && assertion_properties.indexOf(name) !== -1;
const name = property && (property.name || property.value);
return name === 'Promise' ||
name === 'fulfilled' ||
name === 'fulfilledWith' ||
name === 'rejected' ||
name === 'rejectedWith' ||
name === 'finally' ||
name === 'eventually';
}
function ancestorReturns(parents) {
for (var i = parents.length - 1; i >= 0; i--) {
var parent = parents[i];
var type = parent.type;
if (type === 'ReturnStatement' || type === 'YieldExpression') {
for (let i = parents.length - 1; i >= 0; i--) {
let parent = parents[i];
let type = parent.type;
if (type === 'ReturnStatement' || type === 'AwaitExpression' || type === 'YieldExpression') {
return true;

@@ -36,16 +32,22 @@ }

module.exports = function(context) {
return {
MemberExpression: function(node) {
if (!isPromiseAssertionProperty(node.property)) {
return;
}
module.exports = {
meta: {
docs: {}
},
if (ancestorReturns(context.getAncestors(node))) {
return;
create(context) {
return {
MemberExpression(node) {
if (!isPromiseAssertionProperty(node.property)) {
return;
}
if (ancestorReturns(context.getAncestors(node))) {
return;
}
context.report(node.property, 'Promise assertion must return, await or yield.');
}
context.report(node.property, 'Promise assertion must return or await.');
}
};
};
}
};
{
"name": "eslint-plugin-should-promised",
"version": "1.0.8",
"description": "Eslint rule for checking that should-promised assertions return",
"main": "index.js",
"files": [
"index.js",
"lib"
],
"scripts": {
"test": "istanbul cover _mocha -- --recursive --reporter spec",
"coveralls": "cat ./coverage/lcov.info | coveralls"
"test": "jest --coverage",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},

@@ -14,9 +17,13 @@ "peerDependencies": {

"devDependencies": {
"babel-eslint": "^4.1.8",
"coveralls": "^2.11.6",
"eslint": "^2.0.0",
"is-my-json-valid": "^2.12.4",
"istanbul": "^0.4.2",
"mocha": "^2.4.5"
"eslint": "^3.9.0",
"jest": "^16.0.2",
"semantic-release": "^4.3.5"
},
"jest": {
"testEnvironment": "node"
},
"engines": {
"node": ">=4",
"npm": ">=3"
},
"repository": {

@@ -37,3 +44,4 @@ "type": "git",

"promise"
]
}
],
"version": "2.0.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