[Feature request] eslint setting for custom class-string regex
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m using the package Twrnc for React-Native, and I’d love to be able to use your plugin. The tailwind classes for Twrnc are in the format
style={tw`classes here like-this`}
but can also be in other slightly different formats depending on how you configure it (eg. style={tws(`classes-like this`, someBoolean && `more class-es`)}
Describe the solution you’d like I would love it if you could provide an ESlint tailwind setting for providing custom regexes to identify the start and end of tailwind strings. I’m thinking it could be set up so that the regex capture group(s) contain the identified tailwind class strings.
That would make the regex for the simpler case need something like:
tw`([^`])`
And perhaps the more complex case would be a set of regexes expanding as far as the number of sequential strings you wanted to support:
tws\([^`]*`([^`]*)`[^\)]*\)
tws\([^`]*`[^`]*`[^`]*`([^`]*)`[^\)]*\)
tws\([^`]*`[^`]*`[^`]*`[^`]*`[^`]*`([^`]*)`[^\)]*\)
tws\([^`]*`[^`]*`[^`]*`[^`]*`[^`]*`[^`]*`[^`]*([^`]*)`[^\)]*\)
If you provided the option to switch to a regex-based version it would also support class name strings that aren’t in-situ in a React node.
FYI the VSCode Tailwind plugin does a great job of utilising complex regex group location, using the multi-regexp2
package: see this function.
Describe alternatives you’ve considered No alternative that I can see if I want to use this plugin with React-Native and Twrnc
Additional context N/A
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@finnmerlett see https://github.com/francoismassart/eslint-plugin-tailwindcss/commit/f2feaf61ba4469ed0a49d006772769fc0d7b8c88
Wondering if the regex syntax could be supported as well.
For instance using vite-plugin-inline-css-module we can write
The tailwind library supports parsing this using