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 false positives for x unit within vendor-prefixed image-set in unit-no-unknown #4654

Merged
merged 2 commits into from Apr 3, 2020

Conversation

srawlins
Copy link
Contributor

Which issue, if any, is this issue related to?

Fixes #4653

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.

However, I'm not super familiar with the ASTs involved, and I'm super open to suggestions if this is not an optimal fix.

@@ -116,8 +117,10 @@ function rule(actual, options) {
return;
}

if (/^image-set/i.test(value)) {
const imageSet = parsedValue.nodes.find((node) => node.value === 'image-set');
if (/image-set/i.test(value)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think better /^(?:-webkit-)?image-set$/i, because in theory we can have image-set-something() function (yes, it is not exists in CSS), but strict check always better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding $ at the end does not work here because of what we're matching on. I was able to use [\s(] to delimit the end of the function name.

Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request.

Yes, let's go with tweaking the RegEx.

I think we'll be fine with /^(?:-webkit-)?image-set$/i as only the -webkit prefix is currently used.

@jeddy3 jeddy3 changed the title Allow 'x' unit on vendor-prefixed image-set Fix false positives for x unit within vendor-prefixed image-set in unit-no-unknown Mar 20, 2020
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jeddy3 jeddy3 mentioned this pull request Apr 2, 2020
6 tasks
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -116,8 +117,10 @@ function rule(actual, options) {
return;
}

if (/^image-set/i.test(value)) {
const imageSet = parsedValue.nodes.find((node) => node.value === 'image-set');
if (/^(?:-webkit-)?image-set[\s(]/i.test(value)) {
Copy link
Member

Choose a reason for hiding this comment

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

[IMO] If using \b (word boundary), the intent of the code may be clear.

For example:

Suggested change
if (/^(?:-webkit-)?image-set[\s(]/i.test(value)) {
if (/^(?:-webkit-)?image-set\b/i.test(value)) {

@jeddy3 jeddy3 merged commit fa24482 into stylelint:master Apr 3, 2020
@jeddy3
Copy link
Member

jeddy3 commented Apr 3, 2020

Changelog entry:

  • Fixed: unit-no-unknown false positives for x unit within vendor-prefixed image-set (#4654).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Fix false positives for vendor-prefixed image-set w/ unit "x" in unit-no-unknown
4 participants