Closed hangaoke1 closed 2 months ago
Providing a fix for this use case will be extremely challenging, almost impossible.
What's the expected and correct fix?
Maybe
<div className={`fishd-upload-list-${listType} m-websession-uploadlist`}>app</div>
But ïŒNow it break fishd-upload-list-${listType}
I think it maybe need handle JsTemplateElementListïŒ but unfortunately I am just start to learn
The rule does handle template literals, however there's a limitation of what the rule can do and that's one of them.
The rule does handle template literals, however there's a limitation of what the rule can do and that's one of them.
Hello buddy, I think it is possible by dealing with JsTemplateExpression
1ăExtract the template string content from JsTemplateExpression
2ăSort string content
3ăRebuild JsTemplateExpression with make::js_template_expression
(Perhaps biome provides an easier way to generate expression nodes from string)
4ăReplace node in rule action
That's not what I'm talking about. Can the tailwind plugin fix your case?
That's not what I'm talking about. Can the tailwind plugin fix your case?
Test in prettier-plugin-tailwindcss
It has special logic in sortTemplateLiteralïŒand fishd-upload-list-
will be filter
https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/main/src/index.ts#L538
@ematipico sorry but I can't understand if tailwind sorting of classes is enabled and handled out of the box when using Biome. In my monorepo project I don't see it working, but from the convos here on github (like this one) I'm assuming yes.
I also tried moving tailwind.config.ts
from the /package/webapp
folder into /root
folder but nothing.
Can you point me out to relevant documentation? I only found this https://biomejs.dev/linter/rules/use-sorted-classes/#important-notes.
This rule has been flagged with an unsafe fix, hence it's only fixable via CLI using the --unsafe
option, or using the "Quick fix" pop up that VSCode provides.
You're free to change the severity of the fix. The lint rule page provides useful links at the bottom of the page. One of them is this one: https://biomejs.dev/linter/#configure-the-rule-fix
I advise you to read more about how our linter works, it's different from ESLint
@ematipico I managed to have the sort working, marking as "safe" and letting webstorm handling it on save as I had with eslint, grazie!
As reference for others:
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 160,
"lineEnding": "lf"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": {
"recommended": false
},
"suspicious": {
"recommended": false
},
"nursery": {
"useSortedClasses": {
"level": "error",
"fix": "safe",
"options": {
"attributes": ["className"],
"functions": ["cx"]
}
}
}
}
}
}
Environment information
Playground link
https://biomejs.dev/playground/?bracketSameLine=true&lintRules=all&code=aQBtAHAAbwByAHQAIABSAGUAYQBjAHQAIABmAHIAbwBtACAAJwByAGUAYQBjAHQAJwA7AAoACgBjAG8AbgBzAHQAIABBAHAAcAAgAD0AIAAoACkAIAA9AD4AIAB7AAoAIAAgAGMAbwBuAHMAdAAgAGwAaQBzAHQAVAB5AHAAZQAgAD0AIAAnAHAAaQBjAHQAdQByAGUALQBjAGEAcgBkACcAOwAKACAAIAByAGUAdAB1AHIAbgAgADwAZABpAHYAIABjAGwAYQBzAHMATgBhAG0AZQA9AHsAYABtAC0AdwBlAGIAcwBlAHMAcwBpAG8AbgAtAHUAcABsAG8AYQBkAGwAaQBzAHQAIABmAGkAcwBoAGQALQB1AHAAbABvAGEAZAAtAGwAaQBzAHQALQAkAHsAbABpAHMAdABUAHkAcABlAH0AYAB9AD4AYQBwAHAAPAAvAGQAaQB2AD4AOwAKAH0AOwAKAAoAZQB4AHAAbwByAHQAIABkAGUAZgBhAHUAbAB0ACAAQQBwAHAAOwAKAA%3D%3D
Code of Conduct