Transition from ignoring JSHint

I run my code through JSHint and I push this error:

Expected break statement before case

In this block of code:

 switch(true) { // Renames skill1=abc to section_8_1_body=abc case Major === 0 && Minor === 0 && Patch < 433: upgraded = upgraded.replace(/(\s+)skill(\d)=/gm, '$1section_8_$2_body='); /*falls through*/ // Example case Major === 0 && Minor === 0 && Patch < 442: console.log('test'); /*falls through*/ } 

The code checks the version information for the file and updates it for compatibility with the latest software version. Therefore, he intends to skip case so that the file can be updated through several versions.

However, I still get the error message with the addition of /*falls through* , although it is supposedly valid .

How can I let my case succeed in JSHint?

+6
javascript jshint
Sep 25 '13 at 21:37
source share
1 answer

JSHint seems to expect the comment to be on the line before the case .

 // Example /* falls through */ case Major === 0 && Minor === 0 && Patch < 442: console.log('test'); 

As described in the source code, it will not otherwise recognize the comment:

 // You can tell JSHint that you don't use break intentionally by // adding a comment /* falls through */ on a line just before // the next `case`. 
+16
Sep 25 '13 at 21:53
source share



All Articles