mdx-js / eslint-mdx

ESLint Parser/Plugin for MDX
https://npmjs.org/eslint-plugin-mdx
MIT License
264 stars 32 forks source link

`Parsing error: unknown jsx node` when newlines are between nested jsx nodes AND there are JavaScript statements in the file (follow-up to #272) #367

Closed lpsinger closed 2 years ago

lpsinger commented 2 years ago

Initial checklist

Affected packages and versions

1.16.0

Link to runnable example

https://codesandbox.io/s/crazy-bhaskara-8y512?file=/src/test-line-between.mdx

Steps to reproduce

Example 1, no whitespace between nested JSX nodes:

function foo() {
  return 'bar'
}

<div>
  <p>test</p>
  <p>test</p>
</div>

Example 2, whitespace present in nested JSX nodes:

function foo() {
  return 'bar'
}

<div>
  <p>test</p>

  <p>test</p>
</div>

Expected behavior

Both examples should lint without any errors.

Actual behavior

Example 2 fails with the error Parsing error: unknown jsx node.

Runtime

Node v14

Package manager

npm v8

OS

macOS

Build and bundle tools

No response

vaibhavshn commented 2 years ago

Same error occurs for me when I use md inside JSX nodes.

Example:

<MyComponent>

```js
console.log()



And if I remove the codeblock inside the component, the error goes away.

![image](https://user-images.githubusercontent.com/6205961/153544264-36d65a3c-a8de-4dea-b740-a98f886cabc2.png)

`Parsing error: unknown jsx node: "<Tabs\n  groupId=\"android-language\"\n  defaultValue=\"kotlin\"\n  values={[\n    { label: 'Kotlin', value: 'kotlin', },\n    { label: 'Java', value: 'java', },\n  ]\n}>\n<TabItem value=\"kotlin\">"`
JounQin commented 2 years ago
# yarn 1
yarn add https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx
# yarn 2, 3
yarn add eslint-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx/_pkg.tgz eslint-plugin-mdx@https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx/_pkg.tgz
# npm
npm i https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-mdx https://pkg.csb.dev/mdx-js/eslint-mdx/commit/abdc9db9/eslint-plugin-mdx

Please help us to test the fresh new version.