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

Fallthrough is not allowed when adding comment above switch case #1196

Open
dsherret opened this issue Sep 9, 2023 · 3 comments · May be fixed by #1275
Open

Fallthrough is not allowed when adding comment above switch case #1196

dsherret opened this issue Sep 9, 2023 · 3 comments · May be fixed by #1275
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dsherret
Copy link
Member

dsherret commented Sep 9, 2023

I often do stuff like this:

switch (something) {
  case 1:
  // some comment about case 2
  case 2:
    console.log(1);
    break;
  default:
    console.log(2);
    break;
}

There is no fallthrough here, but deno lint warns about it because of the comment on line 3

@dsherret
Copy link
Member Author

dsherret commented Sep 9, 2023

Just looked into this and it seems to be explicitly not allowed here: https://github.com/denoland/deno_lint/blob/main/src/rules/no_fallthrough.rs#L271

Eslint seems to only allow it when setting allowEmptyCase (https://eslint.org/docs/latest/rules/no-fallthrough#allowemptycase).

I would argue that the empty case is a formatting concern (the formatter will collapse it) and adding a comment here is mostly used to document a case. With the rule as-is there's no way to document why a specific case exists in a list of cases without adding a deno-lint-ignore comment at the top, so I think we should just allow this because I'm not sure what problem it's trying to prevent.

@lucacasonato
Copy link
Member

We should allow it.

@bartlomieju bartlomieju added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels May 10, 2024
@koh28
Copy link

koh28 commented May 13, 2024

May I work on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants