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: Unexpected token, expected "}" #334

Closed chenxsan closed 3 years ago

chenxsan commented 3 years ago

Subject of the issue

Here's the content of a mdx file:

<div>
  <img />
</div>

```js
module.exports = {
  plugins: [],
};
```

And eslint would report an error shown below:

error

Now if I prepend a paragraph, e.g.,

hello world.

<div>
  <img />
</div>

```js
module.exports = {
  plugins: [],
};
```

Now the error would be fixed.

Your environment

Steps to reproduce

  1. clone code from https://github.com/webpack/webpack.js.org/pull/5298
  2. add a src/content/mdx.mdx file with below content:
<div>
  <img />
</div>

```js
module.exports = {
  plugins: [],
};
```
  1. run npx eslint src/content/mdx.mdx

Expected behaviour

No error.

Actual behaviour

An error shown.

JounQin commented 3 years ago

Thank you, I can reproduce it locally.

Workaround temporarily:

<div>

<img />

</div>
JounQin commented 3 years ago

@chenxsan Please try

yarn add -D https://pkg.csb.dev/mdx-js/eslint-mdx/commit/a2199654/eslint-plugin-mdx
chenxsan commented 3 years ago

@JounQin Works fine now.