You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The markdownlint pre-commit hook defers to a repo-local config when the
target repo has one (#116), which is right. But the global config carries "MD060": false and the repo-local branch inherits nothing, so a repo whose
config predates MD060 gets the rule at its default. MD060 wants aligned or
compact table pipes; terraform-docs emits |------|---------|. The two
disagree, and the hook blocks every commit touching a generated README.
Hit this on beacon-biosignals/infra, committing an unrelated Terraform
change that happened to include a docs edit. That repo has 93 READMEs
generated by terraform-docs, and MD060 fails on all of them. Beacon's CI
doesn't run markdownlint at all, so this is purely the local hook.
Reproduction
mkdir md-repro &&cd md-repro
printf'%s\n''<!-- BEGIN_TF_DOCS -->''## Providers''' \
'| Name | Version |''|------|---------|''| aws | n/a |' \
'<!-- END_TF_DOCS -->'> README.md
printf'%s\n''{ "MD013": false }'> .markdownlint.json
# repo-local branch: MD060 fires
markdownlint --fix README.md
# global branch: clean, because the global config disables MD060
markdownlint --fix --config ~/.config/markdownlint-cli/.markdownlint.json README.md
The same file passes under one branch and fails under the other. markdownlint
v0.49.1.
Note MD060 reports but does not auto-fix this case, so the hook fails without
rewriting. On infra's real config it did rewrite tables elsewhere in the
file (that config sets MD013.tables: false, which changes what other rules
touch), producing | ------ | --------- |. That form is worse than the
failure: terraform-docs reverts it on the next terraform-docs run, so it is
permanent churn against a generated file.
The comment above it (lines 113-118) explains the intent: defer to a repo's own
conventions rather than forcing the personal global config. That intent is
correct. The gap is that "defer to the repo" silently means "and also apply
every rule the repo's config never heard of," including rules added to
markdownlint after that config was written.
Why it's worth fixing
Same shape as #290: a global hook default fighting a repo's actual convention,
with an escape hatch nobody knows to reach for until they've lost time to it.
The repo that suffers is not mine. Fixing it the obvious way means committing
a change to Beacon's shared .markdownlint.yaml to accommodate my local
tooling, which a reviewer would rightly question on an unrelated PR.
It scales with the rule set. Every new rule markdownlint ships lands
enabled-by-default in every repo-local branch. MD060 is new in the v0.4x
line; the next one will do this again somewhere else.
Generated files are the common case. terraform-docs, swagger-markdown, and
similar tools emit tables in whatever style they emit, and no amount of
local reformatting survives regeneration.
Options
Layer the global config under the repo's. Pass both, global first, so
repo settings win but global opinions about rules the repo never mentions
still apply. markdownlint-cli2 supports config extension; markdownlint-cli
may need the merge done in the hook.
Disable MD060 globally in the hook regardless of branch, since
generated tables are common and the rule is cosmetic.
Skip files containing generator sentinels such as BEGIN_TF_DOCS, @generated, or DO NOT EDIT. Correct in principle, and the sentinel list
never stops growing.
Preference is 1. It preserves the #116 intent exactly (the repo still wins on
anything it has an opinion about) while stopping a new upstream rule from
becoming a per-repo emergency. 2 is the one-line version if 1 is more
machinery than it is worth.
Summary
The
markdownlintpre-commit hook defers to a repo-local config when thetarget repo has one (#116), which is right. But the global config carries
"MD060": falseand the repo-local branch inherits nothing, so a repo whoseconfig predates MD060 gets the rule at its default. MD060 wants aligned or
compact table pipes; terraform-docs emits
|------|---------|. The twodisagree, and the hook blocks every commit touching a generated README.
Hit this on
beacon-biosignals/infra, committing an unrelated Terraformchange that happened to include a docs edit. That repo has 93 READMEs
generated by terraform-docs, and MD060 fails on all of them. Beacon's CI
doesn't run markdownlint at all, so this is purely the local hook.
Reproduction
The same file passes under one branch and fails under the other. markdownlint
v0.49.1.
Note MD060 reports but does not auto-fix this case, so the hook fails without
rewriting. On
infra's real config it did rewrite tables elsewhere in thefile (that config sets
MD013.tables: false, which changes what other rulestouch), producing
| ------ | --------- |. That form is worse than thefailure: terraform-docs reverts it on the next
terraform-docsrun, so it ispermanent churn against a generated file.
Where
pre-commit/config.yaml:121-136The comment above it (lines 113-118) explains the intent: defer to a repo's own
conventions rather than forcing the personal global config. That intent is
correct. The gap is that "defer to the repo" silently means "and also apply
every rule the repo's config never heard of," including rules added to
markdownlint after that config was written.
Why it's worth fixing
Same shape as #290: a global hook default fighting a repo's actual convention,
with an escape hatch nobody knows to reach for until they've lost time to it.
Three things make it worse than #290:
a change to Beacon's shared
.markdownlint.yamlto accommodate my localtooling, which a reviewer would rightly question on an unrelated PR.
enabled-by-default in every repo-local branch. MD060 is new in the v0.4x
line; the next one will do this again somewhere else.
swagger-markdown, andsimilar tools emit tables in whatever style they emit, and no amount of
local reformatting survives regeneration.
Options
repo settings win but global opinions about rules the repo never mentions
still apply. markdownlint-cli2 supports config extension; markdownlint-cli
may need the merge done in the hook.
generated tables are common and the rule is cosmetic.
BEGIN_TF_DOCS,@generated, orDO NOT EDIT. Correct in principle, and the sentinel listnever stops growing.
Preference is 1. It preserves the #116 intent exactly (the repo still wins on
anything it has an opinion about) while stopping a new upstream rule from
becoming a per-repo emergency. 2 is the one-line version if 1 is more
machinery than it is worth.
Happy to send a PR for whichever you prefer.