unocss: @unocss/eslint-config doesn't work on pnpm monorepo with vscode?
UnoCSS version
any
Describe the bug
I’m trying to use the eslint plugin for unocss, the older one from devunt doesn’t have the options to configure linting for other attributes besides className so i was trying to use the tailwind one, but the latter doesn’t pick up the uno.config.ts custom values.
I installed @unocss/eslint-config and tried following the official instructions but when i open a file with unocss classes i get an error like this for ESlint output.
[Error - 12:38:47] An unexpected error occurred:
[Error - 12:38:47] Error: [@unocss/eslint-plugin] No config file found, create a `uno.config.ts` file in your project root and try again.
at getGenerator (/---/uno-monorepo/node_modules/.pnpm/@unocss+eslint-plugin@0.51.12_eslint@8.40.0_typescript@5.0.4/node_modules/@unocss/eslint-plugin/dist/worker-sort.cjs:37:11)
at async /---/uno-monorepo/node_modules/.pnpm/@unocss+eslint-plugin@0.51.12_eslint@8.40.0_typescript@5.0.4/node_modules/@unocss/eslint-plugin/dist/worker-sort.cjs:43:15
Reproduction
I’ve uploaded a reproduction repo, these are the steps to reproduce:
- clone the repo
- run
pnpm install - open a
.tsxfile,page.tsxhas unocss class applied or apply a class to a new file - observe the eslint output for vscode
Screenshot:
System Info
- laptop: MacBook Air M1 13 inches
- OS: Ventura latest version
- IDE: VScode
- Package Manager: pnpm
Validations
- Read the Contributing Guidelines.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 12
- Comments: 16 (3 by maintainers)
I don’t have the bandwidth to look into this right now. If someone could propose some solutions via PRs, it might help this to move faster.
What if I have multiple packages that holds their own
uno.config.ts? Do I export them all with a spread syntax all at once in the rootuno.config.ts? Is that possible to configure the@unocss/eslint-configthat consumes the similar config pattern forunocss.rootthat the unocss VSCode extension uses therefore we could have a stable and same behavior?That’s a little bit complex - you can replace its content with:
my temporary solution is to create a “uno.config.ts” in the root directory and write the following content in it:
At least it stops throwing this error message
[@unocss/eslint-plugin] No config file found.You can refer to this project: https://github.com/cherryful/unocss-ui
+1