mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-26 01:36:03 +03:00
[GH-ISSUE #410] Feature request: Suggest MD030 configuration when Prettier is detected (ex: tab width) #342
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#342
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 @tats-u on GitHub (Jul 3, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/410
https://github.com/prettier/prettier/issues/5019
Prettier, the most famous Markdown formatter, outputs "formatted" Markdown when tabwidth is not 2:
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBaABAMwhEAaECABxgEtoBnZUAQwCc6IB3ABXoSpRoBsmaBPKgQBGdGmADWcGAGUi40lADmyGHQCucAnAC2wuABMDhgDI1l6mkrgAxCHR00YZZchA11MXAQAWMHdwA6j6k8BTyYHAyHKGkAG6h-G5gFEIgihRwdDAsYkqOyJg8mQQAVhQAHgBCYpLSMjQ6cCaKcIXFWiDlFTKKStxwAIrqEPDt3CUg8nSZdG6OdBIGzFD4U3SKMIGkBjA+yAAcAAwERIyZgWJEbmdws3FtBACOI-C5xJzuFKhQcIaGazocBepCBuSsBSQRQmnUyOlIqg0sL6A2GozaUI6BBgNGE212+yQABZsWJSNw+gBhCA6SEgO4AVjW6kyABVcZxoZM4poAJJQYywGRgDYkACCApkMH4A3GmQAvvKgA
Input:
Output:
This behavior makes sense when item is multi-lined like:
May markdownlint disable or suggest disabling MD030 when Prettier is detected and tabwidth = 4 is used.
@DavidAnson commented on GitHub (Jul 3, 2021):
I'm not sure I agree that:
Makes more sense than:
Both are allowed by the specification, though I think the latter is more common in practice.
Good news is this is already configurable via the parameters for MD030: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md030---spaces-after-list-markers
I'm not sure how this library would determine that Prettier was going to be used or with what configuration?
Here's your example with no warnings: https://dlaa.me/markdownlint/#%25m%23%20Issue%20410%0A%0A-%20%20%20foo%20%20%0A%20%20%20%20bar%20%20%0A%20%20%20%20baz%0A-%20%20%20qux%20%20%0A%20%20%20%20quux%0A%0A%3C!--%20markdownlint-configure-file%20%7B%0A%20%20%22MD030%22%3A%20%7B%0A%20%20%20%20%22ul_multi%22%3A%203%0A%20%20%7D%0A%7D%20--%3E%0A
@nschonni commented on GitHub (Jul 3, 2021):
Under the hood, Prettier uses Remark for the formatting. I like some of the remark-lint rules, but their formatter is poor.
@tats-u commented on GitHub (Jul 4, 2021):
I agree so, and I am complained about Prettier's style and policy (does not append extra options in principle).
HackMD adopts the
- <item>style.Thank you for the information. This is what I have wanted. Can I change the title to something like "Feature request: suggest https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md030---spaces-after-list-markers in MD030 when Prettier is detected"?
packages.json-(*) and a item is<tabwidth> - 1(<tabwidth>); It may be useful that<tabwidth>is mostly one of (2,) 4, and 8@DavidAnson commented on GitHub (Jul 4, 2021):
As a library, this code does not sniff around the file system to guess what else might be installed. Here's the API it exposes for callers: https://github.com/DavidAnson/markdownlint#linting
We can discuss whether the CLI or the VS Code extension should look for the presence of other tools, but there are a number of ways Prettier might be configured, such as file, command-line, editor plugin, etc.. I'd rather not try to support the various ways that tool is configured.
In this case, there is a one-time configuration to match the list indent settings. I'd love for that to be even easier to find, but I'm not thinking that detecting Prettier is the best approach.
@tats-u commented on GitHub (Jul 5, 2021):
You are right. How about adding tips for Prettier users in https://github.com/DavidAnson/markdownlint/blob/v0.23.1/doc/Rules.md#md030 and https://github.com/DavidAnson/markdownlint#configuration? This seems much easier.
@tats-u commented on GitHub (Jul 5, 2021):
In addition to that, it would be good if I can confirm whether markdown can suggest changing settings when the length of spaces is
<tabwidth> - 1. (This has lower priority than tips for Prettier users)@DavidAnson commented on GitHub (Jul 5, 2021):
Good idea, I'll use this issue to track that.
@DavidAnson commented on GitHub (Jul 5, 2021):
I'm not sure I understand. Is the idea to detect if all the tabs are wrong in the same way and suggest a settings change?
@tats-u commented on GitHub (Jul 11, 2021):
Not everything has to be. I say just that, if everything is easier to implement, everything is better.