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

Fix support for latest Liquid scripting plugin #109

Merged
merged 1 commit into from Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing!
- Fix support for latest Shopify Liquid plugin ([#109](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/109))

## [0.2.0] - 2022-11-25

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@prettier/plugin-php": "^0.19.2",
"@prettier/plugin-pug": "^2.3.0",
"@shopify/prettier-plugin-liquid": "^0.4.0",
"@shopify/prettier-plugin-liquid": "^1.0.0-rc.2",
"@shufo/prettier-plugin-blade": "^1.8.0",
"@tailwindcss/line-clamp": "^0.3.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Expand Up @@ -346,9 +346,18 @@ function transformGlimmer(ast, { env }) {
}

function transformLiquid(ast, { env }) {
/** @param {{name: string | {type: string, value: string}[]}} node */
function isClassAttr(node) {
if (Array.isArray(node.name)) {
return node.name.every((n) => n.type === 'TextNode' && n.value === 'class');
}

return node.name === 'class'
}

visit(ast, {
AttrSingleQuoted(node, _parent, _key, _index, meta) {
if (node.name !== "class") {
if (!isClassAttr(node)) {
return;
}

Expand All @@ -357,7 +366,7 @@ function transformLiquid(ast, { env }) {
},

AttrDoubleQuoted(node, _parent, _key, _index, meta) {
if (node.name !== "class") {
if (!isClassAttr(node)) {
return;
}

Expand Down