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 media-feature-name-no-vendor-prefix positions for *-device-pixel-ratio #6975

Closed
romainmenke opened this issue Jun 25, 2023 · 1 comment · Fixed by #6977
Closed

Fix media-feature-name-no-vendor-prefix positions for *-device-pixel-ratio #6975

romainmenke opened this issue Jun 25, 2023 · 1 comment · Fixed by #6977
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule

Comments

@romainmenke
Copy link
Member

romainmenke commented Jun 25, 2023

What steps are needed to reproduce the bug?

@media (min--moz-device-pixel-ratio: 0.0104), (-webkit-min-device-pixel-ratio: 0.0104) {
  div {
    color: green;
  }
}

What Stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "media-feature-name-no-vendor-prefix": true
  }
}

How did you run Stylelint?

https://stylelint.io/demo/#N4Igxg9gJgpiBcIACBbGUCWBDABAChQwDsBaElCALxNgDcMwYSAHDADxgBsSAnLAFwwR4OAAwA6UQEZRAFgCUAGnwkA7jABGAawz9yxGjHqMW7LrwFCRE6XPk5gAHSI4cmWg+evXkThB4iAOY8MDBEANxeOAC+ztEgiiAAZhicMAByWGgIIDBsWcxp4mAAziUJ4BBEKYE5Ti44jrls-GFQJU0iANpRrk0l-ACeaZzEepDVGIEkA1hEUFg8UE1RALqKUU08AK5pHQieDX0gaJhYJEkwAtshJERZTEQQJNtEWk+qRJ04XUS7nKsorEiPFEhMagAxfwoAQ5ABWJSqFVgzHKiHqxwGwy4Y2+TU4AhgAyaGwa-SGIzGJHBUxm-DmCyWeJABNaxJAcRA0SAA

Which version of Stylelint or dependencies are you using?

{
  "stylelint": "latest",
  "stylelint-config-standard": "latest"
}

What did you expect to happen?

I expected a correct source index for both media queries.

ERROR Unexpected vendor-prefix (media-feature-name-no-vendor-prefix) [1:9-36]
ERROR Unexpected vendor-prefix (media-feature-name-no-vendor-prefix) [1:48-78]

What actually happened?

The source index for the first media query warning is offset by 3 characters.

ERROR Unexpected vendor-prefix (media-feature-name-no-vendor-prefix) [1:12-36]
ERROR Unexpected vendor-prefix (media-feature-name-no-vendor-prefix) [1:48-78]

Does the bug relate to non-standard syntax?

No response

Proposal to fix the bug

Update :

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

To :

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

Add extra tests :

{
	code: '@media (-webkit-min-device-pixel-ratio: 1) {}',
	fixed: '@media (min-device-pixel-ratio: 1) {}',
	message: messages.rejected,
	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 ( min--moz-device-pixel-ratio: 1) {}',
	fixed: '@media ( min-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,
},
@jeddy3 jeddy3 changed the title Incorrect error report source index for media-feature-name-no-vendor-prefix Fix media-feature-name-no-vendor-prefix positions for *-device-pixel-ratio Jun 25, 2023
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule labels Jun 25, 2023
@jeddy3
Copy link
Member

jeddy3 commented Jun 25, 2023

@romainmenke Thanks for the report and fix proposal.

I've labelled the issue as ready to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule
Development

Successfully merging a pull request may close this issue.

2 participants