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

eslint-plugin-try-catch-failsafe

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-try-catch-failsafe - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

lib/rules/new-url.js

15

package.json
{
"name": "eslint-plugin-try-catch-failsafe",
"version": "0.1.3",
"version": "0.1.4",
"description": "Make sure to use try-catch to wrap up some dangerous actions!",
"main": "lib/index.js",
"scripts": {
"build": "rm -rf lib && swc src -d lib",
"prepack": "pnpm build",
"test": "ts-mocha tests/**/*.spec.ts"
},
"dependencies": {

@@ -42,3 +37,7 @@ "requireindex": "^1.2.0"

],
"license": "MIT"
}
"license": "MIT",
"scripts": {
"build": "rm -rf lib && swc src -d lib",
"test": "ts-mocha tests/**/*.spec.ts"
}
}

@@ -21,4 +21,4 @@ # eslint-plugin-try-catch-failsafe

{
"plugins": [
"try-catch-failsafe"
"extends": [
"plugin:try-catch-failsafe/default"
]

@@ -73,1 +73,45 @@ }

If you are confident that the `JSON.parse` will not throw an error, you can disable this rule.
### try-catch-failsafe/new-url
- **Default**: `error`
- **Fixable**: `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.
```js
// ❌ 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.
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