-
-
Notifications
You must be signed in to change notification settings - Fork 942
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 function-no-unknown
false positives for unspaced operators against nested brackets
#6842
Conversation
…nst nested brackets
🦋 Changeset detectedLatest commit: 8cd0ee9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 have one quick question, but other than that this looks good to me - glad to see that the @csstools
packages are useful!
if (!isStandardSyntaxFunction(node)) { | ||
return; | ||
} |
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.
Since we've removed this check, is it possible that this rule will now flag errors for SASS/CSS-in-JS users? If so, I imagine that this might be slightly breaking for those users (and/or something we propagate to configs)?
(I could also be missing something about how SASS and CSS-in-JS play together with this rule, or with @csstools
)
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.
Good catch :)
module.exports = function isStandardSyntaxFunction(node) {
// Function nodes without names are things in parentheses like Sass lists
if (!node.value) {
return false;
}
if (node.value.startsWith('#{')) {
return false;
}
// CSS-in-JS interpolation
if (node.value.startsWith('${')) {
return false;
}
// CSS-in-JS syntax
if (node.value.startsWith('`')) {
return false;
}
return true;
};
None of those cases would be parsed as a FunctionNode
by @csstools/css-parser-algorithms
.
Only <ident><open-parenthesis>
(e.g. foo(
) starts a function in standard CSS.
This behavior makes isFunctionNode
the equivalent of isStandardSyntaxFunction
.
is it possible that this rule will now flag errors for SASS/CSS-in-JS users?
no
…unspaced-operators-against-nested-brackets--resourceful-kangaroo-ec239dde9a
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. I've suggested a tiny refactoring, but this PR sounds good. 👍🏼
Because postcss-value-parser
seems to stop maintenance, we may need to switch it to @csstools/css-tokenizer
to reduce dependencies.
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
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 👍🏼
Closes #6582
This change migrates this rule from
postcss-value-parser
to@csstools/css-parser-algorithms
.