Skip to content

fix(config): resolve markdownlint-cli2 configs like markdownlint-cli2 - #942

Closed
rcdailey wants to merge 1 commit into
rvben:mainfrom
rcdailey:fix/markdownlint-cli2-nested-merge
Closed

rcdailey wants to merge 1 commit into
rvben:mainfrom
rcdailey:fix/markdownlint-cli2-nested-merge

Conversation

@rcdailey

Copy link
Copy Markdown
Contributor

Description

Fixes #941.

rumdl reads .markdownlint-cli2.* and .markdownlint.* files on behalf of markdownlint-cli2, so I think it should resolve them the same way markdownlint-cli2 does. Two things differed:

  1. A nested .markdownlint-cli2.* file replaced the config from parent directories, so rules it didn't mention fell back to rumdl's defaults.
  2. A .markdownlint-cli2.* file took precedence over a .markdownlint.* file in the same directory. markdownlint-cli2 does the opposite (config: markdownlintConfig || markdownlintOptions?.config in lintFiles).

I based the resolution on markdownlint-cli2's source (createDirInfos, mergeOptions, lintFiles) and checked each case against markdownlint-cli2 v0.23.3:

  • Nested .markdownlint-cli2.* configs merge over their parents. Like mergeOptions, a rule key in a nearer file replaces the inherited entry as a whole (no deep merge of rule options).
  • A .markdownlint.* file is used as-is. It beats a .markdownlint-cli2.* config in the same directory, and a nested directory inherits it while no .markdownlint-cli2.* file in between sets config.
  • Inheritance stops at the directory rumdl runs from, since markdownlint-cli2 stops at its working directory. For the LSP that's the document's workspace root.
  • Explicit --config files stay standalone. The public SourcedConfig::load_discovered keeps its signature and behavior; the LSP uses a new crate-private load_discovered_within that takes the workspace root.

MARKDOWNLINT_CONFIG_FILES now lists .markdownlint.* before .markdownlint-cli2.* (and .jsonc before .json, matching markdownlint-cli2's order).

Known limitations:

  • Inherited values are attributed to the nearest file in provenance output (e.g. rumdl config), although every file in the chain is listed in loaded_files.
  • For a file outside the working directory, markdownlint-cli2 injects the working directory's config as a parent. rumdl doesn't inherit anything in that case.

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update

Testing

  • Tests added/updated
  • All tests passing (make test-dev)
  • Manual testing performed

make test-dev has 14 failures locally, and the same tests fail on main for me: the code block tool tests need gofmt, prettier, ruff, and similar tools I don't have installed, and a_filtered_file_under_a_vendor_directory_still_counts fails too.

Checklist

  • Code follows project style (make fmt && make lint)
  • Conventional commit messages used (they generate the changelog)
  • Documentation updated (if needed)

Clippy passes. lint-actions couldn't run locally because shellcheck isn't installed.

A nested .markdownlint-cli2.* file replaced the config from parent
directories, so rules it did not mention fell back to rumdl defaults. A
.markdownlint-cli2.* file also took precedence over a .markdownlint.*
file in the same directory. markdownlint-cli2 does neither, and rumdl
should give a config file the meaning its owning tool gives it.

The resolution follows markdownlint-cli2's source (createDirInfos and
lintFiles), not only observed output. The inheritance walk ends at the
directory rumdl runs from (the LSP workspace root), because
markdownlint-cli2 stops at its working directory.

- Nested .markdownlint-cli2.* configs merge over their parents, a nearer
  rule entry replacing the inherited one as a whole
- .markdownlint.* files win over a .markdownlint-cli2.* config in the
  same directory, and are inherited while no cli2 file in between sets
  config
- Explicit --config files and the public load_discovered stay standalone

Fixes rvben#941
@rvben

rvben commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Thanks for the configuration-inheritance fix. Your original commit has been incorporated with authorship preserved. Follow-up fixes cover CLI2 ignore behavior across CLI, stdin, and LSP, plus the MD060 alias from #944. The combined changes passed independent reviews and regression checks. Closing this PR as incorporated.

@rvben rvben closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested .markdownlint-cli2.yaml replaces parent config instead of merging with it

2 participants