eslint-plugin-tailwindcss: [BUG] Poor performance of `no-custom-classname` and `classnames-order`
Describe the bug
no-custom-classname and classnames-order take a very long time to run relative to other rules.
To Reproduce Steps to reproduce the behavior:
- Clone https://github.com/flirtual/flirtual
- Run eslint in apps/frontend/
Expected behavior Execution time more in line with other rules. These two rules account for over 80% (>50s on a fast machine) of our eslint runtime.
Screenshots
$ TIMING=1 ./node_modules/.bin/eslint src/**/*.ts src/**/*.tsx
Rule | Time (ms) | Relative
:----------------------------------------------|----------:|--------:
tailwindcss/no-custom-classname | 34219.388 | 55.4%
tailwindcss/classnames-order | 17837.675 | 28.9%
prettier/prettier | 1704.244 | 2.8%
tailwindcss/no-contradicting-classname | 1603.051 | 2.6%
tailwindcss/enforces-negative-arbitrary-values | 1420.780 | 2.3%
tailwindcss/enforces-shorthand | 1173.931 | 1.9%
import/no-self-import | 933.115 | 1.5%
@typescript-eslint/no-floating-promises | 672.175 | 1.1%
import/export | 305.687 | 0.5%
import/no-named-as-default-member | 236.529 | 0.4%
Environment (please complete the following information):
- OS: macOS 13 (M1 Pro)
- Softwares + version used:
- eslint 8.49.0
Additional context
Setting cssFiles to [] per #174 makes no-custom-classname almost 40% faster, but these rules still take around 40 seconds to run.
eslint config file or live demo
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 24
- Comments: 22 (8 by maintainers)
Commits related to this issue
- Temporarily disable eslint-config-tailwindcss https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/276 — committed to haydenbleasel/ultracite by haydenbleasel 3 years ago
+1 on this. Also experiencing extreme slowdown of ESLint within VSCode, especially when format on save.
Checked in our react-native project 15s -> 2.4s. 6x performance boost
Before:
After:
You can improve speed of plugin with this patch:
In my case
cssFiles: []boost performance up to 17x timesBefore:
After:
I think cssFiles detection logic is ineffective, we should investigate it
Hi, this issue is not resolved. Performance is still an extreme issue with this plugin.
There are 3 problems.
https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/7070c348b8829bc6af0366d19176b4f898cd018e/lib/util/cssFiles.js#L18-L41
I can provide PR that fixes this behavior
@XantreDev Can you turn this into a pull request? I’d like to see this merged.EDIT: Oop, just saw you already did, well done!@rickvandermey you can add this to your
.eslintrc:Even though the rule is slow, I personally find it very useful and don’t recommend disabling it.
+1 here
Please provide more information about your setup How does it perform in your case?
The
tailwindcss/no-custom-classnameis taking 2mins on my project as well.@francoismassart can you suggest an approach to mitigate this? Or is there any plan to do something about it? Thanks!
+1 Here too
Added the following to my eslint-config package as a stop-gap measure, but the underlying issue is incredibility unacceptable, given these rules often account for over 50s. If you don’t have time to resolve this, could you perhaps point me in the right direction?