Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Parsing error: Identifier is expected for :global #64

Open
1 task
crabvk opened this issue Feb 23, 2025 · 3 comments
Open
1 task

Bug: Parsing error: Identifier is expected for :global #64

crabvk opened this issue Feb 23, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@crabvk
Copy link

crabvk commented Feb 23, 2025

Environment

ESLint version: 9.21.0
@eslint/css version: 0.4.0
Node version: 22.14.0
npm version: 10.9.2
Operating System: Artix Linux 6.13.4.zen1-1

Which language are you using?

stylesheet

What did you do?

Hi. I'm using CSS modules in React application with Vite. A lot of my <Component>.module.css files has :global selectors like:

:global(.some-class) {
    color: yellow;
}

When I run npx eslint . I've got a lot of

Parsing error: Identifier is expected

errors pointing to the :global selectors.

What did you expect to happen?

No error should be shown for :globals.

What actually happened?

Parsing error: Identifier is expected

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-opheq2hk?file=src%2Fstyle.css

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@crabvk crabvk added the bug Something isn't working label Feb 23, 2025
@nzakas
Copy link
Member

nzakas commented Feb 24, 2025

Please submit a reproduction case so we can take a look.

There's nothing wrong with the CSS itself, it parses fine.

@nzakas nzakas added this to Triage Feb 24, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Feb 24, 2025
@nzakas nzakas moved this from Needs Triage to Triaging in Triage Feb 24, 2025
@crabvk
Copy link
Author

crabvk commented Feb 27, 2025

I've added an example: https://stackblitz.com/edit/vitejs-vite-opheq2hk?file=src%2Fstyle.css
At the end of the style.css you can find:

.content {
  display: flex;

  :global(.some-class) {
    background-color: red;
  }
}

:global is inside the .content, which causes the error. It's OK if :global isn't nested.

@nzakas
Copy link
Member

nzakas commented Feb 27, 2025

Ah I see. Yes, CSSTree doesn't yet support nested rule declarations, that's why you're getting the error. For now, you'll need to use tolerant parsing.

I'll leave this open to track nested rules.

@nzakas nzakas moved this from Triaging to Blocked in Triage Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Blocked
Development

No branches or pull requests

2 participants