[bug] `blocks` will be reset on `preprocess` every time and will break `.md` in `.md`
JounQin opened this issue · comments
The will not work when writing markdown codes in code blocks.
Lifecycle:
preprocess('.md') -> preprocess('.md/0_0.md') -> postprocess('.md/0_0.md') -> postprocess('.md')
This was not a problem before because .md
files are not linted by eslint before. By adding esling-plugin-mdx
which support .md
files, it will be a problem.
Originally posted by @JounQin in #178 (comment)
It's clear to be an bug
https://github.com/eslint/eslint-plugin-markdown/blob/main/lib/processor.js#L219
Thanks for opening this so we can dig in. I think I follow what you're saying, but to be sure, can you provide an example Markdown document that triggers the bug?
This issue will only occur when integrating with other plugins like eslint-plugin-mdx
which will lint original .md
files by preprocess
too.
Here is the fake version for testing.
So maybe I shouldn't flag it as bug but a better compatibility with other markdown related ESLint plugins based on eslint-plugin-markdown
.
This seems related to https://github.com/eslint/eslint/pull/14227/files#r602802758. I can reproduce this today in a test if I configure this plugin to run on .md
and .markdown
files and have a README.md
file containing a markdown
code block. If #14227 changes ESLint to run processors directly recursively, this would be even easier to reproduce.
Yes, I should simplify the test case in current PR.