diff --git a/package-lock.json b/package-lock.json index 4a18769..2f6e0b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1780,9 +1780,9 @@ } }, "node_modules/@shopify/prettier-plugin-liquid": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-0.4.0.tgz", - "integrity": "sha512-pJDTud9alhtCF0ZNDKpREmjvrWSVL60ZJsd1BE1kZ+QWBuuj6MYiVth9edYsupFp3Xa29VqrZ0QaEzgIouOeSg==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-0.4.3.tgz", + "integrity": "sha512-WCs7OEWvsgEdowP095DSFfCSQQedLNtppZPEK7pXINQ7WaKlmJUgATzxggTihf5wi9LyhJZdJmvnjVw6fxE+tA==", "dev": true, "dependencies": { "html-styles": "^1.0.0", @@ -13911,9 +13911,9 @@ } }, "@shopify/prettier-plugin-liquid": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-0.4.0.tgz", - "integrity": "sha512-pJDTud9alhtCF0ZNDKpREmjvrWSVL60ZJsd1BE1kZ+QWBuuj6MYiVth9edYsupFp3Xa29VqrZ0QaEzgIouOeSg==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-0.4.3.tgz", + "integrity": "sha512-WCs7OEWvsgEdowP095DSFfCSQQedLNtppZPEK7pXINQ7WaKlmJUgATzxggTihf5wi9LyhJZdJmvnjVw6fxE+tA==", "dev": true, "requires": { "html-styles": "^1.0.0", diff --git a/package.json b/package.json index c1c9cce..23be83d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 7f44404..360bad2 100644 --- a/src/index.js +++ b/src/index.js @@ -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; } @@ -357,7 +366,7 @@ function transformLiquid(ast, { env }) { }, AttrDoubleQuoted(node, _parent, _key, _index, meta) { - if (node.name !== "class") { + if (!isClassAttr(node)) { return; }