New Rule: no-invalid-pseudo-selectors · Issue #551 · eslint/css · GitHub
Skip to content

New Rule: no-invalid-pseudo-selectors #551

Open

Description

@BHyeonKim

Rule details

Warns when a selector uses a pseudo-class or pseudo-element name that doesn't exist in the CSS specifications (e.g. a typo like :hoverr or ::befor) — an unknown pseudo-class/element causes the entire selector (and rule) to be silently dropped by browsers.

What type of rule is this?

Warns about a potential problem

Example code

/* WARNING: 'hoverr' and 'befor' are typos, not real pseudo-classes/pseudo-elements */
a:hoverr {
  color: red;
}

p::befor {
  content: "";
}

/* OK */
a:hover {
  color: red;
}

p::before {
  content: "";
}

Prior Art

stylelint covers this with two separate rules:

Participation

  • I am willing to submit a pull request to implement this rule.

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

Disclosure: I'm a participant of open source contribution program OSSCA

Activity

  1. moved this to Needs Triage in Triageon Sep 1, 2026
  2. BHyeonKim commented on Sep 1, 2026

    @BHyeonKim
    ContributorAuthor

    I assumed no-unmatchable-selectors already covered this, based on its name. After checking the implementation, it only handles :nth-*() selectors with impossible AnPlusB values — it doesn't validate whether a pseudo-class/pseudo-element name actually exists. Hence this proposal.

  3. moved this from Needs Triage to Ready to Implement in Triageon Oct 20, 2026
  4. added
    acceptedThere is consensus among the team that this change meets the criteria for inclusion
    on Oct 20, 2026
  5. nzakas commented on Oct 20, 2026

    @nzakas
    Member

    Sounds good to me. Marking as accepted. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionfeature

Type

No type

Projects

  • Status
    Ready to Implement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions