Skip to content

fix: allow modifier classes inside :is()/:not()/:where() with a base class - #49

Open
davidding wants to merge 1 commit into
mainfrom
fix/selector-disallowed-list-is-false-positive
Open

fix: allow modifier classes inside :is()/:not()/:where() with a base class#49
davidding wants to merge 1 commit into
mainfrom
fix/selector-disallowed-list-is-false-positive

Conversation

@davidding

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a false positive in selector-disallowed-list where modifier classes (e.g. .-mod-b) were incorrectly flagged when used as additional arguments in :is()/:not()/:where() with a base class (e.g. .base:is(.-mod-a, .-mod-b))
  • Adds detection for the genuinely invalid case where :is(.-modifier) has no base class before it (e.g. :is(.-mod-a, .-mod-b) .child)

Behaviour

Selector Before After
.base:is(.-mod-a, .-mod-b) ✖ false positive ✔ passes
.base:is(.-mod) ✔ passes ✔ passes
:is(.-mod-a, .-mod-b) .child ✔ passes (missed) ✖ flagged
.-standalone .bar ✖ flagged ✖ flagged

How it works

Two patterns replace the previous single pattern:

  1. Original pattern + negative lookbehind — skips matches where the modifier appears after a comma-space inside an already-open :is()/:not()/:where()/:matches()
  2. New pattern — flags :is( (and siblings) when it appears at the start of a selector or after a combinator, meaning no base class precedes it

🤖 AI-assisted draft — human review required

Test plan

  • Verify .base:is(.-mod-a, .-mod-b) .child no longer triggers selector-disallowed-list
  • Verify :is(.-mod-a, .-mod-b) .child (no base class) is still flagged
  • Verify .-standalone .bar is still flagged
  • Verify .base:not(.-mod-a, .-mod-b) passes

…class

The selector-disallowed-list regex was a false positive on patterns like
.base:is(.-mod-a, .-mod-b) because the second argument appeared after a
comma-space, which matched the combinator pattern. Added a negative
lookbehind to exclude matches inside :is()/:not()/:where()/:matches() when
a base class precedes the pseudo-class.

Also added a second pattern to flag :is(.-modifier) when used without any
base class (i.e. :is() itself starts the selector or follows a combinator),
which is a genuine violation the original regex missed.
@davidding
davidding marked this pull request as ready for review June 19, 2026 15:30
@davidding
davidding requested a review from a team as a code owner June 19, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants