mdx-js / eslint-mdx

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

`'` can be escaped with `'`, `‘`, `'`, `’`. #331

Closed chenxsan closed 3 years ago

chenxsan commented 3 years ago

Subject of the issue

Using ' in javascript code block inside mdx shows an error as the title:

<div>
```js
import foo from './foo.js'
```
</div>

Your environment

Steps to reproduce

  1. Clone code from https://github.com/webpack/webpack.js.org/pull/5233
  2. Run yarn to install
  3. open src/content/index.mdx, and append code below:
<div>
```js
import foo from './foo.js'
```
</div>

Expected behaviour

No lint error.

Actual behaviour

A lint error.

JounQin commented 3 years ago

See https://github.com/mdx-js/eslint-mdx/issues/207#issuecomment-782716731

Short answer, it can not be fixed in eslint-plugin-mdx@v1, and I don't have time to work on v2 temporarily.

Workaround:

<!-- eslint-disable react/no-unescaped-entities -->

<div>
```js
import foo from './foo.js'

JounQin commented 3 years ago

Or:

<!-- example.mdx -->
```js
import foo from './foo.js';

````mdx
<!-- index.mdx -->
import Example from './example.mdx'

<div>
  <Example />
</div>
chenxsan commented 3 years ago

Or:

<!-- example.mdx -->
```js
import foo from './foo.js';

```gfm
<!-- index.mdx -->
import Example from './example.mdx'

<div>
  <Example />
</div>

Yeah, this is how I work around it at the moment.