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

Make generated each code more consistent #3504

Merged
merged 2 commits into from
Sep 5, 2019

Conversation

Swatinem
Copy link
Member

@Swatinem Swatinem commented Sep 4, 2019

While looking at the generated code of each blocks, I noticed that there were some wild inconsistencies:

  • some blocks had proper braces and indentations, others didn’t
  • some loops used var, others used let
  • some loops were missing either, which was super confusing

To clean this up, I:

  • changed all (expect one) case to use braces and indentations
  • changed all loops to use let
  • I added a comment explaining whats going on for the one case where a loop was relying on a previous value.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

@codecov-io
Copy link

codecov-io commented Sep 4, 2019

Codecov Report

Merging #3504 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3504   +/-   ##
=======================================
  Coverage   50.25%   50.25%           
=======================================
  Files           1        1           
  Lines         197      197           
=======================================
  Hits           99       99           
  Misses         98       98

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 c6b53b6...f41bbad. Read the comment docs.

@Rich-Harris
Copy link
Member

@Swatinem! long time no see dude!

Thanks, I think this is better. It adds four bytes for each time i needs to get re-declared, but it'll come out in the gzip wash, and I think we should probably get round to replacing some of those for loops with helpers anyway for the sake of code size

@Rich-Harris Rich-Harris merged commit cc10714 into sveltejs:master Sep 5, 2019
@Swatinem
Copy link
Member Author

Swatinem commented Sep 5, 2019

@Swatinem! long time no see dude!

glad you remember :-)

we should probably get round to replacing some of those for loops with helpers anyway for the sake of code size

I was actually surprised to see it is still done this way. I was also expecting a helper similar to HtmlTag. Maybe I will do that when I am motivated for another coding spree :-D

@antony
Copy link
Member

antony commented Sep 5, 2019

❤️ braces for all

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.

4 participants