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:

Repo link

  1. clone the repo
  2. run pnpm install
  3. open a .tsx file, page.tsx has unocss class applied or apply a class to a new file
  4. observe the eslint output for vscode

Screenshot:

Screenshot 2023-05-10 at 12 48 25

System Info

  • laptop: MacBook Air M1 13 inches
  • OS: Ventura latest version
  • IDE: VScode
  • Package Manager: pnpm

Validations

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 12
  • Comments: 16 (3 by maintainers)

Most upvoted comments

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.

That’s a little bit complex - you can replace its content with:

// To make @unocss/eslint-plugin work
export { default } from "./packages/foo/uno.config";

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 root uno.config.ts? Is that possible to configure the @unocss/eslint-config that consumes the similar config pattern for unocss.root that the unocss VSCode extension uses therefore we could have a stable and same behavior?

my temporary solution is to create a “uno.config.ts” in the root directory and write the following content in it:

// for eslint;
import { defineConfig } from 'unocss'

export default defineConfig({
  configFile: './components/uno.config.ts',
})

At least it stops throwing this error message [@unocss/eslint-plugin] No config file found.

You can refer to this project: cherryful/unocss-ui

That’s a little bit complex - you can replace its content with:

// To make @unocss/eslint-plugin work
export { default } from "./packages/foo/uno.config";

my temporary solution is to create a “uno.config.ts” in the root directory and write the following content in it:

// for eslint;
import { defineConfig } from 'unocss'

export default defineConfig({
  configFile: './components/uno.config.ts',
})

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