You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add reportUnusedFallthroughComment option to no-fallthrough rule (#18188)
* feat: (no-fallthrough) Report unused fallthrough comments
fixes#18182
* add space
* add a few test cases to ensure state doesn't leak across multiple switches
* add correct case in docs
* fix leaked state
* Fix docs typo
Co-authored-by: Milos Djermanovic <[email protected]>
* add some test coverage
---------
Co-authored-by: Milos Djermanovic <[email protected]>
Copy file name to clipboardExpand all lines: docs/src/rules/no-fallthrough.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -178,6 +178,8 @@ This rule has an object option:
178
178
179
179
* Set the `allowEmptyCase` option to `true` to allow empty cases regardless of the layout. By default, this rule does not require a fallthrough comment after an empty `case` only if the empty `case` and the next `case` are on the same line or on consecutive lines.
180
180
181
+
* Set the `reportUnusedFallthroughComment` option to `true` to prohibit a fallthrough comment from being present if the case cannot fallthrough due to being unreachable. This is mostly intended to help avoid misleading comments occurring as a result of refactoring.
182
+
181
183
### commentPattern
182
184
183
185
Examples of **correct** code for the `{ "commentPattern": "break[\\s\\w]*omitted" }` option:
@@ -235,6 +237,60 @@ switch(foo){
235
237
236
238
:::
237
239
240
+
### reportUnusedFallthroughComment
241
+
242
+
Examples of **incorrect** code for the `{ "reportUnusedFallthroughComment": true }` option:
If you don't want to enforce that each `case` statement should end with a `throw`, `return`, `break`, or comment, then you can safely turn this rule off.
0 commit comments