Skip to content

Make the global styles only warning configurable #1157

Open
@fehnomenal

Description

@fehnomenal

Describe the problem

I'm using unocss in the svelte scoped mode. In short it scans through the source, collects all tailwind-like classes it detects, (optionally combines them to one, during build or if forced) and outputs the rules as global styles (e.g. :global(.c-red) {...) by adding a <style> tag if necessary.
Also I'm using shadcn-svelte which has a lot of wrapper components without any html elements but defining classes (e.g. https://github.com/huntabyte/shadcn-svelte/blob/next-tailwind-3/sites/docs/src/lib/registry/new-york/ui/alert-dialog/alert-dialog-description.svelte). After preprocessing the component has some global styles defined and this triggers this plugin's check for scopable elements (this is one by adding *{} and checking if the svelte compiler complains because of that rule).

This combination results in my getting spammed with a wall of warnings directly after starting the dev server.

Repro: https://github.com/fehnomenal/repro-unocss-svelte-scoped

Describe the proposed solution

My ideal solution would be to totally silence the warning if there are really no scopable elements and only global selectors. But this info is currently not available AFAIK.

Alternatives considered

Just ignore the warnings, but it is easy to miss real warnings that indicate a problem. Either by just not reading them or configuring:

  compilerOptions: {
    warningFilter: (w) =>
      w.code !== 'css_unused_selector' || w.message.includes('No scopable elements found'),
  },

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageAwaiting triage by a project member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions