-
Notifications
You must be signed in to change notification settings - Fork 3
chore: use shopify-liquid VS code plugin to autoformat html #537
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for cal-itp-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
69dbed8 to
8bc5357
Compare
bf6dc87 to
62bd598
Compare
| "extensions": [ | ||
| "eamodio.gitlens", | ||
| "esbenp.prettier-vscode", | ||
| "prettier.prettier-vscode", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change helps allows us to use [email protected] (instead of 2.x)
https://marketplace.visualstudio.com/items?itemName=prettier.prettier-vscode
| - id: djlint-reformat-jinja | ||
| files: \.html$ | ||
| types_or: ["html"] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i futzed around for longer than i probably ought this morning trying to wire up prettier + @shopify/prettier-plugin-liquid to run as a pre-commit hook too.
the configuration below doesn't error, but it results in formatting that does not match what is generated in VS Code (even when i made sure to use prettier@2 or prettier@3 consistently)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
name: prettier + plugin-liquid
additional_dependencies:
- [email protected]
- "@shopify/[email protected]"
args:
- --plugin=@shopify/prettier-plugin-liquid
types_or: [css, html]
i'm in favor of merging this PR as-is if we prefer the formatting that is produced in VS Code and just accepting that changes made via the github UI will no longer be formatted automatically.
i'm interested in hearing other opinions though. it wouldn't hurt my feelings to just close this PR and let sleeping dogs lie either.
|
RE:
Did you try updating the file extension specific formatter config? E.g. we have an entry for Sounds like you messed around with this a bit, just wanted to ask. |
i did indeed get that bit working and updated the PR description and subsequent comments to clarify where this PR stands now. |
|
Sorry if I wasn't clear; I meant in trying that other option: https://shopify.dev/docs/storefronts/themes/tools/shopify-liquid-vscode#code-formatting If you tried adding an explicit |
Scotchester
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I would definitely like to see before merging this:
I assume we'll want to use the new config to mass-format all our existing files. When doing so, let's confine the formatting to a commit that only does that, then add the commit SHA to .git-blame-ignore-revs?
62bd598 to
f273bd0
Compare
|
i did a dry-run and discovered two issues in our HTML that needed to be fixed prior to bulk autoformatting. f273bd0 when the runway is clear, now it'll be a cinch to do the actual deed: afterwards i'll commit that change and inject the SHA into a new .git-blame-ignore-revs file in the root of the repo (TIL!) |
resolves #541
theoretically it should be possible to get prettier + plugins configured to run via pre-commit, but i haven't found any joy getting that setup with
@shopify/prettier-plugin-liquidyet (CIL for more notes about that).prettier/pre-commit#16
as for the formatting changes... i figured it made sense to start with a single file as a conversation starter.
alternatives exploredhttps://shopify.dev/docs/storefronts/themes/tools/shopify-liquid-vscode#code-formattingi could only get ☝️ to autoformat🤷.liquidfiles.