PolymerElements / iron-component-page

A reusable landing page for elements
36 stars 32 forks source link

Automatic format! #153

Closed e111077 closed 6 years ago

e111077 commented 6 years ago

Runs the experimental autoformatter webmat which runs clang-format on js files and makes it so that it can run on HTML files. Please look through this PR with ?w=1 in the diff to make sure that no logic was changed.

What has changed? You can run the formatter on the whole project by running npm run format and ex/include files from the formatter, and enter your custom clang-format config in a formatconfig.json see webmat readme for more

web-padawan commented 6 years ago

Wow! This looks impressive. It has been a while since my request to prettier for the <script> tags support and now there is an alternative.

@e111077 could you explain, what are the benefits of using clang-format as compared to prettier for JS? Or is the clang-format just a Google standard for TS which you decided to also follow in Polymer? I'm just curious, and would be grateful for some reading regarding best practices etc.

e111077 commented 6 years ago

Heya, we are using clang-format simply because it uses google's style guide and conforms to our internal code specifications.

Additionally our tools team already used clang-format and we didn't want to fragment our tooling. We also looked at prettier and may decide eventually to switch over.

Links: Google JS styleguide Google TS formatter (which is basically just clang-format)