-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaks with eslint-plugin-markdown #22
Comments
Hi! I've never used eslint-plugin-markdown before. Can you show me how you set things up? The best thing would be a small reproduction repo. |
module.exports = {
extends: [],
plugins: [
'simple-import-sort',
'markdown',
],
rules: {
'simple-import-sort/sort': 'error',
},
overrides: [
{
files: ['**/*.md'],
parserOptions: {
ecmaFeatures: {
impliedStrict: true,
},
},
rules: {
'simple-import-sort/sort': 'error',
},
},
],
} Some text
\\```js
import b from 'b'
import a from 'a'
\\``` |
Couldn’t you have bothered to post something that actually works? 😢 Anyway, after fighting ESLint’s configuration for a while I finally made it work and could reproduce the issue. But now I lost my steam for working on the bug. Some text
```js
import b from 'b'
import a from 'a'
``` is autofixed to: import a from 'a'
import b from 'b'
``` In other words, everything before the first |
Discovery: The issue only seems to occur when the autofix applies from the very beginning of the code block (index 0). For example: Some text
```js
;import b from 'b'
import a from 'a'
``` successfully autofixes to: Some text
```js
;import a from 'a'
import b from 'b'
``` Feels like a bug in eslint-plugin-markdown. I need to investigate further. |
Previously, if a rule added an autofix at index 0 of a code block, all code from the start of the markdown file until the start of that code block would be removed. Now, the autofix is applied as expected. Fixes lydell/eslint-plugin-simple-import-sort#22
Previously, if a rule added an autofix at index 0 of a code block, all code from the start of the markdown file until the start of that code block would be removed. Now, the autofix is applied as expected. Fixes lydell/eslint-plugin-simple-import-sort#22
If the replacement text of an autofix contains newlines, all lines but the first in the replacement text will unexpectedly have 0 indentation if a code block is indented. I guess not only the _range_ of fixes but also the _text_ of fixes need to be adjusted. If the code block is placed within a blockquote, a `>` character also needs to be inserted. This issue was found while investigating lydell/eslint-plugin-simple-import-sort#22. That plugin several lines of imports in one go. This means that most of the imports will have too little indentation after autofix if the code block is indented (such as when placed in a list).
Previously, if a rule added an autofix at index 0 of a code block, all code from the start of the markdown file until the start of that code block would be removed. Now, the autofix is applied as expected. Fixes lydell/eslint-plugin-simple-import-sort#22
eslint/eslint-plugin-markdown#119 has been merged, so the next version of eslint-plugin-markdown should not cause removals of markdown above imports anymore. You might still run into eslint/eslint-plugin-markdown#120, though. |
* Chore: Add failing test case for indent of multiline fixes If the replacement text of an autofix contains newlines, all lines but the first in the replacement text will unexpectedly have 0 indentation if a code block is indented. I guess not only the _range_ of fixes but also the _text_ of fixes need to be adjusted. If the code block is placed within a blockquote, a `>` character also needs to be inserted. This issue was found while investigating lydell/eslint-plugin-simple-import-sort#22. That plugin several lines of imports in one go. This means that most of the imports will have too little indentation after autofix if the code block is indented (such as when placed in a list). * Fix: Indent multiline fixes (fixes #120) * Add test for underindented multiline autofix * Add test for nested blockquote multiline autofix * Add comment explaining underintented line shift
v1.0.1 of eslint-plugin-markdown has been released! All the above issues should be fixed. I have some uncommitted test that I need to finish up, then we can close this issue. |
https://github.com/eslint/eslint-plugin-markdown
Parsed some markdown files and totally mangled them. Easy to turn off the rule for markdown but other rules (like
import/order
) seemed to manage the individual code blocks well.The text was updated successfully, but these errors were encountered: