Skip to content
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

Indent if while for body when splits #159

Merged
merged 4 commits into from
Jun 20, 2019

Conversation

Janther
Copy link
Contributor

@Janther Janther commented Jun 13, 2019

while solving #138
I found that there's a mismatch between the AST for if (x) return true; and if (x) { return true; }.
Nonetheless, I found some benefits in the exercise of creating the feature so for the moment as a compromise, this PR indents the bodies of an IfStatement, ForStatement, and WhileStatement in case of them being too long.
I also added the case of forcing the indentation of a nested if.

// Before Prettier
if (a) if (b) return true; else return false; else if (c) break; else throw;

// After Prettier
if (a)
    if (b) return true;
    else return false;
else if (c) break;
else throw;

@codecov
Copy link

codecov bot commented Jun 13, 2019

Codecov Report

Merging #159 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #159      +/-   ##
==========================================
+ Coverage    98.2%   98.26%   +0.05%     
==========================================
  Files          66       66              
  Lines         446      461      +15     
  Branches       56       60       +4     
==========================================
+ Hits          438      453      +15     
  Misses          8        8
Impacted Files Coverage Δ
src/nodes/ForStatement.js 100% <100%> (ø) ⬆️
src/nodes/IfStatement.js 100% <100%> (ø) ⬆️
src/nodes/WhileStatement.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e100b69...0579c82. Read the comment docs.

Copy link
Member

@mattiaerre mattiaerre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apart for that small thing, this LGTM

@@ -1,38 +1,58 @@
/* eslint-disable implicit-arrow-linebreak */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't have these lines anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was waiting for #157 to be merged. now I rebased to master.

@Janther Janther force-pushed the feature/indent_if_while_for_body_when_splits branch from 72ad310 to 0579c82 Compare June 14, 2019 20:56
Copy link
Member

@mattiaerre mattiaerre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mattiaerre mattiaerre merged commit 432f4e4 into master Jun 20, 2019
@mattiaerre mattiaerre deleted the feature/indent_if_while_for_body_when_splits branch June 20, 2019 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants