I'm running my code through JSHint, and I'm hitting this error:
Expected a
break
statement beforecase
On 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 version information for a file, and upgrades it to be compatible with the latest version of the software. It's therefore intentional for the case
s to fall through, so that a file can be upgraded through multiple versions.
However, I still receive the error message, with /*falls through*
added, even though it is supposedly valid.
How can I allow my case
s to fall through successfully in JSHint?
JSHint seems to expect the comment to be on the line right before the case
.
// Example
/* falls through */
case Major === 0 && Minor === 0 && Patch < 442:
console.log('test');
According to the description in the source code, it won't acknowledge the comment otherwise:
// 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`.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With