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

WIP: Formatting test #415

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

WIP: Formatting test #415

wants to merge 8 commits into from

Conversation

anthmatic
Copy link
Contributor

Types of change

  • Bug fix (change which fixes an issue)
  • Enhancement (change which improves upon an existing feature)
  • New feature (change which adds new functionality)

Description

A clear and concise description of what the pull request is solving.

Relevant links

Example page:
GitHub issue:

Checklist

People to notify

{# First page link #}

{% if module.show_first_and_last_links == true %}
<a class="pagination__link pagination__link--first {{ "pagination__link--disabled" if not last_page_num }}">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missing template data

<nav aria-label="Pagination navigation" role="navigation" class="pagination">
{% set page_list = %}
{% if contents.total_page_count - current_page_num == 1 %}
{% set offset = %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indenting

{% if module.button_link.no_follow %}
{% do rel.append("nofollow") %}
{% dorel.append("nofollow") %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

space

{% endif %}
{% set rel = [] %}
{% set rel = %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

missing

name="{{ module.feature_icon.name }}"
purpose="decorative"
style="{{ module.feature_icon.type }}"
unicode="{{ module.feature_icon.unicode }}" %}{{ feature }}</li>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

weird formatting

{% if module.link.no_follow %}
{% do rel.append("nofollow") %}
{% dorel.append("nofollow") %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

space missing

@@ -4,141 +4,143 @@
<style>
{% scope_css %}

{# Features #}
{# Features #}
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'm thinking scoped css should never add indentation?

Copy link
Member

Choose a reason for hiding this comment

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

I'd be good with that rule 👍🏼 so maybe: indent for if statements but don't indent for HubL functions (e.g. require_css/scope_css) CC: @TanyaScales

@@ -4,141 +4,143 @@
<style>
{% scope_css %}

{# Features #}
{# Features #}
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'm thinking scoped css should never add indentation?

Comment on lines +17 to +18
[ {"social_account": "facebook-f"}, {"social_account": "linkedin-in"},
{"social_account": "twitter"}, {"social_account": "instagram"} ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

arrays shouldn't break

Comment on lines +17 to +18
[ {"social_account": "facebook-f"}, {"social_account": "linkedin-in"},
{"social_account": "twitter"}, {"social_account": "instagram"} ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

arrays shouldn't break

Comment on lines -145 to +147
{% set list_type = "small" %}
{% set list_type = "small" %}
{% elif module.layout_style == "list" %}
{% set list_type = "large" %}
{% set list_type = "large" %}
Copy link
Member

Choose a reason for hiding this comment

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

I would still expect the {% set %} lines to be indented inside of the if statement.

Current prettier formatting:

{% if module.layout_style == "card" %}
{% set list_type = "small" %}
{% elif module.layout_style == "list" %}
{% set list_type = "large" %}
{% endif %}

Previous and expected format:

{% if module.layout_style == "card" %}
  {% set list_type = "small" %}
{% elif module.layout_style == "list" %}
  {% set list_type = "large" %}
{% endif %}

Copy link
Member

Choose a reason for hiding this comment

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

Curious to hear @jasonnrosa thoughts on this, it appears this is a rule around all {% if %} statements

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I would also expect and much prefer the previous comment. Formatting of the first instance Tanya mentioned is much harder to read. In general we always prefer an indent within if statements.

Comment on lines +66 to +69
{% if module.link.open_in_new_tab %}target="_blank"
{% endif %}
{% if rel %}rel="{{ rel|join( ) }}"
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

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

This is odd formatting to me -- seems like this should stay on one line, or if following some of the other ways prettier is trying to format, the attribute should be on its own line:

{% if module.link.open_in_new_tab %}
  target="_blank"
{% endif %}

{% set menu = menu(module.menu, "site_root").children %}
{% set menu = %}
Copy link
Member

Choose a reason for hiding this comment

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

Missing/removed the value here

<li class="menu__item menu__item--depth-{{ depth }} {{ "menu__item--has-submenu" if link.children && depth < module.max_levels }} hs-skip-lang-url-rewrite">
<li class="menu__item menu__item--depth-depth {{ "menu__item--has-submenu" if link.children and depth < module.max_levels }} hs-skip-lang-url-rewrite">
Copy link
Member

Choose a reason for hiding this comment

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

Seems to have removed the brackets around depth in the class name:

menu__item menu__item--depth-{{ depth }} changed to menu__item menu__item--depth-depth

<span class="menu__child-toggle-icon"></span>
</button>
<ul class="menu__submenu menu__submenu--level-{{ depth + 1 }} no-list">
{% set depth = %}
Copy link
Member

Choose a reason for hiding this comment

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

Missing/removed depth + 1 here

Comment on lines -91 to +93
<a class="menu__link {{ "menu__link--toggle" if link.children && depth < module.max_levels }} {{ "menu__link--active-branch" if link.activeBranch }} {{ "menu__link--active-link" if link.activeNode }}" href="{{ link.url }}" {{ 'aria-haspopup="true" aria-expanded="false"' if link.children && depth < module.max_levels }} {{ 'aria-current="page"' if link.activeNode }} {{ 'target="_blank" rel="noopener"' if link.linkTarget }}>{{ link.label }}</a>
<a class="menu__link {{ "menu__link--toggle" if link.children and depth < module.max_levels }} {{ "menu__link--active-branch" if link.activeBranch }} {{ "menu__link--active-link" if link.activeNode }}" href="{{ link.url }}" {{ "aria-haspopup="true" aria-expanded="false"" if link.children and depth < module.max_levels }} {{ "aria-current="page"" if link.activeNode }} {{ "target="_blank" rel="noopener"" if link.linkTarget }}
>{{ link.label }}</a
>
Copy link
Member

Choose a reason for hiding this comment

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

Bit of strange formatting here, breaking the ending caret of the anchor tag to a new line on both the opening and closing tag

Copy link
Member

Choose a reason for hiding this comment

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

Also noticed that the quotes were changed here from single to double causing this line to break:

Original:

{{ 'target="_blank" rel="noopener"' if link.linkTarget }}

Change to:

{{ "target="_blank" rel="noopener"" if link.linkTarget }}

Copy link
Member

Choose a reason for hiding this comment

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

There are other instances of the single to double quotes as well in this line (and probably throughout this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah- Good catch! Will look into this


{# Tags #}
{# Tags #}
Copy link
Member

Choose a reason for hiding this comment

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

I think we have some extra spacing being added in here

Copy link
Member

Choose a reason for hiding this comment

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

This actually looks like it is across the board (looks like it might be pushing things in in some areas 4 spaces instead of 2).

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've noticed this in another scope_css block, are you noticing this in any other tags?

Normally we indent the body inside of a tag block, but because this is CSS (and we're not really parsing CSS) it might make sense to skip that first indent for scope_css

Comment on lines -97 to +95
{% set href = "mailto:" + href %}
{% set href = %}
Copy link
Member

Choose a reason for hiding this comment

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

missing here too

<hr class="card__hr">
<hr class="card__hr" />
Copy link
Member

Choose a reason for hiding this comment

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

not sure if we want self-closing tags to have their closing backslash removed - @jasonnrosa ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are coming straight from prettier and I believe that there is no option to override them. It definitely warrants another look, though.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I'd prefer to omit if possible but sounds like this obviously depends on prettier

Comment on lines -13 to -14
},
max_width={{ context.max_width || 700 }},
Copy link
Member

Choose a reason for hiding this comment

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

Seems to be removing the commas between the top level params.

Current

background_image={...}
max_width={{...}}
padding={...}
vertical_alignment="MIDDLE"

Expected:

background_image={...},
max_width={{...}},
padding={...},
vertical_alignment="MIDDLE"

{% endif %}
<article
class="blog-index__post blog-index__post--{{ list_type }}"
aria-label="Blog post summary: {{ content.name }}"
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason this is pushing attributes to their own line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prettier HTML formatter is handling HTML attributes, so this is expected behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also worth noting that prettier is really opinionated and the team does not accept requests for new options. More info on that here https://prettier.io/docs/en/option-philosophy.html

{% endif %}

{# Blog author listing header #}

{% if blog_author %}
<h2 class="blog-author-heading">{{ module.blog_author_listing.subheading }} {{ blog_author.display_name }}:</h2>
<h2 class="blog-author-heading">{{ module.blog_author_listing.subheading }} {{ blog_author.display_name }}:</h2>
Copy link
Member

Choose a reason for hiding this comment

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

Similar indenting issue

{% endif %}

{# Blog tag listing header #}

{% if tag %}
<h2 class="blog-tag-heading">{{ module.blog_tag_listing.subheading }} {{ page_meta.html_title|split(" | ")|last }}:</h2>
<h2 class="blog-tag-heading">{{ module.blog_tag_listing.subheading }} {{ page_meta.html_title|split(" | ")|last }}:</h2>
Copy link
Member

Choose a reason for hiding this comment

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

Similar indenting issue

{% endif %}
{% if module.button_link.open_in_new_tab %}
{% do rel.append("noopener") %}
{% dorel.append("noopener") %}
Copy link
Member

Choose a reason for hiding this comment

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

space

{% do rel.append("nofollow") %}
{# Sets attributes used for the link field #}

{% set href = %}
Copy link
Member

Choose a reason for hiding this comment

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

missing


{% set href = %}
{% if item.social_link.url.type == "EMAIL_ADDRESS" %}
{% set href = %}
Copy link
Member

Choose a reason for hiding this comment

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

missing

{% if item.social_link.url.type == "EMAIL_ADDRESS" %}
{% set href = %}
{% endif %}
{% set rel = %}
Copy link
Member

Choose a reason for hiding this comment

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

missing

{% endif %}
{% set rel = %}
{% if item.social_link.no_follow %}
{% dorel.append("nofollow") %}
Copy link
Member

Choose a reason for hiding this comment

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

space

{% dorel.append("nofollow") %}
{% endif %}
{% if item.social_link.open_in_new_tab %}
{% dorel.append("noopener") %}
Copy link
Member

Choose a reason for hiding this comment

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

space

{% set social_icon = %}
{% else %}
{% set social_icon = %}
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

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

missing values for two social_icon variables above

vertical_alignment="MIDDLE"
%}
}
vertical_alignment="MIDDLE" %}
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem to be allowing the closing tag being on its own line.

{% end_dnd_module %}
{% end_dnd_row %}
{% dnd_row %}
{% dnd_module
path="../modules/button",
button_text={{ context.button_text || "Get started" }},
path="../modules/button"
Copy link
Member

Choose a reason for hiding this comment

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

removed comma

"src": context.image or get_asset_url("../images/grayscale-mountain.png")
}
offset=0
width=6 %}
Copy link
Member

Choose a reason for hiding this comment

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

More missing commas above

offset=6,
width=6
%}
{% dnd_column offset=6 width=6 %}
Copy link
Member

Choose a reason for hiding this comment

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

Shifted these from being on their own lines with commas to being in one line with no comma

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing issue with commas.

In regards to going from multiple lines to single line, prettier will try to fit a tag on one line and only break if it doesn't fit. Curious if folks feel strongly about always breaking on new lines?

Copy link
Member

Choose a reason for hiding this comment

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

We typically always have HubL tags break params onto their own lines throughout all of our assets -- so, I generally do appreciate that formatting -- what I would like more is consistency -- so if you're saying that some HubL tags will break onto multiple lines because they are longer/have more params, and others won't because they are shorter, I don't really like them diverging like that

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I also much prefer them broken out onto multiple lines. I find it a lot easier to read separate parameters on their own lines vs. trying to read them all on one line (similar to CSS declarations).

pageEditor.appendChild(linkNode);
}
</script>
{% end_require_js %}
{% end_require_js %}
Copy link
Member

Choose a reason for hiding this comment

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

Would just want to make sure all of this JS formatting is expected

{{ require_css(get_asset_url("../../css/main.css")) }}
{# This is intended to be used if a template requires template specific style sheets #}
{#
<!-- This is intended to be used if a template requires template specific style sheets -->
Copy link
Member

Choose a reason for hiding this comment

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

Added HTML comment within HubL comment

{% endif %}
{{ require_css(get_asset_url("../../css/theme-overrides.css")) }}
{# To see a full list of what is included via standard_header_includes please reference this article: https://developers.hubspot.com/docs/cms/hubl/variables#required-page-template-variables #}
{#
<!-- To see a full list of what is included via standard_header_includes please reference this article: https://developers.hubspot.com/docs/cms/hubl/variables#required-page-template-variables -->
Copy link
Member

Choose a reason for hiding this comment

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

HTML within HubL comment

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.

3 participants