markdownlint-cli icon indicating copy to clipboard operation
markdownlint-cli copied to clipboard

Make ignores and files to include part of the configuration

Open borekb opened this issue 7 years ago • 7 comments

The config file (.markdownlint.json), if I understand it correctly, is the options.config object. In the API, options have other keys like files or customRules.

Would it be possible to use this in .markdownlint.json as well? Especially, I'd use it to denote certain directories as ignored. This is probably not supported by the underlying API at this point but I imagine something like this:

// .markdownlint.json
{
  "ignore": [
	"node_modules"
  ],
  "config": {
	"MD026": false
  }
}

borekb avatar Aug 07 '18 12:08 borekb

Your understanding is correct: .markdownlint.json is for configuring rules (only). This allows it to be shared by multiple tools (like this CLI and the VS Code extension) even when those tools have different ways of configuring and applying options. What you propose is possible, but needs some thought and coordination to do well.

DavidAnson avatar Aug 07 '18 16:08 DavidAnson

This would be a nice to have.

There are some other proposals that are similar in #46 but those require adding additional files to our repos which I'd rather not do, we already have a huge number of dot files in the root for different tools and adding another would just further pollute it.

jwalker343 avatar Apr 23 '19 13:04 jwalker343

@DavidAnson Has there been any thought on how some of these thing might be done? I have a need to pass a list of plugins to markdownlint and I currently use the cli to run it. We use a plugin for tables that support different syntax, so without passing the plugin we can't actually use linting for the tables.

If there is an acceptable approach, I could code some or all of the next step.

JimPatterson avatar Jul 08 '20 19:07 JimPatterson

I’m part-way through a side project experiment that may help with this scenario. I should be in a position to share something rough in a week or so.

DavidAnson avatar Jul 08 '20 19:07 DavidAnson

@borekb @jwalker343: I've just published version 0.0.3 of https://github.com/DavidAnson/markdownlint-cli2

It's a slightly different take on a CLI, please see the README for context. Relevant to this thread, it supports a unique .markdownlint.json in each directory. It also supports customizing the options object for each directory. It handles ignoring files a little differently - you could either pass the right combination of including/excluding globs on the command-line OR use a .markdownlintignore in the root of the project to ignore specific directories.

@JimPatterson: markdown-it plugins aren't supported in that version, but will be in the next one which I expect to publish soon. Custom rules are supported and can be different for each directory - plugins will be handled similarly.

If you try this out, please let me know how it goes - thanks!

DavidAnson avatar Jul 31 '20 21:07 DavidAnson

Thanks for the info. Note that a single, root-level ignore file can be a maintenance pain point in larger repos, see e.g. these feature requests for Prettier and ESLint:

  • https://github.com/prettier/prettier/issues/4081
  • https://github.com/eslint/eslint/issues/13389

But any improvements in this area are welcome (though I won't be able to test the new behavior soon, sorry).

borekb avatar Aug 02 '20 13:08 borekb

@JimPatterson, plugins are supported in the latest version and can vary by directory. If you try this out, please let me know how it goes!

DavidAnson avatar Aug 13 '20 02:08 DavidAnson