-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Variable Declarations & Callee Behavior #264
base: master
Are you sure you want to change the base?
Variable Declarations & Callee Behavior #264
Conversation
[UPDATE:] Expanded PR to include all TW-v3 rules AND expand callee behaviorI've been working on multiple changes for the plugin, the first of which were variable declarations. However, it got too entangled keeping them separate so I'm updating everything here. The new callee behaviorThe current callee behavior will treat things like clsx({
'bg-wrong-class': 'w-full'
}) In the case of cva(['w-full'], {
variants: {
good: 'w-auto',
bad: 'w-random-value'
}
}) To achieve this, the type CalleeType = {
[<callee-name>: string]: 'key' | 'value'
} The default values are:
Additionally, any existing array that is passed in will be converted to the new form. If the callee existing in the defaults, it will use the This is a big update! Please provide any kind of feedback. We are actively using these changes in our projects by temporarily updating our "eslint-plugin-tailwindcss": "https://github.com/jd-carroll/eslint-plugin-tailwindcss#variable-declarations", If you want to see these changes land, please help by contributing documentation and/or test cases. I have arguably spent too much time on creating these updates so I need to re-focus on other items. Either leave a message here or create a PR against my fork. (❤️ for all the effort that went into this plugin already) |
@francoismassart What can I do to make this PR more understandable? It would be great to get this evaluated / merged at some point. I think these changes will really help people. |
Just bumped into code where duplicate class names were not detected: cva(['w-full', 'w-full'], {
variants: {
good: 'w-auto',
bad: 'w-random-value'
}
}) Having two strings in the first argument is useful when they are long and we want to render them on separate lines. Example (imagine this inside It’d be great to see this PR reviewed @francoismassart 🙏 |
Parse Variable Declarations
Description
This PR fixes a hole in the current evaluation.
Currently, the following code misses the incorrect class name:
This update will identify the wrong class names in all variable declarations with string, object, or array values.
(It will also identify duplicate class names)