Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make return expressions of pure functions pure
- Loading branch information
1 parent
8daf05e
commit cc53d89
Showing
7 changed files
with
67 additions
and
37 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
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
module.exports = { | ||
solo: true, | ||
description: 'allows to manually declare functions as pure by name', | ||
options: { | ||
treeshake: { manualPureFunctions: ['foo', 'bar.a'] } | ||
} | ||
}; | ||
// TODO Lukas also tagged templates | ||
// TODO Lukas also check "this" or arguments are not deoptimized |
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
const lib = () => console.log(); | ||
lib.a = () => { | ||
console.log(); | ||
const result = () => console.log(); | ||
result.c = console.log; | ||
return result; | ||
const lib = { | ||
a: () => { | ||
console.log(); | ||
return () => { | ||
console.log(); | ||
return () => { | ||
console.log(); | ||
return console.log; | ||
} | ||
} | ||
} | ||
}; | ||
lib.a.b = () => console.log(); | ||
|
||
lib(); // not removed | ||
lib.b(); // not removed |
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 |
---|---|---|
@@ -1,11 +1,27 @@ | ||
import { lib as bar } from './other'; | ||
const foo = console.log; | ||
|
||
foo; // removed | ||
foo(); // removed | ||
bar.a(); // removed | ||
bar?.a(); // removed | ||
foo.a; // removed | ||
foo.a(); // removed | ||
foo.a()(); // removed | ||
foo.a().a; // removed | ||
foo.a().a(); // removed | ||
foo.a().a()(); // removed | ||
foo.a().a().a; // removed | ||
foo.a().a().a(); // removed | ||
|
||
bar(); // not removed | ||
bar.b(); // not removed | ||
|
||
bar.a.b(); // removed | ||
bar.a(); // removed | ||
bar?.a(); // removed | ||
bar.a.a; // removed | ||
bar.a.a(); // removed | ||
bar.a()(); //removed | ||
bar.a().a; //removed | ||
bar.a().a(); //removed | ||
bar.a()()(); //removed | ||
bar.a()().a; //removed | ||
bar.a()().a(); //removed | ||
|
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
export const lib = () => console.log(); | ||
lib.a = () => { | ||
console.log(); | ||
const result = () => console.log(); | ||
result.c = console.log; | ||
return result; | ||
export const lib = { | ||
a: () => { | ||
console.log(); | ||
return () => { | ||
console.log(); | ||
return () => { | ||
console.log(); | ||
return console.log; | ||
} | ||
} | ||
} | ||
}; | ||
lib.a.b = () => console.log(); |