Bug 1391699 - Disallow fallthrough case statements. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Fri, 18 Aug 2017 18:55:56 +0100
changeset 649146 9f737b5e441979c25a7f650e58ca166f8beba817
parent 649145 978f68c17245c37283a3635629efff66d2cdcba9
child 727016 951dd1d0e9d69e63ce25035452924e56ed19a276
push id74965
push userbmo:ato@sny.no
push dateFri, 18 Aug 2017 17:59:22 +0000
reviewersautomatedtester
bugs1391699, 1254136
milestone57.0a1
Bug 1391699 - Disallow fallthrough case statements. r?automatedtester We recently had a serious bug in Marionette (https://bugzil.la/1254136) due to a case statement that fell through due to a missing "break" statement. This patch introduces a lint rule to prevent similar episodes in the future. When you do want a case to fall through, it is possible to add a comment like this: switch (foo) { case 1: doSomething(); // fall through case 2: doSomething(); break; } MozReview-Commit-ID: Gu8cFGsdne2
testing/marionette/.eslintrc.js
--- a/testing/marionette/.eslintrc.js
+++ b/testing/marionette/.eslintrc.js
@@ -8,14 +8,15 @@ module.exports = {
       "FunctionExpression": {"body": 1, "parameters": 2},
       "MemberExpression": 2,
       "SwitchCase": 1,
     }],
     "max-len": ["error", 78, {
       "ignoreStrings": true,
       "ignoreUrls": true,
     }],
+    "no-fallthrough": "error",
     "no-new-object": "error",
     "no-undef-init": "error",
     "object-curly-spacing": ["error", "never"],
     "semi": "error",
   }
 };