Skip to content
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

[Feature request] Only validate callees #154

Closed
zslabs opened this issue Aug 17, 2022 · 4 comments
Closed

[Feature request] Only validate callees #154

zslabs opened this issue Aug 17, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@zslabs
Copy link

zslabs commented Aug 17, 2022

Describe the solution you'd like
Having the callees option is great; where we can consolidate classes into variables and still have this plugin parse the contents; ctl('flex flex-col').

During conversions of large projects, it's typical that a normal React component will have lots of other, non-Tailwind classes in the default className prop. I'd love to see an option where ONLY the callees are parsed and not the default className. So className="my-other-class" won't be parsed, but className={ctl('flex flex-col')} would be.

Describe alternatives you've considered
I'm not sure there's a workaround for this at the moment.

Additional context
Nope! But thanks for creating this tool!

@zslabs zslabs added the enhancement New feature or request label Aug 17, 2022
@francoismassart
Copy link
Owner

Hi @zslabs,
Because this feature is easy to implement, I'll add a new setting called skipClassAttribute which is false by default.

Setting it as true would ignore the value of the class and/or className attribute(s).

But a className attribute containing a template literal which hosts an expression with one the callee would still be linted.

e.g. for the no-custom-classname rule

className={`custom my-other-class ${ctl('yolo')}`}

would warn you about yolo being a custom class.

WDYT?

@francoismassart
Copy link
Owner

@zslabs
You can try this out with
npm i -D eslint-plugin-tailwindcss@3.8.0-beta.0

@zslabs
Copy link
Author

zslabs commented Nov 16, 2022

👋 @francoismassart That works beautifully! Thank you so much for taking a look at this feature request and the implementation.

francoismassart added a commit that referenced this issue Dec 13, 2022
* feat: add `skipClassAttribute` option

#154
@francoismassart
Copy link
Owner

released in v3.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants