Removing breaks from the last switch case, and just disabling the lint warning instead.

This commit is contained in:
Jeremy Ashkenas 2010-10-24 21:30:26 -04:00
parent 12b217c8ec
commit 017e3a156e
4 changed files with 7 additions and 6 deletions

View File

@ -11,7 +11,7 @@
-comma_separated_stmts # multiple statements separated by commas (use semicolons?)
+unreachable_code # unreachable code
+missing_break # missing break statement
+missing_break_for_last_case # missing break statement for last case in switch
-missing_break_for_last_case # missing break statement for last case in switch
-comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
+useless_void # use of the void type may be unnecessary (void is always undefined)

View File

@ -135,7 +135,6 @@
break;
default:
return 0;
break;
}
this.line += count(string, '\n');
return string.length;
@ -378,7 +377,6 @@
break;
case '::':
prev[0] = 'INDEX_PROTO';
break;
}
}
}

View File

@ -1596,7 +1596,6 @@
return '--';
default:
return pvar < 0 ? ' -= ' + pvar.slice(1) : ' += ' + pvar;
break;
}
})();
}
@ -1666,6 +1665,9 @@
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
}
code += block.compile(o, LEVEL_TOP) + '\n';
if (i === this.cases.length - 1 && !this.otherwise) {
break;
}
_ref5 = block.expressions;
for (_j = _ref5.length - 1; _j >= 0; _j--) {
expr = _ref5[_j];
@ -1678,7 +1680,7 @@
}
}
if (this.otherwise) {
code += idt1 + ("default:\n" + (this.otherwise.compile(o, LEVEL_TOP)) + "\n" + idt2 + "break;\n");
code += idt1 + ("default:\n" + (this.otherwise.compile(o, LEVEL_TOP)) + "\n");
}
return code + this.tab + '}';
};

View File

@ -1367,10 +1367,11 @@ exports.Switch = class Switch extends Base
cond = cond.invert() unless @subject
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
code += block.compile(o, LEVEL_TOP) + '\n'
break if i is @cases.length - 1 and not @otherwise
for expr in block.expressions by -1 when expr not instanceof Comment
code += idt2 + 'break;\n' unless expr instanceof Return
break
code += idt1 + "default:\n#{ @otherwise.compile o, LEVEL_TOP }\n#{idt2}break;\n" if @otherwise
code += idt1 + "default:\n#{ @otherwise.compile o, LEVEL_TOP }\n" if @otherwise
code + @tab + '}'
#### If