-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Parse error for multiline object props on React components #435
Comments
Thanks for reporting issue by using the template, I'm on a vocation these days, I'll check later soon. |
It seems related to <button
style={{
display: "block",
}}
>
Test
</button> The assertion error is thrown at eslint-mdx/packages/eslint-mdx/src/worker.ts Line 491 in a1998c7
I'll check how to fix this with For text: <button
style={{
display: 'block'
}}
>
Test
</button>
I'll try to draft a simple reproduction for it. |
Hi @JounQin, thanks for all your great work and investigating this. Is there any new update on this? For now, do you recommend replacing all the tabs in our stories with spaces or waiting for a new fix to be released? |
Hey @mike-fam did you manage to work around this one? I'm facing the same thing. |
I investigated a bit this issue. With the following code: - list
<Components data={`
`} /> I also have the error This crashes because of this line: eslint-mdx/packages/eslint-mdx/src/worker.ts Line 413 in 9331895
When adding console.logs before and after I think that the reason of the offset is because when writing But the offsets start & end on the I'm not sure why the spaces are dropped in this estree (which comes from this processor
|
If I’m correct, this repo is mainly maintained by @JounQin. However, we haven’t heard from him in a while. Maybe we should create and pin a Looking for maintainers issue? |
@wooorm Sorry to ping again, but I think we need your help here. |
I dunno where this problem is, I’d appreciate a reduced test case. If it isn’t in |
Working on a minimal reproduction without |
@wooorm Please check https://github.com/JounQin/test/blob/mdx-tab/test.mjs#L29-L32 Besides, #435 (comment) could be another range issue not related to I tried /**
* @typedef {import('estree').Program} Program
* @typedef {import('estree-jsx').JSXElement} JSXElement
* @typedef {import('estree-jsx').JSXAttribute} JSXAttribute
*/
const root =
// @ts-expect-error
/** @type {Program} */ (acorn.Parser.extend(acornJsx()).parse(contents, {
ecmaVersion: 2020,
}))
const statement = root.body[0]
if (typeof statement === 'object' && statement.type === 'ExpressionStatement') {
const jsxElement = /** @type {JSXElement} */ (statement.expression)
const attribute =
/** @type {JSXAttribute} */ (jsxElement.openingElement.attributes[0])
console.log(attribute.value)
}
|
@JounQin did you see my above commit? |
@wooorm Thanks! It seems working to me now. @mike-fam @morganfeeney @Ayc0 Can you help to confirm? You may need to delete your |
I think that this is working for me too! Thank you very much! 🎉 (with yarn 2+, you can run |
Initial checklist
Affected packages and versions
2.0.5
Link to runnable example
https://github.com/mike-fam/eslint-mdx-multiline-prop-error
Steps to reproduce
eslint
witheslint-plugin-mdx
Parsing error: Expected value to be truthy
Expected behavior
The file should pass linting without any problems, as this is valid mdx syntax.
Actual behavior
Linting produces the following error:
0:0 error Parsing error: Expected value to be truthy
Runtime
Node v16, Node v14
Package manager
yarn v1
OS
macOS
Build and bundle tools
webpack
The text was updated successfully, but these errors were encountered: