Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'semicolon-var-fix' of https://github.com/jeffjewiss/rollup
 into jeffjewiss-semicolon-var-fix
  • Loading branch information
Rich-Harris committed Aug 11, 2017
2 parents 1a3abf2 + 723f6a9 commit 11508c4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/nodes/VariableDeclaration.js
Expand Up @@ -98,7 +98,7 @@ export default class VariableDeclaration extends Node {
const needsSemicolon = !forStatement.test( this.parent.type );

if ( this.end > c ) {
code.overwrite( c, this.end, needsSemicolon ? ';' : '' );
code.overwrite( c, this.end, needsSemicolon ? ';' : '\n' );
} else if ( needsSemicolon ) {
this.insertSemicolon( code );
}
Expand Down
3 changes: 3 additions & 0 deletions test/form/line-wrap/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'use a newline for line wraps removing a necessary semicolon (#1275)'
};
6 changes: 6 additions & 0 deletions test/form/line-wrap/_expected/amd.js
@@ -0,0 +1,6 @@
define(function () { 'use strict';

for(var x=1;x<2;x++)var d=x|0
console.log(d);

});
4 changes: 4 additions & 0 deletions test/form/line-wrap/_expected/cjs.js
@@ -0,0 +1,4 @@
'use strict';

for(var x=1;x<2;x++)var d=x|0
console.log(d);
2 changes: 2 additions & 0 deletions test/form/line-wrap/_expected/es.js
@@ -0,0 +1,2 @@
for(var x=1;x<2;x++)var d=x|0
console.log(d);
7 changes: 7 additions & 0 deletions test/form/line-wrap/_expected/iife.js
@@ -0,0 +1,7 @@
(function () {
'use strict';

for(var x=1;x<2;x++)var d=x|0
console.log(d);

}());
10 changes: 10 additions & 0 deletions test/form/line-wrap/_expected/umd.js
@@ -0,0 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';

for(var x=1;x<2;x++)var d=x|0
console.log(d);

})));
1 change: 1 addition & 0 deletions test/form/line-wrap/main.js
@@ -0,0 +1 @@
for(var x=1;x<2;x++)var d=x|0;console.log(d);

0 comments on commit 11508c4

Please sign in to comment.