Skip to content

markdownlint-climarkdownlint-cli2 #1934

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

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

parkerbxyz
Copy link
Contributor

@parkerbxyz parkerbxyz commented Oct 5, 2022

Proposed Changes

Replace markdownlint-cli with markdownlint-cli2.

Motivation: MegaLinter doesn't currently play nice with directory-specific markdownlint configuration files. Using markdownlint-cli2 in place of markdownlint-cli will fix this.

Advantages:

  • Speed (allegedly)
  • Configuration files can live anywhere and automatically apply to their part of the directory tree
    The markdownlint VS Code extension is powered by markdownlint-cli2, so everything should just work without special configuration when using the extension in conjunction with MegaLinter.
  • Fewer dependencies

Additional information: https://dlaa.me/blog/post/markdownlintcli2

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

@parkerbxyz parkerbxyz marked this pull request as ready for review October 22, 2022 00:31
@parkerbxyz parkerbxyz requested a review from nvuillam as a code owner October 22, 2022 00:31
@parkerbxyz
Copy link
Contributor Author

The only markdownlint test that I see failing is this one:

megalinter/tests/test_megalinter/linters/markdown_markdownlint_test.py::markdown_markdownlint_test::test_failure FAILED [ 46%]

I haven't been able to find any logs indicating why it's failing and I haven't figured out how to run the tests locally to debug further. Any help here would be greatly appreciated. 🙂

@nvuillam
Copy link
Member

Maybe you can start y what are the advatages og megalinter to use maskdownlint-cli2 instead of markdownlint ? :)

@parkerbxyz
Copy link
Contributor Author

Maybe you can start y what are the advatages og megalinter to use maskdownlint-cli2 instead of markdownlint ? :)

I'm not sure I understand the question... If you're asking what the advantages of markdownlint-cli2 are over the original markdownlint CLI, I addressed that in the PR description. Let me know if there's something I should elaborate on there or if you have any other questions. 🙂

@Kurt-von-Laven
Copy link
Collaborator

The only markdownlint test that I see failing is this one:

megalinter/tests/test_megalinter/linters/markdown_markdownlint_test.py::markdown_markdownlint_test::test_failure FAILED [ 46%]

I haven't been able to find any logs indicating why it's failing and I haven't figured out how to run the tests locally to debug further. Any help here would be greatly appreciated. 🙂

I think this is very valid feedback. I am inclined to give our CI pipeline some love if @nvuillam agrees. I am open to suggestions on where to begin. Otherwise, I will just try to keep the PRs small in order to solicit feedback.

@nvuillam
Copy link
Member

image

There are errors in bad testing files
They are not detected by markdownlint-cli2, that's why CI job fails

@parkerbxyz
Copy link
Contributor Author

It looks like the test is adding markdownlint-cli2 as an argument to the command, like so:

markdownlint-cli2 markdownlint-cli2 /tmp/lint/.automation/test/markdown/markdown_bad_1.md /tmp/lint/.automation/test/markdown/markdown_bad_2.md

This appears to be because of how the container works. More on that here. If we want to use the container, we'll need to use the --entrypoint flag to indicate which command to run without adding it twice.

I'm going to see if the build success without the container and go from there.

@nvuillam
Copy link
Member

nvuillam commented Oct 23, 2022

I think using npm package could be ok :) (all npm packages are joined in a single install command so it won't impact badly the build time)

@parkerbxyz
Copy link
Contributor Author

parkerbxyz commented Oct 24, 2022

megalinter/tests/test_megalinter/helpers/utilstest.py:604: in assert_file_has_been_updated
    test_self.assertTrue(updated, f"{file_name} has been updated")
E   AssertionError: False is not true : markdown_for_fixes_1.md has been updated

If I run the following command locally on this branch, 17 files, including markdown_for_fixes_1.md get updated/fixed:

npx mega-linter-runner --path .automation/test/sample_project_fixes/ --fix

Any ideas why it might behave differently in the test?

@parkerbxyz
Copy link
Contributor Author

Checks are passing. Ready for review!

@echoix
Copy link
Collaborator

echoix commented Mar 13, 2025

About the changes in the configuration schema. What happens to existing users, their config is no longer valid?

Since from what I know, the jsonschema store isn't versioned, how does existing releases play with that?

I'm asking questions, but maybe they don't need to be "solved" for the PR to go through. Only understand the implications

Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this pull request should stay open, please remove the O: stale 🤖 label or comment on the pull request.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Apr 13, 2025
@parkerbxyz
Copy link
Contributor Author

About the changes in the configuration schema. What happens to existing users, their config is no longer valid?

Since from what I know, the jsonschema store isn't versioned, how does existing releases play with that?

I'm asking questions, but maybe they don't need to be "solved" for the PR to go through. Only understand the implications

Great questions! I'm actually not sure. Perhaps this should be considered a breaking change with a note that configurations with MARKDOWN_MARKDOWNLINT_CLI should be changed to MARKDOWN_MARKDOWNLINT_CLI2? Alternatively, I could revert the changes to the schema, or maybe there's a way both options could be supported.

@echoix
Copy link
Collaborator

echoix commented Apr 14, 2025

Just like this, does markdownlint-cli2 support the same config and options that markdownlint-cli does? (In other words, if it were a mathematical set, the cli2 contains all of cli, plus cli2-specific elements). If so, we could just say that we substitute the binary that actually does the linting, but keep the variable names of ...-cli intact. It would be easier for the transition.

Does it make sense?

(Handling it like a major version change, that needs a new package name and install instructions)

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Apr 15, 2025
@parkerbxyz
Copy link
Contributor Author

From the markdownlint-cli2 README:

  • markdownlint-cli2 is configuration-based and prioritizes speed and simplicity.
  • markdownlint-cli2 supports all the features of markdownlint-cli (sometimes a little differently).

Compatibility

markdownlint-cli

  • The glob implementation and handling of pattern matching is slightly
    different.
  • Configuration files are supported in every directory (vs. only one at the
    root).
  • The INI config format, .markdownlintrc, and .markdownlintignore are not
    supported.

The --config, --fix, and --help parameters appear to be the same (though cli2 doesn't appear to support -c, -f, and -h). markdownlint-cli supports additional parameters.

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.

4 participants