feat: use eslint-plugin-mdx for md/mdx files#353
Conversation
3b1f334 to
8a3bd14
Compare
8a3bd14 to
dd8d570
Compare
dd8d570 to
336e453
Compare
| @@ -1,32 +1,33 @@ | |||
| # @antfu/eslint-config | |||
| @antfu/eslint-config | |||
There was a problem hiding this comment.
I think they're removed unexpectedly.
| const patchedParser: Linter.ParserModule = { | ||
| ...mdxParser, | ||
| parse(text, options) { | ||
| // @ts-expect-error cast | ||
| const result = mdxParser.parseForESLint!(text, options) | ||
| const body = result.ast.body | ||
|
|
||
| function predicate(token: { start: number, end: number }) { | ||
| for (const node of body) { | ||
| if (node.start <= token.start! && node.end >= token.end!) | ||
| return true | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| // `eslint-mdx` produces extra tokens that are not presented in the AST, causing rules like `indent` to fail | ||
| result.ast.tokens = result.ast.tokens.filter(predicate) | ||
| result.ast.comments = result.ast.comments.filter(predicate) | ||
|
|
||
| return result | ||
| }, | ||
| } |
There was a problem hiding this comment.
According to eslint-stylistic/eslint-stylistic#215
This patch is the closest thing I could fix, but the formatting for mdx is still not ideal.
I think I have spent too much time on working around it. I rather not have it or something in a broken state. I am giving it up at this moment, but I am open to revisiting it later if the compatibility gets better in the future.
Thanks for your effort!
There was a problem hiding this comment.
I don't understand, why not just disable indent temporarily for .md/.mdx files.
There was a problem hiding this comment.
In this commit, even the tests are passing, you see that mdx is basically not formatted at all.
There was a problem hiding this comment.
Because prettier does not support mdx v2/v3 well?
There was a problem hiding this comment.
Ok, looking forward to see it get fixed! 👍
|
I am okay with keeping this PR open for future reference, or feel free to close it. |

Description
Enable
eslint-plugin-mdxto replace simpleeslint-plugin-markdownLinked Issues
N/A
Additional context