Add opt-in customization features#127
Conversation
|
This feature would be awesome! Thanks for this @nderscore |
d613b6a to
9dac940
Compare
|
I am also excited for this feature! |
|
Looking forward to these features :) |
b388b61 to
6c994f8
Compare
|
Hey, thanks for this PR! We've had internal discussions for quite some time now about adding these kinds of customizations to our Prettier plugin, but it just hasn't materialized to date. This PR was a great step in the right direction and inspired us to try and take another crack at it. In principle we really like what you've done here, but since we wanted to tweak the proposed API slightly, we created a new PR (#155) based on this one and have included you as a co-author. This gives us the ability to properly document these new customization options in the PR description. You can see that PR for more details, but here is the TLDR:
Thanks again for your work here! 🙏 |
|
Hey, we've just merged #155 which provides a way for you to specify additional attributes, functions, and tagged template literals that should be sorted by the plugin. It's available via our insiders build and will be released in the next version of the plugin. We would like to get some feedback on this feature before we release it, so please give it a try and let us know what you think! To test the new features you can install the insiders build like so: |
The changes here originally started out as a fork that was catered specifically to NativeWind v3.x, which is planning to introduce a new CVA/stitches-eseque variants API.
Recently, I updated my fork to be configurable by specifying additional settings to Prettier, so that it could be used to support other non-standard Tailwind use cases. Now that the changes have been made more generic, I think it makes sense to propose moving them upstream.
This PR adds three new Prettier config options, which enable users to expand on and customize where the plugin searches for Tailwind classes.
tailwindJSXProps- allows customizing which JSX props the plugin searchestailwindFunctionCalls- enables searching for tailwind classes in certain function calls by nametailwindTaggedTemplates- enables searching for tailwind classes in certain tagged template expressions by function nameThey are all optional to use and backwards-compatible with existing usage. Usage examples can be found in the diff of the README and unit tests.
This approach could also be expanded upon to support other custom tailwind/tailwind-ish use cases, such as sorting tailwind classes in object properties or variable declarations.