From 8c7d004b0a5b2f246714e2dae89511bd90166fe6 Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Mon, 26 Jun 2023 08:45:14 +0200 Subject: [PATCH] Fix `media-feature-name-no-vendor-prefix` positions for `*-device-pixel-ratio` (#6977) --- .changeset/tough-shrimps-walk.md | 5 ++++ .../__tests__/index.js | 23 ++++++++++++++++++- .../index.js | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .changeset/tough-shrimps-walk.md diff --git a/.changeset/tough-shrimps-walk.md b/.changeset/tough-shrimps-walk.md new file mode 100644 index 0000000000..544dde87ae --- /dev/null +++ b/.changeset/tough-shrimps-walk.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `media-feature-name-no-vendor-prefix` positions for `*-device-pixel-ratio` diff --git a/lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js b/lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js index 89a70ff5c9..2535ad7077 100644 --- a/lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js +++ b/lib/rules/media-feature-name-no-vendor-prefix/__tests__/index.js @@ -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) {}', diff --git a/lib/rules/media-feature-name-no-vendor-prefix/index.js b/lib/rules/media-feature-name-no-vendor-prefix/index.js index 07aa5f9b7d..941f246d86 100644 --- a/lib/rules/media-feature-name-no-vendor-prefix/index.js +++ b/lib/rules/media-feature-name-no-vendor-prefix/index.js @@ -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;