diff --git a/CHANGELOG.md b/CHANGELOG.md
index c162a725..f2987223 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
-- Nothing yet!
+### Added
+
+- Sort expressions in Astro's `class:list` attribute ([#192](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/192))
## [0.4.1] - 2023-07-14
diff --git a/src/plugin-v2.js b/src/plugin-v2.js
index fa0b4877..1ed6f12c 100644
--- a/src/plugin-v2.js
+++ b/src/plugin-v2.js
@@ -553,7 +553,7 @@ function transformCss(ast, { env }) {
* @param {TransformerContext} param1
*/
function transformAstro(ast, { env, changes }) {
- let { staticAttrs } = env.customizations
+ let { staticAttrs, dynamicAttrs } = env.customizations
if (
ast.type === 'element' ||
@@ -569,6 +569,13 @@ function transformAstro(ast, { env, changes }) {
attr.value = sortClasses(attr.value, {
env,
})
+ } else if (
+ dynamicAttrs.has(attr.name) &&
+ attr.type === 'attribute' &&
+ attr.kind === 'expression' &&
+ typeof attr.value === 'string'
+ ) {
+ transformDynamicJsAttribute(attr, env)
}
}
}
@@ -896,6 +903,7 @@ export const parsers = {
? {
astro: createParser('astro', transformAstro, {
staticAttrs: ['class'],
+ dynamicAttrs: ['class:list'],
}),
}
: {}),
diff --git a/src/plugin-v3.js b/src/plugin-v3.js
index 06cbc182..a87be0e9 100644
--- a/src/plugin-v3.js
+++ b/src/plugin-v3.js
@@ -553,7 +553,7 @@ function transformCss(ast, { env }) {
* @param {TransformerContext} param1
*/
function transformAstro(ast, { env, changes }) {
- let { staticAttrs } = env.customizations
+ let { staticAttrs, dynamicAttrs } = env.customizations
if (
ast.type === 'element' ||
@@ -569,6 +569,13 @@ function transformAstro(ast, { env, changes }) {
attr.value = sortClasses(attr.value, {
env,
})
+ } else if (
+ dynamicAttrs.has(attr.name) &&
+ attr.type === 'attribute' &&
+ attr.kind === 'expression' &&
+ typeof attr.value === 'string'
+ ) {
+ transformDynamicJsAttribute(attr, env)
}
}
}
@@ -896,6 +903,7 @@ export const parsers = {
? {
astro: createParser('astro', transformAstro, {
staticAttrs: ['class'],
+ dynamicAttrs: ['class:list'],
}),
}
: {}),
diff --git a/tests/plugins.test.js b/tests/plugins.test.js
index dbba347c..779901c8 100644
--- a/tests/plugins.test.js
+++ b/tests/plugins.test.js
@@ -293,6 +293,12 @@ import Custom from '../components/Custom.astro'