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

markdownlint should look for .markdownlint.jsonc until found #241

Closed
whut opened this issue Nov 21, 2023 · 3 comments
Closed

markdownlint should look for .markdownlint.jsonc until found #241

whut opened this issue Nov 21, 2023 · 3 comments
Labels
question Further information is requested

Comments

@whut
Copy link

whut commented Nov 21, 2023

From what I understand currently markdownlint looks for .markdownlint.jsonc up until Visual Studio Code workspace folder or until current directory (if run via CLI). In my opinion it should not stop there, but instead look for the file in every parent directory, and stop on first found or when there is no more parent folder.

This is how in my opinion all linters/formatters work, e.g. ESLint, Prettier, EditorConfig. Some, like EditorConfig or .gitignore\.gitattributes read all the config files along the way and merge all settings , and some, like Prettier and ESLint just stop on first found (from what I understand ESLint originally used so called "cascaded" approach, but now they do not). IMO the latter is the right approach for markdownlint. Prettier implements it via lilconfig.

Here is an example where it is useful behaviour (and exactly the one where I would use it):

Assume a repository with multiple projects in subfolders, like:

\repo\
    project1\
        .gitignore
        .markdownlint.jsonc <-- I do not want to repeat that file in every project!
        ...
    project2\
        .gitignore
        .markdownlint.jsonc <-- I do not want to repeat that file in every project!
        ....
    .gitignore
    .prettierrc

I can put multiple config files in the repository root, so that all projects inherit them, e.g. I can just open vscode in the project1 folder, but still settings from repo will apply. This works e.g. for .gitignore (but here I want additional per-project .gitignore files) or .prettierrc (just single one in my case, but if I want to I could add .prettierrc in project folder and then explicitely import settings from parent). Sadly currently I have to copy .markdownlint.jsonc in every project folder, or otherwise the settings are not picked up!

@DavidAnson DavidAnson added the question Further information is requested label Nov 21, 2023
@DavidAnson DavidAnson transferred this issue from DavidAnson/markdownlint Nov 21, 2023
@DavidAnson
Copy link
Owner

(I transferred this issue from the markdownlint project because that library does not implement the behavior you describe.)

This is a duplicate of #53. You can read about why I have not implemented this behavior and follow the link to ESLint documentation for all the complexity/uncertainty this behavior causes for them.

I think that what you want to do is already supported by the --config parameter which can be used to point to your non-project shared options file.

@whut
Copy link
Author

whut commented Dec 22, 2023

Thanks for moving it to proper place and the reply and not closing it on-the-spot:)

I believe that originally ESLint used so called "cascaded" approach, in which settings from all parent folder are merged in. In the current approach, they just search for the first config, up to the root folder, which is exactly what I propose for markdownlint.

@DavidAnson
Copy link
Owner

My reply above is similarly relevant for both approaches you describe. If you are using a single configuration file, the "config" parameter is even easier to use. I will close this issue now as a confirmed duplicate.

@DavidAnson DavidAnson closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants