Skip to content
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

Feature request: Suggest MD030 configuration when Prettier is detected (ex: tab width) #410

Closed
tats-u opened this issue Jul 3, 2021 · 9 comments

Comments

@tats-u
Copy link

tats-u commented Jul 3, 2021

prettier/prettier#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:

- foo

Output:

-   foo

This behavior makes sense when item is multi-lined like:

-   foo  
    bar  
    baz
-   qux  
    quux

May markdownlint disable or suggest disabling MD030 when Prettier is detected and tabwidth = 4 is used.

@DavidAnson
Copy link
Owner

I'm not sure I agree that:

-   foo  
    bar  
    baz
-   qux  
    quux

Makes more sense than:

- foo  
  bar  
  baz
- qux  
  quux

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
Copy link
Contributor

nschonni commented 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
Copy link
Author

tats-u commented Jul 4, 2021

I think the latter is more common in practice.

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.

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

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"?

how this library would determine that Prettier was going to be used or with what configuration

  1. Examine packages.json
  2. Branch with if length of spaces between - (*) and a item is <tabwidth> - 1 (<tabwidth>); It may be useful that <tabwidth> is mostly one of (2,) 4, and 8

@DavidAnson
Copy link
Owner

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.

@DavidAnson DavidAnson changed the title MD030 does not compatible with Prettier when tabwidth is not 2 Feature request: Suggest MD030 configuration when Prettier is detected (ex: tab width) Jul 4, 2021
@tats-u
Copy link
Author

tats-u commented 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
Copy link
Author

tats-u commented 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
Copy link
Owner

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.

Good idea, I'll use this issue to track that.

@DavidAnson
Copy link
Owner

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)

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
Copy link
Author

tats-u commented Jul 11, 2021

Is the idea to detect if all the tabs are wrong in the same way and suggest a settings change?

Not everything has to be. I say just that, if everything is easier to implement, everything is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants