mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #525] MD011: should not be triggered by content of inline code span #2275
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2275
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lenormju on GitHub (May 12, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/525
Using
markdownlint demo (v0.25.1):gives me the error :
3 -MD011 / no-reversed-linksReversed link syntax [(' ')[-1]]I think my inline Python code should not be considered a link, so the rule should not be triggered by the content of an inline code span.
@DavidAnson commented on GitHub (May 14, 2022):
Are you seeing this running under Node, or just in the web demo app? There are existing tests to verify your scenario behaves correctly in Node, so I think you're probably only seeing it in the browser? It seems to me at the moment this is a Webpack bug - here's why...
The original code is:
github.com/DavidAnson/markdownlint@2d19c0685b/helpers/helpers.js (L572)That runs as-is under Node and behaves correctly per the existing tests, ignoring the content of the code span. That pattern matches this example in the documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries#iterating_with_index_and_element
However, after being transformed by Webpack, that code looks like this:
github.com/DavidAnson/markdownlint@2d19c0685b/demo/markdownlint-browser.js (L565)Note that it's trying to access the
lengthproperty on the iterator returned byentries(). But that's not defined for iterators and is thereforeundefinedand so the loop does not run:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol
It's hard to imagine I'm the first to run into this, so it may be a configuration issue on my part? At the same time, I don't see how the generated code is valid under an older ES version. I'm still investigating...
@DavidAnson commented on GitHub (May 14, 2022):
After a bit more research, this problem coming from TypeScript (via
ts-loader), not Webpack. When using the default target ofES3(https://www.typescriptlang.org/tsconfig#target), TypeScript doesn't know what iterators are and translatesfor..ofto uselengthin all cases: https://www.typescriptlang.org/docs/handbook/iterators-and-generators.html#targeting-es5-and-es3@Lenormju commented on GitHub (May 17, 2022):
I first encountered the bug on my own computer. But I can't upgrade to the latest version (because reasons) so I used the online demo to reproduce it. Also, I was a bit confused between the different parts (lint, cli, ...) so I preferred to indicate that it was reproducible with the demo, which I guessed you know well.
I'm using
pre-commit 2.15.0(pre-commit -V) to invokeMarkdownLint Command Line Interface 0.29.0(markdownlint -V) which relies onmarkdownlint@0.24.0andmarkdown-it@12.2.0(npm list -g).I suggest you put instructions on how to get all these info in the Issue template, so that users confused like me by the different parts can easily provide you the info you need :)
@DavidAnson commented on GitHub (May 17, 2022):
What version of Node.js? Pre-commit prefers deprecated versions in some cases.
@Lenormju commented on GitHub (May 18, 2022):
v14.18.1(fromnode --version)@DavidAnson commented on GitHub (May 18, 2022):
I'd expect that to work. I'll try to reproduce this using the same CLI version. It's possible that predates ignoring code spans or perhaps there was a fix since then.
@DavidAnson commented on GitHub (May 19, 2022):
I don't see that behavior with Node 14 and markdownlint-cli 0.29.0 and your original example:
However, I'm not going to spend more time here as the reproduction I did have should now be fixed.
@Lenormju commented on GitHub (Jul 6, 2022):
I can't update the versions I use on my computer (because reasons) but it looks like it is now fixed in
markdownlint demo (v0.26.0)👍