-
Notifications
You must be signed in to change notification settings - Fork 82
feat: add functionExpression.flatIife option
#781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
053e166
feat: add `functionExpression.indentInsideIife` option
bartlomieju 703d900
revert unrelated import reordering from rustfmt
bartlomieju ce46e9f
revert unrelated rustfmt reformatting of if/else blocks
bartlomieju 0b3c271
Various fixes
dsherret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
94 changes: 94 additions & 0 deletions
94
tests/specs/expressions/FunctionExpression/FunctionExpression_IndentInsideIife_False.txt
This file contains hidden or 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,94 @@ | ||
| ~~ functionExpression.indentInsideIife: false ~~ | ||
| == should not indent body of IIFE == | ||
| (function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| [expect] | ||
| (function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| == should not indent body of named IIFE == | ||
| (function init() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| [expect] | ||
| (function init() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| == should not indent body of IIFE with args == | ||
| (function(x) { | ||
| const a = x; | ||
| return { a }; | ||
| })(42); | ||
|
|
||
| [expect] | ||
| (function(x) { | ||
| const a = x; | ||
| return { a }; | ||
| })(42); | ||
|
|
||
| == should still indent body of regular function expression == | ||
| const fn = function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| }; | ||
|
|
||
| [expect] | ||
| const fn = function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| }; | ||
|
|
||
| == should still indent body of function expression in call argument == | ||
| call(function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| }); | ||
|
|
||
| [expect] | ||
| call(function() { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| }); | ||
|
|
||
| == should not affect arrow function IIFE == | ||
| (() => { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| [expect] | ||
| (() => { | ||
| const a = "foobar"; | ||
| return { a }; | ||
| })(); | ||
|
|
||
| == should handle IIFE with nested function == | ||
| (function() { | ||
| function inner() { | ||
| return 1; | ||
| } | ||
| return inner(); | ||
| })(); | ||
|
|
||
| [expect] | ||
| (function() { | ||
| function inner() { | ||
| return 1; | ||
| } | ||
| return inner(); | ||
| })(); | ||
|
|
||
| == should handle empty IIFE == | ||
| (function() {})(); | ||
|
|
||
| [expect] | ||
| (function() {})(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.