Skip to content

Commit 4e467f7

Browse files
committed
Document Tailwind class name sorting
1 parent 250c70e commit 4e467f7

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ This uses the [swc](https://github.com/swc-project/swc) parser for TypeScript wr
1010

1111
See the GitHub [releases](https://github.com/dprint/dprint-plugin-typescript/releases).
1212

13+
## Configuration
14+
15+
Set `jsx.sortClassNames` to `tailwind` to sort JSX `class` and `className` values using Tailwind CSS ordering.
16+
Helper calls and tagged templates are sorted only when their leading identifier is listed in `jsx.sortClassNames.functions`.
17+
18+
```json
19+
{
20+
"typescript": {
21+
"jsx.sortClassNames": "tailwind",
22+
"jsx.sortClassNames.functions": ["cn", "classnames", "tw"]
23+
}
24+
}
25+
```
26+
1327
## Development
1428

1529
The tests are in the `./tests/specs` folder. To run the tests, run `cargo test`.

deployment/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
}]
7474
},
7575
"jsx.sortClassNames.functions": {
76-
"description": "Function names whose string arguments should be sorted as Tailwind class names.",
76+
"description": "Leading function or tag identifiers whose string arguments and template literals should be sorted as Tailwind class names.",
7777
"type": "array",
7878
"default": [],
7979
"items": {

src/configuration/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ impl ConfigurationBuilder {
130130
self.insert("jsx.sortClassNames", value.to_string().into())
131131
}
132132

133-
/// Function names whose string arguments should be sorted as Tailwind class names.
133+
/// Leading function or tag identifiers whose string arguments and template literals should be sorted as
134+
/// Tailwind class names.
134135
///
135136
/// Default: `[]`
136137
pub fn jsx_sort_class_names_functions(&mut self, value: Vec<String>) -> &mut Self {

0 commit comments

Comments
 (0)