From 731cce5fb408bc46ab27a7f1edb0eabee59bed0b Mon Sep 17 00:00:00 2001 From: Yash Masani Date: Sat, 21 Oct 2023 15:02:36 -0400 Subject: [PATCH] feat: add error docs for E0423 --- docs/errors/E0423.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docs/errors/E0423.md diff --git a/docs/errors/E0423.md b/docs/errors/E0423.md new file mode 100644 index 0000000000..367619122d --- /dev/null +++ b/docs/errors/E0423.md @@ -0,0 +1,29 @@ +# E0423: missing fallthrough comment in switch case + +Switch Cases in javascript fallthrough to the next case if the `break` statement is not added at the end of the case. +Since there is no explicit way of communication whether the fallthrough is intentional or not, it is recommended to use a comment indicating fallthrough. + +```javascript +function test (c) { + switch (c) { + case 1: + foo(); + default: + bar(); + } +} +``` + +To fix this error, place a comment at the end of `case 1` indicating fallthrough + +```javascript +function test (c) { + switch (c) { + case 1: + foo(); + //fallthrough + default: + bar(); + } +} +```