plugins
plugins copied to clipboard
markdownlint config doesn't seem to be respected
Trunk doesn't seem to honor the markdownlint config changes I've made.
link to example of mapping.
I've tried a lot of variations but I can't get trunk to honor .markdownlint.yaml I run the markdownlint vscode plugin and it honors the file, but in repo when I tweak it seems to ignore the file.
For example changing indentation level to 12, it works with markdownlint tool itself, but then using trunk as my formatter it seems to go back to standard config and not honor it. I've tried both .markdownlint.yaml and .markdownlint.jsonc and neither seems to be picked up. I've also tried placing in root of repo and copying to .trunk/configs and no change in behavior.
Trunk config
version: '0.1'
cli:
version: 1.22.1
plugins:
sources:
- id: trunk
ref: v1.5.0
uri: https://github.com/trunk-io/plugins
lint:
enabled:
- [email protected]
.markdownlint.yaml
$schema: https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json
MD007:
indent: 12
start_indented: false
start_indent: 4
- [ ] one
- _In use by:_
- this
- [ ] more detail
- _the result_
- more
- foo
- [ ] one
- _In use by:_
- this
- [ ] more detail
- _the result_
- more
- foo
Hi! We discussed in Slack what was happening here. Duplicating here as well for visibility:
Markdownlint is being respected correctly, but prettier is taking precedence/ignoring that config. The main point here is that linters and formatters need to be configured to synergize. In the case of markdownlint, we provide a default config that turns off all formatting:
.markdownlint.yaml
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
If you want to opt out of this, you'll need to make sure prettier and markdownlint configs are in sync, or disable prettier for markdown files:
lint:
ignore:
- linters: [prettier]
paths: [**/*.md]
One other option is to add an additional command fix that applies [some] formatting fixes. I tested it out, and I think prettier provides a better experience here, so I won't be adding it for now:
lint:
definitions:
- name: markdownlint
commands:
- name: fix
output: rewrite
run: markdownlint ${target} --fix
success_codes: [0, 1]
batch: true
formatter: true
in_place: true
cache_results: true
where's the logic for what prettier covers. I've used markdownlint as the formatter for years and I thought it covered far more. Would like to examine. This lint with one tool + format with another can result in formatting "whiplash" so I want to examine what it does better.
Makes sense! We have a bit of recommendations about formatter/linter pairings here, but the actual source for these integrations is here:
- prettier files
- based on prettier's own file types
- markdownlint definition
- note that it is not a formatter and not a rewrite/in_place linter, as defined above
We generally recommend prettier as the default formatter for most file types because it covers so many and works generally OOTB, with lots of options for fine tuning individual styling. Let me know if there's anything else I can point you to