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

eslint-plugin-jasmine

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jasmine - npm Package Compare versions

Comparing version 2.10.0 to 2.10.1

15

docs/rules/no-promise-without-done-fail.md

@@ -37,2 +37,8 @@ # Disallow using promise without a done.fail (no-promise-without-done-fail).

it('A spec', function() {
asyncCall().then(done.fail, onError);
});
});
describe('A suite', function(done) {
it('A spec', function() {
asyncCall().then(function() {

@@ -44,2 +50,11 @@ expect(true).toBe(true);

});
describe('A suite', function(done) {
it('A spec', function() {
asyncCall().then(done.fail).catch(function() {
expect(true).toBe(true);
done();
});
});
});
```

11

lib/rules/no-promise-without-done-fail.js

@@ -15,4 +15,3 @@ 'use strict'

function hasDoneFailInReject (node, asyncParam) {
var reject = node.arguments[1]
function hasDoneFail (reject, asyncParam) {
return reject &&

@@ -24,6 +23,12 @@ reject.type === 'MemberExpression' &&

function hasDoneFailArgument (node, asyncParam) {
var resolve = node.arguments[0]
var reject = node.arguments[1]
return hasDoneFail(resolve, asyncParam) || hasDoneFail(reject, asyncParam)
}
function isPromiseThenWithoutCatch (node, asyncParam) {
return hasIdentifier(node, 'then') &&
!hasIdentifier(node.parent.parent, 'then') &&
!hasDoneFailInReject(node, asyncParam) &&
!hasDoneFailArgument(node, asyncParam) &&
!hasIdentifier(node.parent.parent, 'catch')

@@ -30,0 +35,0 @@ }

@@ -54,3 +54,3 @@ {

},
"version": "2.10.0"
"version": "2.10.1"
}

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

{
code: 'it("", function (done) { asyncFunc.then(done.fail, done);})'
},
{
code: 'it("should not care about the name of the first parameter", function (finished) { somethingAsync().then(finished, finished.fail);});'

@@ -41,2 +44,5 @@ },

{
code: 'it("", (done) => { asyncFunc.then(done.fail, done);})'
},
{
code: 'it("should not care about the name of the first parameter", (finished) => { somethingAsync().then(finished, finished.fail);});'

@@ -56,2 +62,8 @@ },

{
code: 'it("", function(done) { somethingAsync.then(undefined, function(err) { expect(err).toBe(true); done(); }) })',
errors: [{
message: 'An "it" that uses an async method should handle failure (use "done.fail")'
}]
},
{
code: 'it("", function(done) { somethingAsync.then(f).then(function(res) { expect(res).toBe(true); done(); }) })',

@@ -58,0 +70,0 @@ errors: [{

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