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

Allow enforcing tabs over spaces #82

Closed
JoshuaKGoldberg opened this issue Oct 22, 2017 · 13 comments
Closed

Allow enforcing tabs over spaces #82

JoshuaKGoldberg opened this issue Oct 22, 2017 · 13 comments
Labels

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Oct 22, 2017

For teams where the code style is tabs instead of spaces, linting needs a way to enforce that 4x gets replaced with tabs.

@DavidAnson
Copy link
Owner

That would seem to be in conflict with: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md010

I prefer tabs semantically, but tend to feel that documentation (Markdown) should render as uniformly as possible (spaces). Do you have a specific example of where tabs would be necessary in Markdown?

@JoshuaKGoldberg
Copy link
Contributor Author

Not necessary, but practical. My use case is that my team at work uses tabs everywhere and wants to keep it standard in all our files.

@sensibleish
Copy link

The Markdown spec at https://daringfireball.net/projects/markdown/basics contains the string "4 spaces or 1 tab" twice. Lint rule MD010 doesn't seem valid, at least not as a blanket rule.

@DavidAnson
Copy link
Owner

@giskard22 I agree with your reading of the specification. That said, there are many projects that impose additional standards and forbidding tab characters like MD010 does is somewhat common. Linking tools will often go beyond what’s allowed by the specification in order to standardize, avoid unwanted practices, and so on. For scenarios where rule MD010 does not apply, it can be disabled.

@NatoBoram
Copy link

NatoBoram commented Mar 6, 2018

You having seen "many projects" imposing different standards shouldn't undermine the usability of your project. Linting tools shouldn't promote unwanted practices nor force different standards.

MD010 simply never applies. It should be a toggle between spaces or tabs.

@DavidAnson
Copy link
Owner

I’ll look at deprecating/replacing this rule in a future release.

@DavidAnson
Copy link
Owner

As I research this more, rule MD010 seems easy to define and implement - but the opposite rule to enforce tabs instead of spaces seems more ambiguous and open to debate.

http://spec.commonmark.org/0.28/#tabs

Many places where a tab could be used are not places I think everyone would agree it should be used, so I think the proposed rule to enforce tabs may need multiple options to support every scenario.

So I will leave this issue as a request to add a new rule for tabs. And separately, I will look at disabling MD010 by default to avoid being too opinionated out of the box.

@sww1235
Copy link

sww1235 commented May 9, 2021

I would like to chime in on this, even though it is over 2 years old at this point and add a request for supporting tabs as well.

I would propose that the following rules are modified with a rule to check for tabs, spaces, or consistent styling.

  • MD007
  • MD010
  • MD030

adding a consistent option to MD010 might be easier than dealing with a bunch of language specific options like in #383

Thank you

@groenroos
Copy link

+1 for implementing a new rule for enforcing indentation with tabs instead of spaces!

While space indentation may be more common in Markdown, I think in a large multi-language project, it's more important that the coding style is fairly consistent across the whole project, rather than orthodox to each individual language.

@AramZS
Copy link

AramZS commented Feb 15, 2023

+1 to tabs over spaces though I will note that YAML requires spaces, so as long as it doesn't mess with the YAML blocks.

@NomarCub
Copy link

NomarCub commented May 5, 2023

@JoshuaKGoldberg
Copy link
Contributor Author

JoshuaKGoldberg commented May 6, 2023

Huh, I'd forgotten that I filed this issue. Since filing it I've come to the conclusion that a linter should not be used for formatting concerns such as enforcing tabs vs spaces. Closing this issue and unsubscribing from it, as I use Prettier or dprint to enforce formatting instead of markdownlint.

As of #594, you can use a built-in Markdownlint style/prettier.json (equivalent to eslint-config-prettier) to disable all formatting rules in Markdownlint:

// .markdownlint.json
{
    "extends": "markdownlint/style/prettier"
}

I've got a longer blog post about it here: https://blog.joshuakgoldberg.com/configuring-markdownlint-alongside-prettier (apologies for the shameless self promotion).

If someone else wants to file a new version of this issue, nothing's stopping you. Just know that I'll silently judge you for using a linter for formatting! 😉

@NomarCub
Copy link

NomarCub commented May 6, 2023

I appreciate your post, but I disagree.

  • I don't want one more tool just to enforce this rule.
  • Tabs are not purely syntactic in markdown, they are basically significant whitespace, so this rule is a linting issue, not a formatting one only.
  • Prettier is too opinionated, generic, and not configurable enough for markdown - see this example.

There's been some valuable discussion on this here, and others still want the feature, so please reopen this issue @JoshuaKGoldberg.
Also, thank you for the useful links, never heard of dprint before!

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

No branches or pull requests

8 participants