New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jshint should not require break before default: if default: is first in switch() statement #490

Closed
sergey-s-s opened this Issue Mar 23, 2012 · 2 comments

Comments

Projects
None yet
4 participants
@sergey-s-s
Copy link

sergey-s-s commented Mar 23, 2012

Example:

switch(x) {
default: xxx();
break;
case 0: yyy();
break;
case 1: zzz();
break;
}

Error:

            <issue line="1" char="11" reason="Expected a &apos;break&apos; statement before &apos;default&apos;." evidence="switch(x) {" />
@goatslacker

This comment has been minimized.

Copy link
Member

goatslacker commented Mar 23, 2012

Accepted.

@WolfgangKluge

This comment has been minimized.

Copy link
Contributor

WolfgangKluge commented Mar 23, 2012

In addition: I think we should add a style warning (in jshint.next) if defaultis not the last block ;)

@valueof valueof closed this in 6213412 Dec 7, 2012

jugglinmike added a commit to jugglinmike/jshint that referenced this issue Oct 21, 2014

Smarter warning about missing 'break'.
It's unnecessary to warn about missing 'break' before 'default'
when 'default' is the first switch statement:

	switch (name) {
	default: // No need to warn here.
		doSomething();
		break;
	case "Kamol":
		doSomethingElse();
	}

Closes jshintGH-490.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment