Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Format quotes in `@source`, `@plugin`, and `@config` ([#387](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/387))
- Support sorting in callable template literals ([#367](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/367))
- Support sorting in function calls mixed with property accesses ([#367](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/367))
- Handle quote escapes in LESS when sorting `@apply` ([#392](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/392))

## [0.6.14] - 2025-07-09

Expand Down
21 changes: 20 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,33 @@ function transformCss(ast: any, { env }: TransformerContext) {
node.params,
)

node.params = sortClasses(node.params, {
let classList = node.params

let prefix = ''
let suffix = ''

if (classList.startsWith('~"') && classList.endsWith('"')) {
prefix = '~"'
suffix = '"'
classList = classList.slice(2, -1)
isImportant = false
} else if (classList.startsWith("~'") && classList.endsWith("'")) {
prefix = "~'"
suffix = "'"
classList = classList.slice(2, -1)
isImportant = false
}

classList = sortClasses(classList, {
env,
ignoreLast: isImportant,
collapseWhitespace: {
start: false,
end: !isImportant,
},
})

node.params = `${prefix}${classList}${suffix}`
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export let tests: Record<string, TestEntry[]> = {
t`@apply ${yes} #{'''!important'''};`,
t`@apply ${yes} #{"'"'"!important"'"'"};`,
],
less: [...css, t`@apply ${yes} !important;`],
less: [...css, t`@apply ${yes} !important;`, t`@apply ~"${yes}";`, t`@apply ~'${yes}';`],
babel: javascript,
typescript: javascript,
'babel-ts': javascript,
Expand Down