mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Removing breaks from the last switch case, and just disabling the lint warning instead.
This commit is contained in:
parent
12b217c8ec
commit
017e3a156e
4 changed files with 7 additions and 6 deletions
|
@ -11,7 +11,7 @@
|
||||||
-comma_separated_stmts # multiple statements separated by commas (use semicolons?)
|
-comma_separated_stmts # multiple statements separated by commas (use semicolons?)
|
||||||
+unreachable_code # unreachable code
|
+unreachable_code # unreachable code
|
||||||
+missing_break # missing break statement
|
+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 !==)
|
-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
|
-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)
|
+useless_void # use of the void type may be unnecessary (void is always undefined)
|
||||||
|
|
|
@ -135,7 +135,6 @@
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
this.line += count(string, '\n');
|
this.line += count(string, '\n');
|
||||||
return string.length;
|
return string.length;
|
||||||
|
@ -378,7 +377,6 @@
|
||||||
break;
|
break;
|
||||||
case '::':
|
case '::':
|
||||||
prev[0] = 'INDEX_PROTO';
|
prev[0] = 'INDEX_PROTO';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1596,7 +1596,6 @@
|
||||||
return '--';
|
return '--';
|
||||||
default:
|
default:
|
||||||
return pvar < 0 ? ' -= ' + pvar.slice(1) : ' += ' + pvar;
|
return pvar < 0 ? ' -= ' + pvar.slice(1) : ' += ' + pvar;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@ -1666,6 +1665,9 @@
|
||||||
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
|
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
|
||||||
}
|
}
|
||||||
code += block.compile(o, LEVEL_TOP) + '\n';
|
code += block.compile(o, LEVEL_TOP) + '\n';
|
||||||
|
if (i === this.cases.length - 1 && !this.otherwise) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
_ref5 = block.expressions;
|
_ref5 = block.expressions;
|
||||||
for (_j = _ref5.length - 1; _j >= 0; _j--) {
|
for (_j = _ref5.length - 1; _j >= 0; _j--) {
|
||||||
expr = _ref5[_j];
|
expr = _ref5[_j];
|
||||||
|
@ -1678,7 +1680,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.otherwise) {
|
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 + '}';
|
return code + this.tab + '}';
|
||||||
};
|
};
|
||||||
|
|
|
@ -1367,10 +1367,11 @@ exports.Switch = class Switch extends Base
|
||||||
cond = cond.invert() unless @subject
|
cond = cond.invert() unless @subject
|
||||||
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
|
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
|
||||||
code += block.compile(o, LEVEL_TOP) + '\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
|
for expr in block.expressions by -1 when expr not instanceof Comment
|
||||||
code += idt2 + 'break;\n' unless expr instanceof Return
|
code += idt2 + 'break;\n' unless expr instanceof Return
|
||||||
break
|
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 + '}'
|
code + @tab + '}'
|
||||||
|
|
||||||
#### If
|
#### If
|
||||||
|
|
Loading…
Add table
Reference in a new issue