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
no-case-declarations examples are very similar and hard to distinguish #6716
no-case-declarations examples are very similar and hard to distinguish #6716
Comments
@philiiiiiipp Thanks for reporting this-- at a quick glance I have to agree that there's a problem. Just wondering, why did you close this? |
Never mind, I see it-- it's the braces. The point is that That's extremely subtle and I think it could be improved. I'm going to reopen the issue, if that's okay. EDIT: Oh, and I edited the title. Sorry, I just really want to make sure this gets addressed without any more silly questions being asked 😄 |
@platinumazure how would you improve the examples? |
@nzakas A couple of things come to mind:
Also in general, I would simplify the examples by having only one switch/case (or default) per example declaration, so that it's easier to tell what is different. Right now, there are two big switch statements and literally 6 brace characters are the only difference-- even the variable names, switch values, etc. are the same. Okay if I try to show what I mean with a PR? |
I am not sure if I find it any better or worse to use only one case, since multiple cases are the more likely real world example. |
@platinumazure sounds good, feel free to open a PR (documentation improvements are always welcome). I also think that the introduction could be expanded to include an example or two -- right now it's pretty bare. @philiiiiiipp we don't have to worry about violating other rules because we don't know which ones a user will have enabled. |
I can try to pick this up, as I would like to start contributing to eslint, this sounds like a good introduction to the eslint-project. If no-one is busy with it of course. As for the change in documentation. Would you prefer 1 single example and explaining with comments, which is good an bad? |
@rangelke Thanks for contributing! There's no hard and fast rule for how to arrange the examples. Personally, I think the second option (a different example for each of the cases) sounds like it would be clearer, but anything that clearly indicates what the rule is doing would be fine. |
Alright. I'll take this on me then! I have to setup the project first though! |
@rangelke Thanks! You can always drop by our gitter chat if you need help setting anything up. |
Hey,
looking at http://eslint.org/docs/rules/no-case-declarations#rule-details I cannot really see the difference between correct and incorrect code. Either I am missing something or the declarations should be removed there.
The text was updated successfully, but these errors were encountered: