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

Provide no-empty option that allows empty catch blocks. #2187

Closed
ljharb opened this issue Mar 30, 2015 · 6 comments
Closed

Provide no-empty option that allows empty catch blocks. #2187

ljharb opened this issue Mar 30, 2015 · 6 comments
Labels
triage An ESLint team member will look at this issue soon

Comments

@ljharb
Copy link
Sponsor Contributor

ljharb commented Mar 30, 2015

I want to disallow empty blocks in general with the no-empty rule, but I do not want to disallow empty "catch" blocks.

I'd like an option that restores the pre-0.18.0 behavior of ignoring empty catch blocks.

Filing per discussion on #1841 (comment)

@nzakas nzakas added the triage An ESLint team member will look at this issue soon label Mar 30, 2015
@nzakas
Copy link
Member

nzakas commented Mar 30, 2015

We aren't going to restore the previous behavior. You can still allow empty catch blocks, you just need to add a comment inside. We made this change because it's easy to miss empty catch blocks that weren't intended to be empty.

Happy to discuss other augmentations of the rule that might help you out.

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented Mar 30, 2015

So var data; try { data = JSON.parse(json); } catch (e) {}, which is a very common pattern I've seen, necessitates a comment in that block? would /**/ work, or does the comment have to have content?

@nzakas
Copy link
Member

nzakas commented Mar 30, 2015

necessitates a comment in that block?

Yes.

would /**/ work, or does the comment have to have content?

With #2193 that comment will work.

@ljharb
Copy link
Sponsor Contributor Author

ljharb commented Mar 31, 2015

Thanks, #2193 makes this much easier for me. However, I'd still like an option that does ignore empty catch blocks, so I'd love this to remain open.

@doberkofler
Copy link
Contributor

@ljharb I generally understand your point with a breaking change and in the original #1841 discussion I actually opted for a separate (no-empty-catch) rule altogether. @nzakas convinced me, that keeping this a single rule makes more sense and I still think he was right. I would keep the behavior as it is now and am fine with relaxing the the need for a specific comment to any comment.

@nzakas
Copy link
Member

nzakas commented Mar 31, 2015

@ljharb thanks for your input. We've already made the other change you requested, so I'm considering the matter closed. I know you disagree with the decision, however, I've already explained the rationale. We have a lot of other issues to focus on now.

@nzakas nzakas closed this as completed Mar 31, 2015
@eslint eslint locked and limited conversation to collaborators Mar 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

3 participants