-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Implement parser switching (HTML, Vue, styled-components) #2086
Conversation
class Foo<T> { | ||
constructor(private foo: keyof Apple) {} | ||
} | ||
|
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'm aware of the trailing hardline
but I don't know a way to remove it without hacking it out of the doc.
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.
The CSS piece is hacking the doc. I think the "right" thing to do is to make printers not output a final hardline and have the outer format call add it.
if ( | ||
ast.type === "TaggedTemplateExpression" && | ||
ast.tag.type === "MemberExpression" | ||
) { |
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 not enough. Relay.QL would match. I think you need to check if the left is style
or the right is extends
.
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.
Oops, this is in clean-ast!
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'll copy across the logic from the other file.
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.
No worries, I actually think it's a good idea to make this one lose, and not have them synced.
This is huge! You're on fire! Keep going :) |
Awesome! |
Go ahead! I honestly have no idea how that will work... |
This PR introduces a general method for switching between different parsers in the middle of a print.
To prove the concept, I have implemented:
<style>
<script>
<script lang="ts">
I also moved the existing styled-jsx support (#1984) to the new method.
Currently, styled-components and styled-jsx are only formatted if there are no expressions in the template string.
#1948, #1882.