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 config doesn't seem to be respected #788

Open
sheldonhull opened this issue May 23, 2024 · 3 comments
Open

markdownlint config doesn't seem to be respected #788

sheldonhull opened this issue May 23, 2024 · 3 comments

Comments

@sheldonhull
Copy link
Contributor

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.

image

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
@TylerJang27
Copy link
Collaborator

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

@sheldonhull
Copy link
Contributor Author

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.

@TylerJang27
Copy link
Collaborator

Makes sense! We have a bit of recommendations about formatter/linter pairings here, but the actual source for these integrations is here:

  • prettier files
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants