Config file in $HOME is not identified
rogerluan opened this issue Β· comments
Hi π
I'm trying this out and I placed my .markdownlintrc
in $HOME/.markdownlintrc
(aka ~/.markdownlintrc
), but it's not able to pick it up. I read the config placement rules in https://www.npmjs.com/package/rc#standards but that seems to be related to npm projects, which have a name, so I think it doesn't really apply. My $HOME
is a parent folder of the current directory, and there are no other .markdownlint*
files anywhere in my computer.
Any hints of what could be the issue?
Thanks in advance!
That should work. How do you know it's not being used? Can you show an example?
So I have a README file that has line length (MD013
) issues. If I run
markdownlint -- README.md
Then it points out those MD013
issues.
But if I run:
markdownlint --config $HOME/.markdownlintrc -- README.md
Then it correctly picks up my config where I've set MD013: false
, then it doesn't throw linter errors for line length.
My config file is identical to the sample/template one in the documentation, except I replaced the MD013 config with:
# MD013/line-length - Line length
MD013: false
For documentation purposes, the directly where I'm running the command is
$HOME/Documents/Projects/some-folder/
And the .markdownlintrc
file is in $HOME
That all sounds right to me, tho I don't do this myself. I will give it a try later today. What platform, by the way?
Thank you!
macOS 12.4, do you need any other env dump? I installed via brew btw. No node.js project
The INI format uses =
, not :
, so your .markdownlintrc
should be:
# MD013/line-length - Line length
MD013 = false
If you make that change, it should behave as you expect.
Interestingly, things work when you pass --config
because that uses the markdownlint
library to parse the configuration file which supports YAML
where :
is valid.
@DavidAnson The entire file is in yaml though π You can find it here: https://github.com/rogerluan/dotfiles/blob/master/.markdownlintrc
Just as a side note now that I shared my actual file with you βοΈ my dotfiles repo uses a symlink for that .markdownlintrc
file, but that doesn't matter because I also tested this by placing the actual file in that location (without a symlink) and the results were the same π¬
And just as an extra data point, I pulled the sample from the yaml sample, not ini: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
Also, I looked for a debugging option like --verbose
, --debug
, etc, to hopefully print more logs when executing the command, but there's none π is there any env var I can set when executing it, to print logs that would help us debug this issue?
@DavidAnson I may have misunderstood your previous message though, are you saying that when I place my config file in the $HOME dir, this specific setup only accepts an INI format? π₯
Right, the rc/run-con package supports application-named config files in JSON and INI format. It does not seem to be extensible to add other formats. This is unique to CLI(1).
The --config option supports JSON(C) and YAML using a shared function from markdownlint that is common to the library, CLI(1), CLI2, and the VS Code extension. It is extensible.
I'm not a fan of rc/run-con, but it wasn't my doing and it would be breaking to remove.
If you are happy with YAML, you could put (or symlink) a file called .markdownlint.yaml in the current directory when running the tool and it should be picked up automatically.
Ah, if it's able to pick up json, I'll try that! Just am not super excited about INI π
Thank you!!
It worked!! I cannot name it .json
though, I gotta keep the naming .markdownlintrc
strictly π but I'm glad we made it work!
I'll add some docs around this just so it doesn't catch anyone else :)