Merge pull request #2608 from amasad/compact-remove-semi

No need for semicolons at the end of the block in compact mode
This commit is contained in:
Sebastian McKenzie 2015-10-28 00:14:28 +00:00
commit 5c514bfa75
4 changed files with 16 additions and 2 deletions

View File

@ -84,6 +84,7 @@ export default class Buffer {
rightBrace() {
this.newline(true);
if (this.format.compact) this._removeLast(";");
this.push("}");
}
@ -114,8 +115,11 @@ export default class Buffer {
removeLast(cha) {
if (this.format.compact) return;
if (!this.isLast(cha)) return;
return this._removeLast(cha);
}
_removeLast(cha) {
if (!this._isLast(cha)) return;
this.buf = this.buf.substr(0, this.buf.length - 1);
this.position.unshift(cha);
}
@ -298,7 +302,10 @@ export default class Buffer {
isLast(cha) {
if (this.format.compact) return false;
return this._isLast(cha);
}
_isLast(cha) {
var buf = this.buf;
var last = buf[buf.length - 1];

View File

@ -0,0 +1,6 @@
function foo() {
if (bar) {
baz();
}
return;
}

View File

@ -0,0 +1 @@
function foo(){if(bar){baz()}return}

View File

@ -1,4 +1,4 @@
function foo(l){
return (
l);}
l)}