-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Option Proposal: for no-unused-vars
, add exceptions
and exceptionsIgnorePattern
options
#3837
Comments
Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. |
Looks good, let's do it. |
@nzakas Should we just make the default behavior to flag args inside catch statements and People who do not want to flag that can use |
I don't see a reason to introduce a breaking change for this. It flags things inside |
I know you hate those … but I love to see this 😘 |
@mischah Issue is accepted, so if you want to write a pull request, have at it! It's like somebody said (I forget who, maybe Gandhi?), "Be the change you wish to see in the world". So he probably would have also said "If you want something, write it yourself" 😁 |
I am working on this , will create a pull request for review shortly |
Update: Add 'caughtErrors' to rule no-unused-vars (fixes #3837)
Thanks for this feature, but I needed this for function names. It works for variables, given the provided "catch (ignoreErr)" example. But doesn't work for functions, say for example: function ignoreTest() { }. I was expecting this "no-unused-vars" exceptions solution to work for functions too, since eslint is showing my unused function error as a "no-unused-vars" error. |
Following from the discussion in #3543, I propose the addition of options to the
no-unused-vars
rule, allowing us to specify how we want to handle exception variables defined in thecatch()
clause of a try/catch statement.Currently, the documentation doesn't address this, and the rule allows caught exception variables to remain unused, even when the
"all"
settings are used for the current options (tested via ESLint 1.4.3, though this behavior was also present in previous versions):Therefore, I propose the addition of
exceptions
andexceptionsIgnorePattern
options, mirroring the functionality of thevars
/varsIgnorePattern
andargs
/argsIgnorePattern
options. Valid settings forexceptions
would be:none
- the default, matches the current behavior of not reporting any unused exception variablesall
- reports all unused exception variables, aside from those matchingexceptionsIgnorePattern
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: