Enable no-case-declarations lint rule
Lexical declarations in `case` and `default` clauses are a footgun,
since they are visible in the entire switch block, but they only
get initialized upon assignment, which only happens if the relevant
`case` is actually reached.
To ensure that such lexical declarations only apply to the current
`case` (which is usually the intention), `case` clauses containing
them should be wrapped in curly braces to create an explicit block.
More information:
https://eslint.org/docs/rules/no-case-declarations
Change-Id: I63d9341fcd76d4b9ce8281bd0e6573b886577f08
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2119685
Reviewed-by: Tim van der Lippe <[email protected]>
Commit-Queue: Mathias Bynens <[email protected]>
diff --git a/.eslintrc.js b/.eslintrc.js
index 915b7cd..18adb3d 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -49,6 +49,7 @@
// anti-patterns
'no-caller': 2,
+ 'no-case-declarations': 2,
'no-cond-assign': 2,
'no-console': [2, {'allow': ['assert', 'context', 'error', 'timeStamp', 'time', 'timeEnd', 'warn']}],
'no-debugger': 2,