Browse Source

prevent superfluous semi-colons causing whitespace to collapse after functions declarations

better-aggressive
Rich Harris 9 years ago
parent
commit
dded04d414
  1. 2
      src/Module.js
  2. 4
      test/form/spacing-after-function-with-semicolon/_config.js
  3. 7
      test/form/spacing-after-function-with-semicolon/_expected/amd.js
  4. 5
      test/form/spacing-after-function-with-semicolon/_expected/cjs.js
  5. 3
      test/form/spacing-after-function-with-semicolon/_expected/es6.js
  6. 7
      test/form/spacing-after-function-with-semicolon/_expected/iife.js
  7. 11
      test/form/spacing-after-function-with-semicolon/_expected/umd.js
  8. 3
      test/form/spacing-after-function-with-semicolon/main.js

2
src/Module.js

@ -436,6 +436,8 @@ export default class Module {
let commentIndex = 0;
ast.body.forEach( node => {
if ( node.type === 'EmptyStatement' ) return;
// special case - top-level var declarations with multiple declarators
// should be split up. Otherwise, we may end up including code we
// don't need, just because an unwanted declarator is included

4
test/form/spacing-after-function-with-semicolon/_config.js

@ -0,0 +1,4 @@
module.exports = {
solo: true,
description: 'handles superfluous semicolons'
};

7
test/form/spacing-after-function-with-semicolon/_expected/amd.js

@ -0,0 +1,7 @@
define(function () { 'use strict';
function x () { return 'x' };
assert.equal( x(), 'x' );
});

5
test/form/spacing-after-function-with-semicolon/_expected/cjs.js

@ -0,0 +1,5 @@
'use strict';
function x () { return 'x' };
assert.equal( x(), 'x' );

3
test/form/spacing-after-function-with-semicolon/_expected/es6.js

@ -0,0 +1,3 @@
function x () { return 'x' };
assert.equal( x(), 'x' );

7
test/form/spacing-after-function-with-semicolon/_expected/iife.js

@ -0,0 +1,7 @@
(function () { 'use strict';
function x () { return 'x' };
assert.equal( x(), 'x' );
})();

11
test/form/spacing-after-function-with-semicolon/_expected/umd.js

@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(this, function () { 'use strict';
function x () { return 'x' };
assert.equal( x(), 'x' );
}));

3
test/form/spacing-after-function-with-semicolon/main.js

@ -0,0 +1,3 @@
function x () { return 'x' };
assert.equal( x(), 'x' );
Loading…
Cancel
Save