no-undef not reported in switch case block
See original GitHub issueTell us about your environment
- ESLint Version: 4.19.1
- Node Version: 10.7.0
- npm Version: 6.4.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
switch (1) {
case 0:
const x = 1;
break;
case 1:
console.log(x);
break;
}
eslint test.js
What did you expect to happen?
error ‘x’ is not defined no-undef
What actually happened? Please include the actual, raw output from ESLint. no error
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
enable rule no-case-declarations to prevent usage of ... - GitHub
During refactoring, var x was removed which triggers two no-undef errors. First error is solved with let x = 1 but that makes...
Read more >ESLint/Nodejs: Error linting due to default switch case
js file using ESLint I received a an unexpected lexical declaration (no-case declarations) error. c:\>eslint C:\modules\myFile.js 503:17 error ...
Read more >The switch Statement (The Java™ Tutorials > Learning the ...
The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one...
Read more >DCL41-C. Do not declare variables inside a switch statement ...
Using test conditions or initializing variables before the first case statement in a switch block can result in unexpected behavior and undefined behavior....
Read more >Disallow Use of undefined Variable (no-undefined) - ESLint
The undefined variable in JavaScript is actually a property of the global object. As such, in ECMAScript 3 it was possible to overwrite...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is intended to be caught by
no-case-declarations
. The ReferenceErrors are resulting from a temporal dead zone reference toy
, becausey
is declared in scope but is read before the declaration is executed.The team has determined that this behavior is working as intended, so closing this issue.