question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autofix for no-unused-vars "caughtErrors: all"

See original GitHub issue

The version of ESLint you are using. 5.16

The problem you want to solve.

We currently have to manually fix caughtErrors: all errors even when we give "ecmaVersion": 2019.

Your take on the correct solution to problem.

ESLint could automatically fix this by removing catch bindings.

Are you willing to submit a pull request to implement this change?

Yes if I learn how to implement an autofix.

This is basically #10434 but based on the existing rule.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
not-an-aardvarkcommented, Apr 22, 2019

We generally only autofix a rule when we’re sure of what the user intended to do. With no-unused-vars, sometimes an unused variable indicates that the user has a bug in their code because they meant to use the variable. So if we “fix” the problem by deleting the variable, we might end up just concealing the bug because the problem will no longer be brought to the user’s attention.

3reactions
arcaniscommented, May 21, 2019

Could that be enabled via an explicit option of the rule?

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
The no-unused-vars rule is one of the most important ESLint rules for ... 3 No-Unused-Vars caughtErrors: Require Catch to Use All Named Vars....
Read more >
ESLint - Configuring "no-unused-vars" for TypeScript
VS Code, using eslint, was giving me warnings about unused variables in my type declarations for function callbacks. These options, added to my ......
Read more >
Improving the User Experience for Unused Variables : r/Zig
By fixing the unused variable errors in the code, you can now work with --autofix on all the time and your users will...
Read more >
Fix most of the remaining no-unused-vars issues for local ...
This fixes most of the no-unused-vars for local scope in browser/. There's only a handful of issues left, but they either need other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found