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] Ignore files specified in .gitignore #292

Closed
dmohns opened this issue Mar 15, 2024 · 4 comments
Closed

[Feature Request] Ignore files specified in .gitignore #292

dmohns opened this issue Mar 15, 2024 · 4 comments
Labels
enhancement New feature or request fixed in next Fixed in the "next" branch for the next release

Comments

@dmohns
Copy link

dmohns commented Mar 15, 2024

Description:

Make it possible for users to configure markdownlint-cli2 to ignore all files from .gitignore.

It could either be the default behaviour (which I personally find reasonable) but could also be a configurable option.

Use case:

It is quite common for repositories to generate files and folder which are external dependencies and where the repository owner do not have control over. Generally, people would add these to .gitignore file. For example node_modules or vendor.

Currently, when adding Markdownlint (via markdownlint-cli) to an existing repository users are overwhelmed with a lot of false-positives from gitignore'd directories. To circumvent, users have to configure markdownlint-cli accordingly, essentially, re-implementing their gitignore file again.

Further information:

@DavidAnson
Copy link
Owner

You've read my thoughts in #1 so I won't repeat them here - though they remain valid and need to be addressed.

You reference the behavior of prettier, but it uses a dedicated configuration file (not .gitignore) and similar functionality is already possible with this tool via .markdownlint-cli2.jsonc and the globs parameter.

What are some examples of common directories that appear in .gitignore and contain Markdown files? In my experience, there is typically just one directory like node_modules, vendor, etc. which is straightforward to handle.

@DavidAnson DavidAnson added the question Further information is requested label Mar 15, 2024
@dmohns
Copy link
Author

dmohns commented Mar 15, 2024

You reference the behavior of prettier, but it uses a dedicated configuration file (not .gitignore)

Prettier ignores all files/folders that are in root directories .gitignore. For example in a PHP project

{
  "name": "acme/hello-world",
  "require": {
    "laravel/laravel": "*"
  }
}
# .gitignore
vendor

Running prettier --check . with default configuration, it passes. After deleting .gitignore it complains a lot.

However, markdownlint-cli2 always complains.

and similar functionality is already possible with this tool via .markdownlint-cli2.jsonc and the globs parameter.

Yeah, it is clear to me that it is possible to implement arbitrary matching rules . However, what I'm asking/suggesting is a merely a user experience change.

Right now, users have to write a markdownlint-cli2 config file to reasonably use the tool. I think it's more inviting if users may write a config file to customise the behaviour of the tool to their needs.

Another way of saying is the following: From the discussion in #1 it sounded like it would be easy to implement this, if we limit ourselves to root ignore file(s) only (bear with me, if I misunderstood the point).

I (personally) think the UX gain from

  • supporting .gitignore-style ignore files in the root directory
  • defaulting to [ .markdownlintignore, .gitignore]

is huge. And outweighs the downside of not being able to properly adhere to cascading ignore files (which are not gitignored anyways 😂 ).

What are some examples of common directories that appear in .gitignore and contain Markdown files? In my experience, there is typically just one directory like node_modules, vendor, etc. which is straightforward to handle.

I can only speak for languages I'm familiar with

  • node_modules (JS)
  • vendor (PHP)
  • .venv/venv (Python)
  • .terraform/providers (Terraform`

But I'm sure most languages will have their own specific folders.

@DavidAnson
Copy link
Owner

Right now, users have to write a markdownlint-cli2 config file to reasonably use the tool.

No. Per the documentation and example: markdownlint-cli2 "**/*.md" "#node_modules". As most projects probably invoke this tool via script, it is easy to add additional ignore directories if needed. (Although your examples suggest most projects will only need to ignore a single directory.)

I'll leave this issue open for consideration for the next version. I need to revisit my previous comments and the options that are available nowadays. You propose enabling this behavior by default and .gitignore files are common, so it's important to me to make sure the performance impact is as small as possible. Nobody is using this feature today, but adding it will making everyone's experience slower.

@DavidAnson
Copy link
Owner

It looks like globby supports nested .gitignore handling. I’m not sure why this didn’t seem good to me before, but it looks appropriate to me now. I will try adding support for that, BUT I expect it will be off by default (at least for now). Maybe I will learn more as I write and test this.

@DavidAnson DavidAnson added enhancement New feature or request and removed question Further information is requested labels Mar 31, 2024
@DavidAnson DavidAnson added the fixed in next Fixed in the "next" branch for the next release label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed in next Fixed in the "next" branch for the next release
Projects
None yet
Development

No branches or pull requests

2 participants