eslint / eslint-plugin-markdown

Lint JavaScript code blocks in Markdown documents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using this with prettier

simlu opened this issue · comments

Using this in combination with eslint-plugin-prettier.

It appears since the linebreaks are stripped, we can't satisfy prettier?

For a code block

\`\`\`js
const a = "";

\`\`\`

I always get the error:

error Insert "⏎" prettier/prettier

Wondering if we can just fix this by adding a new-line before checking. What is the "correct" solution here?

Relevant:
https://github.com/eslint/eslint-plugin-markdown/blob/master/lib/processor.js#L13

Opened a pr adding in the line break. Would appreciate timely feedback since this is blocking for us.

Is prettier even really meant to work with code blocks (as opposed to files)? I would say you should just use config overrides to disable prettier/prettier from markdown files, at least as a short-term solution.

@platinumazure We lose so much by disabling that.

(1) Prettier is designed to work on markdown syntax. So that would be completely disabled

(2) Prettier replaces eslint formatting. So to use prettier one needs to disable eslint formatting rules. That means we would effectively disable all formatting checks for code blocks in markdown.

Hence that is not really an option.

@simlu Okay, thanks for explaining.

In that case, I'll ask you to please remember that this project, like many open source projects, is maintained on a volunteer basis, and so things will not always move at the speed you want to. Please give the maintainer a few days to evaluate this. Thanks!

Thanks for your patience and putting the pull request together, @simlu! I just released v1.0.0-rc.1 that included your change.

Sweet! Thank you very much!