Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
eslint-plugin-should-promised
Advanced tools
Eslint rule for checking that should-promised assertions return
Eslint rule for checking that should-promised assertions return
$ npm i -D eslint-plugin-should-promised
{
"plugins": [
"should-promised"
],
"rules": {
"should-promised/return-promise": 2
}
}
This rule is intended to be used with the should assertion library.
When testing an async function by returning a promise to mocha it is important to remember to actually return the promise. Forgetting to return will cause the test case to pass even if the promise is eventually rejected.
This rule will point out when a should assertion is made without returning.
This rule looks for any of the properties Promise
, fulfilled
, fulfilledWith
, rejected
, rejectedWith
, finally
and eventually
.
The following patterns are considered warnings:
describe('forgetting to return the promise', () => {
it('should report when not returning the promise from should.be.fulfilled', () => {
promiseFn().should.be.fulfilled();
});
it('should report when not returning the promise from should.eventually', () => {
promiseFn().should.eventually.eql(1);
});
});
These patterns would not be considered warnings:
describe('returning the promise', () => {
it('should not report when returning the promise from should.be.fulfilled', () => {
return promiseFn().should.be.fulfilled();
});
it('should allow implicit return in a single expression arrow function', () =>
promiseFn().should.be.fulfilled());
it('should not report when using async/await', async () => {
await promiseFn().should.eventually.eql(expected_value);
});
it('should not report when using a generator function', function * () {
yield generatorFn().should.eventually.eql(expected_value);
});
});
FAQs
Eslint rule for checking that should-promised assertions return
The npm package eslint-plugin-should-promised receives a total of 1,348 weekly downloads. As such, eslint-plugin-should-promised popularity was classified as popular.
We found that eslint-plugin-should-promised demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.