-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1179 from kzc/drop-unused-inner-functions-and-cla…
…sses drop unused function and class declarations within functions
- Loading branch information
Showing
10 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'does not include unused inner functions and classes' | ||
}; |
25 changes: 25 additions & 0 deletions
25
test/form/unused-inner-functions-and-classes/_expected/amd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
define(function () { 'use strict'; | ||
|
||
function bar () { console.log("outer bar"); } | ||
|
||
|
||
|
||
function Baz() { | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
return bar(), bog; | ||
} | ||
|
||
bar(); | ||
var f = Baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
return MyClass; | ||
|
||
} | ||
|
||
console.log( getClass().name ); | ||
|
||
}); |
23 changes: 23 additions & 0 deletions
23
test/form/unused-inner-functions-and-classes/_expected/cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
function bar () { console.log("outer bar"); } | ||
|
||
|
||
|
||
function Baz() { | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
return bar(), bog; | ||
} | ||
|
||
bar(); | ||
var f = Baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
return MyClass; | ||
|
||
} | ||
|
||
console.log( getClass().name ); |
21 changes: 21 additions & 0 deletions
21
test/form/unused-inner-functions-and-classes/_expected/es.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function bar () { console.log("outer bar"); } | ||
|
||
|
||
|
||
function Baz() { | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
return bar(), bog; | ||
} | ||
|
||
bar(); | ||
var f = Baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
return MyClass; | ||
|
||
} | ||
|
||
console.log( getClass().name ); |
26 changes: 26 additions & 0 deletions
26
test/form/unused-inner-functions-and-classes/_expected/iife.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
function bar () { console.log("outer bar"); } | ||
|
||
|
||
|
||
function Baz() { | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
return bar(), bog; | ||
} | ||
|
||
bar(); | ||
var f = Baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
return MyClass; | ||
|
||
} | ||
|
||
console.log( getClass().name ); | ||
|
||
}()); |
29 changes: 29 additions & 0 deletions
29
test/form/unused-inner-functions-and-classes/_expected/umd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(factory()); | ||
}(this, (function () { 'use strict'; | ||
|
||
function bar () { console.log("outer bar"); } | ||
|
||
|
||
|
||
function Baz() { | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
return bar(), bog; | ||
} | ||
|
||
bar(); | ||
var f = Baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
return MyClass; | ||
|
||
} | ||
|
||
console.log( getClass().name ); | ||
|
||
}))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { foo, bar, bog, boo, baz } from './stuff'; | ||
|
||
bar(); | ||
var f = baz(); | ||
f(); | ||
|
||
function getClass () { | ||
class MyClass {} | ||
class UnusedInnerClass1 {} | ||
return MyClass; | ||
class UnusedInnerClass2 {} | ||
} | ||
|
||
class UnusedClass {} | ||
|
||
console.log( getClass().name ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function foo () { console.log("outer foo"); } | ||
export function bar () { console.log("outer bar"); } | ||
export function bog () { console.log("outer bog"); } | ||
export function boo () { console.log("outer boo"); } | ||
|
||
function Baz() { | ||
function foo () { console.log("inner foo"); } | ||
function bar () { console.log("inner bar"); } | ||
function bog () { console.log("inner bog"); } | ||
function boo () { console.log("inner boo"); } | ||
|
||
return bar(), bog; | ||
} | ||
|
||
export { Baz as baz }; |