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

Fix selector-pseudo-class-no-unknown false positive for :modal #6811

Merged
merged 3 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/many-mugs-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Fixed selector-pseudo-class-no-unknown false positive for :modal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changeset nit:

Suggested change
Fixed selector-pseudo-class-no-unknown false positive for :modal
Fixed: `selector-pseudo-class-no-unknown` false positive for `:modal`

1 change: 1 addition & 0 deletions lib/reference/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const pseudoClasses = uniteSets(
'last-child',
'last-of-type',
'link',
'modal',
'only-child',
'only-of-type',
'optional',
Expand Down
11 changes: 11 additions & 0 deletions lib/rules/selector-pseudo-class-no-unknown/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ testRule({
{
code: 'a::before { }',
},
{
code: 'a:modal { }',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nit, but it seems like from documentation (MDN, CSS spec) that no attached selector is more idiomatic:

Suggested change
code: 'a:modal { }',
code: ':modal { }',

},
{
code: "input:not([type='submit']) { }",
},
Expand Down Expand Up @@ -127,6 +130,14 @@ testRule({
endLine: 1,
endColumn: 10,
},
{
code: 'a:modal { }',
message: messages.rejected(':modal'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it's unclear to me why this test case is here; we don't want to reject :modal since it is a known pseudo-class. Could you remove this test case?

Suggested change
{
code: 'a:modal { }',
message: messages.rejected(':modal'),
line: 1,
column: 2,
endLine: 1,
endColumn: 10,
},

{
code: 'a:Unknown { }',
message: messages.rejected(':Unknown'),
Expand Down