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

Prevent ASI errors for conditional expressions #3035

Merged
merged 2 commits into from Aug 7, 2019

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Aug 6, 2019

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #3019

Description

This will remove linebreaks before simplified statements if this would lead to an erroneous automatic semicolon insertion. The logic is in place for both return and break statements and checks for simplifications in conditional, logical and sequence expressions.

The logic only removes line-breaks but does not touch other non-code characters to retain (annotation?) comments in the best possible way.

@codecov
Copy link

codecov bot commented Aug 6, 2019

Codecov Report

Merging #3035 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3035      +/-   ##
==========================================
+ Coverage   88.65%   88.68%   +0.02%     
==========================================
  Files         165      165              
  Lines        5694     5708      +14     
  Branches     1738     1743       +5     
==========================================
+ Hits         5048     5062      +14     
  Misses        388      388              
  Partials      258      258
Impacted Files Coverage Δ
src/ast/nodes/SequenceExpression.ts 90% <100%> (+0.71%) ⬆️
src/ast/nodes/ThrowStatement.ts 100% <100%> (ø) ⬆️
src/ast/nodes/LogicalExpression.ts 95.71% <100%> (+0.12%) ⬆️
src/utils/renderHelpers.ts 94.44% <100%> (+0.59%) ⬆️
src/ast/nodes/ConditionalExpression.ts 94.52% <100%> (+0.15%) ⬆️
src/ast/nodes/ReturnStatement.ts 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 44a23bb...808d2da. Read the comment docs.

@lukastaegert lukastaegert marked this pull request as ready for review August 7, 2019 05:33
@lukastaegert
Copy link
Member Author

Seems like coverage display is a little off, possibly due to me messing around with master lately.

@lukastaegert lukastaegert changed the title [WIP] Prevent ASI errors for conditional expressions Prevent ASI errors for conditional expressions Aug 7, 2019
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.

Erroneous code generated
1 participant