-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Parsing error when a component is used within a markdown list #279
Parsing error when a component is used within a markdown list #279
Comments
Please provide a minimal runnable reproduction. |
Here you go: https://github.com/LeBenLeBen/eslint-mdx-repro-279
|
@wooorm I tried to parse the following: - <div kind="docs-packages-vuetify-preset" story="page">
Vuetify preset
</div>
: some extra text describing the preset And logged And the log is following:
So it seems to be an issue of |
@LeBenLeBen Temporary workaround: <!-- prettier-ignore -->
- <div kind="docs-packages-vuetify-preset" story="page">
Vuetify preset
</div>
: some extra text describing the preset Sorry, I can't fix it easily due to |
@wooorm I have to do something like following, I don't know if it is as expected: combineLeftJsxNodes(jsxNodes: Node[], parent?: Parent): Node {
const start = jsxNodes[0].position.start
const end = { ...last(jsxNodes).position.end }
// fix #279
if (parent.type === 'listItem') {
end.offset += parent.position.indent.reduce(
(acc, indent, index) => acc + (index ? indent + 1 : 0),
0,
)
}
return {
type: 'jsx',
data: jsxNodes[0].data,
value: this.code.slice(start.offset, end.offset),
position: {
start,
end,
},
}
} |
Parsing it at least works on main, and maybe on the last v2 beta. @JounQin |
@wooorm I'm fine to start working on next version, but I'd like to fix this error on current stable version too. I want to confirm if my fix will always work, or, can you patch a fix on |
I do not know if your fix will always work, maybe? |
@LeBenLeBen Please try |
Perfect, it works now. Thank you for looking into this so quickly 💯 |
Subject of the issue
The following code:
Trigger an error on line 3:
Adding an empty line between the last two lines fixes the issue, but the rendered output is not the same. Also putting it all in a single line works, but it’s not "Prettier compliant" and gets reformatted on multiple lines. If the same code is placed at the root (not within a markdown list), it works as well.
It does pretty much the same with a regular element instead of a component, but the error is different:
Note that the code compiles properly, the problem is only at EsLint level.
Your environment
The text was updated successfully, but these errors were encountered: