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
Conversation
lib/rules/unit-no-unknown/index.js
Outdated
@@ -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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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:
if (/^(?:-webkit-)?image-set[\s(]/i.test(value)) { | |
if (/^(?:-webkit-)?image-set\b/i.test(value)) { |
Changelog entry:
|
Fixes #4653
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.