eslint-plugin-try-catch-failsafe
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9718
7
160
116