diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c9316f8..e694db82 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! +### Fixed + +- Add support for sorting `class` attribute on custom elements and Astro components ([#129](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/129)) ## [0.2.3] - 2023-02-15 diff --git a/src/index.js b/src/index.js index 6a573856..dcb00c54 100644 --- a/src/index.js +++ b/src/index.js @@ -573,7 +573,7 @@ export const parsers = { } function transformAstro(ast, { env, changes }) { - if (ast.type === "element") { + if (ast.type === "element" || ast.type === "custom-element" || ast.type === "component") { for (let attr of ast.attributes ?? []) { if (attr.name === "class" && attr.type === "attribute" && attr.kind === "quoted") { attr.value = sortClasses(attr.value, { diff --git a/tests/test.js b/tests/test.js index 4cdb9ca2..ceb945f1 100644 --- a/tests/test.js +++ b/tests/test.js @@ -265,6 +265,16 @@ let tests = { } `, ], + t`--- +import Layout from '../layouts/Layout.astro' +import Custom from '../components/Custom.astro' +--- + + +
+ + +
`, ], };