Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove exception value in try..catch, if it's not used #1507

Open
shoonia opened this issue Mar 16, 2024 · 2 comments
Open

Remove exception value in try..catch, if it's not used #1507

shoonia opened this issue Mar 16, 2024 · 2 comments

Comments

@shoonia
Copy link

shoonia commented Mar 16, 2024

Feature request

Remove exception value in try..catch, if it's not used.

function isValidJSON(text) {
  try {
    JSON.parse(text);
    return true;
-  } catch (error) {
+  } catch {
    return false;
  }
}
@ehoogeveen-medweb
Copy link

Good idea :) Optional catch binding is an ES2019 feature, so would need to be gated behind ecma: 2019 or higher:
https://compat-table.github.io/compat-table/es2016plus/
https://caniuse.com/mdn-javascript_statements_try_catch_optional_catch_binding

@fabiosantoscode
Copy link
Collaborator

The ecma option is poorly understood, so I believe it could catch some people by surprise. I think a new option is needed, defaulted to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants