Skip to content

A platform for community discussion. Free, open, simple.

DEV: Configure prettier for hbs templates

David Taylor104a16610a17
diff --git a/.prettierignore b/.prettierignore
index b33a5618e4d..93b35f929e2 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -26,7 +26,6 @@ dist/
tmp/
**/*.rb
-**/*.hbs
**/*.html
**/*.json
**/*.md
diff --git a/.template-lintrc.js b/.template-lintrc.js
index b50cdcb5fdc..a5c4998a0ce 100644
--- a/.template-lintrc.js
+++ b/.template-lintrc.js
@@ -21,5 +21,11 @@ module.exports = {
"no-implicit-this": {
allow: ["loading-spinner"],
},
+ // Begin prettier compatibility
+ "eol-last": false,
+ "self-closing-void-elements": false,
+ "block-indentation": false,
+ quotes: false,
+ // End prettier compatibility
},
};
diff --git a/app/assets/javascripts/discourse/app/components/google-icon.hbs b/app/assets/javascripts/discourse/app/components/google-icon.hbs
new file mode 100644
index 00000000000..3750fb734cb
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/google-icon.hbs
@@ -0,0 +1,2 @@
+{{! prettier-ignore }}
+<svg class="fa d-icon d-icon-custom-google-oauth2 svg-icon" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg>
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/templates/components/login-buttons.hbs b/app/assets/javascripts/discourse/app/templates/components/login-buttons.hbs
index b7a0ffeba7b..828d599ae27 100644
--- a/app/assets/javascripts/discourse/app/templates/components/login-buttons.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/login-buttons.hbs
@@ -1,7 +1,7 @@
{{#each this.buttons as |b|}}
<button type="button" class="btn btn-social {{b.name}}" {{on "click" (action this.externalLogin b)}} aria-label={{b.screenReaderTitle}} tabindex="3">
{{#if b.isGoogle}}
- <svg class="fa d-icon d-icon-custom-google-oauth2 svg-icon" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg>
+ <GoogleIcon />
{{else if b.icon}}
{{d-icon b.icon}}
{{else}}
diff --git a/app/assets/javascripts/wizard/addon/templates/components/discourse-logo.hbs b/app/assets/javascripts/wizard/addon/templates/components/discourse-logo.hbs
index 325af0ba10a..2278d63e026 100644
--- a/app/assets/javascripts/wizard/addon/templates/components/discourse-logo.hbs
+++ b/app/assets/javascripts/wizard/addon/templates/components/discourse-logo.hbs
@@ -1,3 +1,4 @@
+{{! prettier-ignore }}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 385 104">
<g id="discourse-logo-large" fill="none" fill-rule="nonzero">
<path class="logo-contour" fill="var(--primary)"
diff --git a/app/assets/javascripts/wizard/addon/templates/components/illustration-members.hbs b/app/assets/javascripts/wizard/addon/templates/components/illustration-members.hbs
index b797bc50784..5ee75225dcd 100644
--- a/app/assets/javascripts/wizard/addon/templates/components/illustration-members.hbs
+++ b/app/assets/javascripts/wizard/addon/templates/components/illustration-members.hbs
@@ -1,3 +1,4 @@
+{{! prettier-ignore }}
<svg xmlns="http://www.w3.org/2000/svg" id="wizard-members-illustration" viewBox="0 0 891.79 761.94">
<defs>
<pattern id="Unnamed_Pattern_2" x="0" y="0" width="144" height="144" patternTransform="matrix(1.3 0 0 -.96 405.71 -15766.98)" patternUnits="userSpaceOnUse">
diff --git a/app/assets/javascripts/wizard/addon/templates/components/illustration-welcome.hbs b/app/assets/javascripts/wizard/addon/templates/components/illustration-welcome.hbs
index a88c31224a2..813f1b7d274 100644
--- a/app/assets/javascripts/wizard/addon/templates/components/illustration-welcome.hbs
+++ b/app/assets/javascripts/wizard/addon/templates/components/illustration-welcome.hbs
@@ -1,3 +1,4 @@
+{{! prettier-ignore }}
<svg xmlns="http://www.w3.org/2000/svg" id="wizard-welcome-illustration" viewBox="0 0 941.69 730.8">
<defs>
{{! template-lint-disable no-forbidden-elements }}
diff --git a/lib/tasks/javascript.rake b/lib/tasks/javascript.rake
index 5b473f6e5ee..ebdbe1702b6 100644
--- a/lib/tasks/javascript.rake
+++ b/lib/tasks/javascript.rake
@@ -58,6 +58,7 @@ def write_hbs_template(path, task_name, template)
basename = File.basename(path)
output_path = "#{Rails.root}/app/assets/javascripts/#{path}"
File.write(output_path, "#{header}\n#{template}")
+ %x{yarn run prettier --write #{output_path}}
puts "#{basename} created"
end