-
-
Notifications
You must be signed in to change notification settings - Fork 24
Added style AST to SvelteStyleElement #318
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
Conversation
I think this is actually ready now - currently there are parsers only for CSS and SCSS, but others can easily be added later (I am eyeing LESS and stylus...). |
parseFn = SCSSparse; | ||
break; | ||
default: | ||
console.warn(`Unknown <style> block language "${lang}".`); |
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.
This is probably not the right thing to do...
I don't think it's compatible with ESLint yet. The tokens parsed by Even if I did build an AST for SCSS, I don't think the rules would be able to handle the AST very well because we don't do any preprocessing. @mixin define-emoji($name, $glyph) {
span.emoji-#{$name} {
font-family: IconFont;
font-variant: normal;
font-weight: normal;
content: $glyph;
}
}
@include define-emoji("women-holding-hands", "👭"); https://sass-lang.com/documentation/style-rules I'm still against having a parsed AST for |
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for the comments :)
I think that without parsing
Hmm, if I understand this correctly, the So far, I have refrained from any modifications to the parser, I agree that that would be a road to hell... However, I don't see how that's needed, apart from the issue with comments - am I missing something? And as to your example - you're right, that would make it extremely hard to extract the class name. But the same thing happens with <script lang="ts">
export let classValue: string;
</script>
<div class={classValue} /> I would be OK with this, but I understand if you are not... |
We need the AST parsed by The Comment nodes are not generated when the following CSS is parsed by a /* comment */ b {
color: /* comment */ red;
} |
Hmm, ok, that's an issue, however I think it's a solvable issue.
Which processor? Postcss? 😄 We'd need to configure that processor the same way
Yeah, you're right that we could just do that (modulo the processor stuff). But then every plugin and every rule touching Ok, I'm willing to do the work to make this compatible with the ESLint AST, fix the Anyway, thanks for the feedback! |
I intended it to mean a "processor" that converts from SCSS, Sass, Less, and Stylus, etc. to CSS.
It's an idea I just came up with, but it might be better to provide the What do you think? |
Thanks, I think using the services is a great idea - we wouldn't have to worry about AST compatibility and could still provide the AST to rules in one place. About the preprocessors - Do you see any advantage to providing the AST of the resulting CSS instead of the original? Because code wise, both mean we have to handle custom style languages, so we have to deal with that complexity either way... |
I don't think we can extract the class names used from the following SCSS without using preprocessors. @mixin define-emoji($name, $glyph) {
span.emoji-#{$name} {
font-family: IconFont;
font-variant: normal;
font-weight: normal;
content: $glyph;
}
}
@include define-emoji("women-holding-hands", "👭"); |
Yeah, that's right... :/ On the other hand, most of the time you'd probably want the original AST rather than the transpiled one. We could obviously provide both, but that seems to be a bit overkill... |
|
Obsoleted by #340 |
Fixes #317