Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.