Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
eslint-plugin-try-catch-failsafe
Advanced tools
Make sure to use try-catch to wrap up some dangerous actions!
Make sure to use try-catch to wrap up some dangerous actions!
Use package manager to install this plugin.
npm install --save-dev eslint-plugin-try-catch-failsafe
yarn add -D eslint-plugin-try-catch-failsafe
pnpm add -D eslint-plugin-try-catch-failsafe
Add this plugin to your ESLint configuration.
{
"extends": [
"plugin:try-catch-failsafe/default"
]
}
error
false
Make sure to use try-catch to wrap up JSON.parse
. Notice that the JSON.parse
in catch
or finally
block may also throw an error in JavaScript, so we should wrap them up too.
// ❌ Error
JSON.parse('{"foo": "bar"}');
// ❌ Error
try {
// some code that may throw an error
} catch (e) {
JSON.parse('{"foo": "bar"}');
}
// ❌ Error
try {
// some code that may throw an error
} finally {
JSON.parse('{"foo": "bar"}');
}
// ✅ OK
try {
JSON.parse('{"foo": "bar"}');
} catch (e) {
console.error(e);
}
// ✅ OK
try {
// some code that may throw an error
} finally {
try {
JSON.parse('{"foo": "bar"}');
} finally {}
}
If you are confident that the JSON.parse
will not throw an error, you can disable this rule.
error
false
Make sure to use try-catch to wrap up new URL()
. Notice that the new URL()
in catch
or finally
block may also throw an error in JavaScript, so we should wrap them up too.
// ❌ Error
new URL('');
// ❌ Error
try {
// some code that may throw an error
} catch (e) {
new URL('');
}
// ❌ Error
try {
// some code that may throw an error
} finally {
new URL('');
}
// ✅ OK
try {
new URL('');
} catch (e) {
console.error(e);
}
// ✅ OK
try {
// some code that may throw an error
} finally {
try {
new URL('');
} finally {}
}
If you are confident that the new URL()
will not throw an error, you can disable this rule.
FAQs
Make sure to use try-catch to wrap up some dangerous actions!
The npm package eslint-plugin-try-catch-failsafe receives a total of 13 weekly downloads. As such, eslint-plugin-try-catch-failsafe popularity was classified as not popular.
We found that eslint-plugin-try-catch-failsafe 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.