Skip to content

Bug: Pseudo-class selector inside nesting is not correctly parsed #250

@antti5

Description

@antti5

Environment

ESLint version: 9.32.0
@eslint/css version: 0.11.0
Node version: 22.11.0
npm version: 11.2.0
Operating System: Windows 11

Which language are you using?

stylesheet

What did you do?

/* Does not work */

main {
   p:first-of-type {
      margin-top: 0;
   }
}

/* Works */

main {
   p {
      &:first-of-type {
         margin-top: 0;
      }
   }
}

What did you expect to happen?

No errors from ESlint

What actually happened?

Without tolerant mode: Parsing error: Unexpected input

With tolerant mode: Unknown property 'p' found

Additional comments

Once I introduced @eslint/css into my project, I ran into several of these issues. The CSS should be correct, is in production and works in all tested browsers.

It looks like any selector that has both element type and a pseudo-class is not recognized as a selector, but instead the parser tries to parse it as a property declaration.

The problem only occurs if the selector is nested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionbugSomething isn't working

    Type

    No type

    Projects

    Status

    Blocked

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions