New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting classes #1825
Comments
Currently the default preset sorting is done through rule orders. Also with help of layering ( Please find the relevant usages in the codebase: unocss/packages/core/src/types.ts Line 153 in f4954d2
unocss/packages/core/src/types.ts Line 230 in f4954d2
unocss/packages/core/src/types.ts Line 352 in f4954d2
unocss/packages/core/src/types.ts Line 357 in f4954d2
|
I'm not sure you understood me correctly, I mean sorting inside source code |
Just for context, I think @MrFoxPro is referencing to this feature, which is also available in Windi and would be a great addition to the DX with unocss. |
Thank you and sorry that I missed your point the first time.
Due to the similarity of api, I think you could start from both sides, either via extension or prettier |
I checked extension. Btw I'm not sure how sorting should be done at all, if there are variant groups. |
WindiCSS uses ast parsing for this purpose. |
I would prefer to not force users to use prettier. I think the VSCode extension would be the correct place, maybe the implementation of the transformers would be a good starting point, as they already need to identify e.g. if there are variant groups etc.. Sorting also has to consider the usage of different transformers. |
I don't think transformer will work. Transformer is just transformation when you build your app, it can't format code or check style like |
would love to have this feature in the vscode extension as well 🙏🏼 |
da06c65 this commit added a utility to sort the rules, if anyone is interested, feel free to create a eslint/prettier plugin for that |
Already I am on it :P - #2140 |
EDIT: See
extends: ['eslint:recommended', 'plugin:svelte/recommended', '@unocss', 'prettier'], |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is it feasible to make the plugin read config from |
It's recommended to use a standalone |
Closing this as we have shipped the eslint plugin for a long while. Currently, we don't have enough bandwidth for a prettier plugin but open to contributions. |
So, is it possible to sort in semantic order? For example: positioning first, styling like color and background last |
A PR is probably welcome, the sort rules are implemented here afaik: https://github.com/unocss/unocss/blob/main/packages/shared-integration/src/sort-rules.ts |
Tailwind has prettier plugin to sort classes: https://github.com/tailwindlabs/prettier-plugin-tailwindcss
WindiCSS has this feature in VSCode extension: https://windicss.org/editors/vscode.html#extension-settings
I think it would be nice to implmeent such as IDE extension/prettier plugin/cli command alongside with #1576.
I would like to implement this feature, however I'm not sure where to start.
Any ideas / drafts?
The text was updated successfully, but these errors were encountered: