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

Support configuration file in parent directory of CWD #53

Closed
zhimsel opened this issue Jun 27, 2022 · 3 comments
Closed

Support configuration file in parent directory of CWD #53

zhimsel opened this issue Jun 27, 2022 · 3 comments
Labels
question Further information is requested

Comments

@zhimsel
Copy link

zhimsel commented Jun 27, 2022

I understand this tool supports merging/overriding a hierarchy of configuration files in parent directories of the target file to lint. However, it does not appear to consider configuration files in anything above the current working directory.

Consider this directory structure:

.
├── .markdownlint.yaml
└── foo
    ├── .markdownlint.yaml
    └── bar
        └── baz.md

If I run markdownlint-cli2 from the root of this directory tree, then both .markdownlint.yaml and foo/.markdownlint.yaml will be used to lint foo/bar/baz.md.

However, if I change my directory to foo, then run it again, only foo/.markdownlint.yaml is used. If I then change to foo/bar, then neither will be used.

This is counterintuitive considering the behavior of nested/parent configs below the current directory. One would expect that relationship to work the other way, too.

@DavidAnson
Copy link
Owner

Scanning is rooted from the current directory when the tool is run. The behavior you describe is therefore expected. The alternative is to scan every parent directory all the way up to the root of the file system which would be a performance hit and feels to me like a security/expectation violation. That said, I am aware some other tools do so.

@DavidAnson DavidAnson added the question Further information is requested label Jun 27, 2022
@DavidAnson
Copy link
Owner

Note all the time and energy ESLint spends describing this behavior and all the implications/unexpected side effects: https://eslint.org/docs/latest/user-guide/configuring/configuration-files#cascading-and-hierarchy

@zhimsel
Copy link
Author

zhimsel commented Jun 28, 2022

Understood, thanks. I wasn't sure if this was a bug or intended behavior. I can see merits for both approaches, and I wouldn't suggest changing the approach used here.

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