Skip to content

Commit

Permalink
Fix media-feature-name-no-vendor-prefix positions for `*-device-pix…
Browse files Browse the repository at this point in the history
…el-ratio` (#6977)
  • Loading branch information
romainmenke authored and mattxwang committed Jun 29, 2023
1 parent 9c0a726 commit 8c7d004
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-shrimps-walk.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `media-feature-name-no-vendor-prefix` positions for `*-device-pixel-ratio`
23 changes: 22 additions & 1 deletion lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js
Expand Up @@ -41,12 +41,33 @@ testRule({
line: 1,
column: 9,
},
{
code: '@media (min--moz-device-pixel-ratio: 1) {}',
fixed: '@media (min-device-pixel-ratio: 1) {}',
message: messages.rejected,
line: 1,
column: 9,
},
{
code: '@media ( max--moz-device-pixel-ratio: 1) {}',
fixed: '@media ( max-device-pixel-ratio: 1) {}',
message: messages.rejected,
line: 1,
column: 10,
},
{
code: '@media (/* a comment */MIN--moz-device-pixel-ratio: 1) {}',
fixed: '@media (/* a comment */MIN-device-pixel-ratio: 1) {}',
message: messages.rejected,
line: 1,
column: 24,
},
{
code: '@media\n\t(min--moz-device-pixel-ratio: 1) {}',
fixed: '@media\n\t(min-device-pixel-ratio: 1) {}',
message: messages.rejected,
line: 2,
column: 6,
column: 3,
},
{
code: '@media (-o-max-device-pixel-ratio: 1/1) {}',
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/media-feature-name-no-vendor-prefix/index.js
Expand Up @@ -32,7 +32,7 @@ const rule = (primary, _secondaryOptions, context) => {
return;
}

const matches = atRule.toString().match(/-[a-z-]+device-pixel-ratio/gi);
const matches = atRule.toString().match(/(?:min-|max-)?-[a-z-]+device-pixel-ratio/gi);

if (!matches) {
return;
Expand Down

0 comments on commit 8c7d004

Please sign in to comment.