unocss: Unknown at rule @apply

UnoCSS version

0.50.3

Describe the bug

The @apply is working, but VS Code annoys me with a ton of errors:

图片

Reproduction

vite.config.ts:

import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";

import UnoCSS from "unocss/vite";
import { presetUno, presetIcons, extractorSvelte, transformerDirectives } from "unocss";
import { presetDaisy } from "unocss-preset-daisy";

export default defineConfig({
	server: {
		host: "0.0.0.0",
	},
	plugins: [
		UnoCSS({
			transformers: [transformerDirectives()],
			extractors: [extractorSvelte],
			shortcuts: [
				{
					"svg-rule": "text-6 ma block",
				},
			],
			presets: [
				presetUno(),
				presetDaisy(),
				presetIcons({
				}),
			],
			theme: {
				// This is NOT a theme name, it must be `colors`
				colors: {},
			},
		}),
		sveltekit(),
	],
});

System Info

No response

Validations

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

I got it working with npmjs.com/package/@unocss/eslint-config

I use @unocss/eslint-config too, but there’re still the warnings. Could you please tell me how does it work?

Guys, the solution:

.vscode/settings.json

{
  "css.customData": [".vscode/unocss.json"]
}

.vscode/unocss.json

{
  "version": 1.1,
  "atDirectives": [
    {
      "name": "@apply"
    },
    {
      "name": "@screen"
    },
  ]
}