[GH-ISSUE #441] How does this package relate to markdownlint-cli and markdonwlint-cli2? #367

Closed
opened 2026-03-03 01:26:16 +03:00 by kerem · 15 comments
Owner

Originally created by @pabrams on GitHub (Oct 7, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/441

I don't understand how these packages are inter-related. Which one should I use?

I tried installing markdownlint alongside markdownlint-cli2.

Ive tried both of the following commands, markdownlint -c .markdownlint-cli2.jsonc **/.md markdownlint-cli2 -c .markdownlint-cli2.jsonc **/.md`

with contents of .markdownlint-cli2.jsonc as follows:

 {
    // Disable some built-in rules
    "config": {
      "no-trailing-spaces": false,
      "no-multiple-blanks": false,
      "no-inline-html": false,
      "code_block_line_length": "120"
    },
  
    // Fix any fixable errors
    "fix": true,

    // Define glob expressions to use (only valid at root)
    "globs": [
      "!*bout.md"
    ],
  
    // Define glob expressions to ignore
    "ignores": [
      "node_modules"
    ],
  
    // // Disable inline config comments
    // "noInlineConfig": true,
  
    // Disable progress on stdout (only valid at root)
    "noProgress": true,
  
    // Use a specific formatter (only valid at root)
    "outputFormatters": [
      [ "markdownlint-cli2-formatter-default" ]
    ]
  }

But in both cases, the output states that the expected line length is 80, even though I configured it to 120.

Originally created by @pabrams on GitHub (Oct 7, 2021). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/441 I don't understand how these packages are inter-related. Which one should I use? I tried installing markdownlint alongside markdownlint-cli2. I`ve tried both of the following commands, `markdownlint -c .markdownlint-cli2.jsonc **/*.md` `markdownlint-cli2 -c .markdownlint-cli2.jsonc **/*.md` with contents of .markdownlint-cli2.jsonc as follows: ``` jsonc { // Disable some built-in rules "config": { "no-trailing-spaces": false, "no-multiple-blanks": false, "no-inline-html": false, "code_block_line_length": "120" }, // Fix any fixable errors "fix": true, // Define glob expressions to use (only valid at root) "globs": [ "!*bout.md" ], // Define glob expressions to ignore "ignores": [ "node_modules" ], // // Disable inline config comments // "noInlineConfig": true, // Disable progress on stdout (only valid at root) "noProgress": true, // Use a specific formatter (only valid at root) "outputFormatters": [ [ "markdownlint-cli2-formatter-default" ] ] } ``` But in both cases, the output states that the expected line length is 80, even though I configured it to 120.
kerem 2026-03-03 01:26:16 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Oct 7, 2021):

Those are two different implementations of a CLI for this library. I blogged about why I created CLI2 here:  https://dlaa.me/blog/post/markdownlintcli2

Only CLI2 supports the CLI2 configuration file format. The length you've tried to set is not being respected because that is a parameter and not a rule. Here are examples of setting it in context:  https://github.com/DavidAnson/markdownlint/search?q=code_block_line_length&type=

<!-- gh-comment-id:938173695 --> @DavidAnson commented on GitHub (Oct 7, 2021): Those are two different implementations of a CLI for this library. I blogged about why I created CLI2 here:  https://dlaa.me/blog/post/markdownlintcli2 Only CLI2 supports the CLI2 configuration file format. The length you've tried to set is not being respected because that is a parameter and not a rule. Here are examples of setting it in context:  https://github.com/DavidAnson/markdownlint/search?q=code_block_line_length&type=
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

I don't even get why the cli packages exist at all. markdownlint has its own command line interface, isn't that what this is?

PS C:> markdownlint
Usage: markdownlint [options] <files|directories|globs>

MarkdownLint Command Line Interface

Options:
-V, --version output the version number
-c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML)
-d, --dot include files/folders with a dot (for example
.github)
-f, --fix fix basic errors (does not work with STDIN)
-i, --ignore [file|directory|glob] file(s) to ignore/exclude (default: [])
-j, --json write issues in json format
-o, --output [outputFile] write issues to file (no console)
-p, --ignore-path [file] path to file with ignore pattern(s)
-r, --rules [file|directory|glob|package] custom rule files (default: [])
-s, --stdin read from STDIN (does not work with files)
-h, --help display help for command
PS C:>

<!-- gh-comment-id:938708813 --> @pabrams commented on GitHub (Oct 8, 2021): I don't even get why the cli packages exist at all. markdownlint has its own command line interface, isn't that what this is? PS C:\> markdownlint Usage: markdownlint [options] <files|directories|globs> MarkdownLint Command Line Interface Options: -V, --version output the version number -c, --config [configFile] configuration file (JSON, JSONC, JS, or YAML) -d, --dot include files/folders with a dot (for example `.github`) -f, --fix fix basic errors (does not work with STDIN) -i, --ignore [file|directory|glob] file(s) to ignore/exclude (default: []) -j, --json write issues in json format -o, --output [outputFile] write issues to file (no console) -p, --ignore-path [file] path to file with ignore pattern(s) -r, --rules [file|directory|glob|package] custom rule files (default: []) -s, --stdin read from STDIN (does not work with files) -h, --help display help for command PS C:\>
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

What other ways are there to interact with markdownlint, other than via the cli? Is there some gui I don't know about?

<!-- gh-comment-id:938710602 --> @pabrams commented on GitHub (Oct 8, 2021): What other ways are there to interact with markdownlint, other than via the cli? Is there some gui I don't know about?
Author
Owner

@DavidAnson commented on GitHub (Oct 8, 2021):

This library does not include a CLI. The output you show above is from the Ruby implementation of markdownlint (discussed in the Overview section of the README). There are various other ways to use this library, including plugins for various editors (like VS Code). A list of some of the most popular options can be found in the Related section of the README: https://github.com/DavidAnson/markdownlint#related

<!-- gh-comment-id:938748770 --> @DavidAnson commented on GitHub (Oct 8, 2021): This library does not include a CLI. The output you show above is from the Ruby implementation of markdownlint (discussed in the Overview section of the README). There are various other ways to use this library, including plugins for various editors (like VS Code). A list of some of the most popular options can be found in the Related section of the README: https://github.com/DavidAnson/markdownlint#related
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

Oh yeah, I keep ending up at that ruby implementation. Confusing.

<!-- gh-comment-id:938992489 --> @pabrams commented on GitHub (Oct 8, 2021): Oh yeah, I keep ending up at that ruby implementation. Confusing.
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

How did I even end up with that installed? I don't have gem, or rake, or anything like that. Did I get it via npm?

<!-- gh-comment-id:938998701 --> @pabrams commented on GitHub (Oct 8, 2021): How did I even end up with that installed? I don't have gem, or rake, or anything like that. Did I get it via npm?
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

It looks like the cli for the ruby version is mdl, not markdownlint... according to this

<!-- gh-comment-id:939002660 --> @pabrams commented on GitHub (Oct 8, 2021): It looks like the cli for the ruby version is `mdl`, not `markdownlint`... according to [this](https://github.com/markdownlint/markdownlint#usage)
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

I went back and looked at the "overview section of the README", but all that is said about the ruby version is that it inspired your stuff:

markdownlint is a static analysis tool for Node.js with a library of rules to enforce standards and consistency for Markdown files. It was inspired by - and heavily influenced by - Mark Harrison's markdownlint for Ruby. The initial rules, rule documentation, and test cases came directly from that project.

That doesn't help me understand what's going on, or how I ended up with it installed

I also reviewed the "ways of using markdownlint" in your "Related" section of the README:

Related
CLI
markdownlint-cli command-line interface for Node.js
markdownlint-cli2 command-line interface for Node.js
GitHub
GitHub Super-Linter Action
GitHub Actions problem matcher for markdownlint-cli
Editor
vscode-markdownlint extension for VS Code
Sublime Text markdownlint for Sublime Text
linter-node-markdownlint extension for Atom
coc-markdownlint extension for Vim/Neovim
Tooling
grunt-markdownlint for the Grunt task runner
Cake.Markdownlint addin for Cake build automation system
Ruby
markdownlint/mdl gem for Ruby

But I still don't understand how I ended up with 'markdownlint' cli... Did I set an alias and forget that I did that?

Anyway, I'll forget about that for a minute, because it seems like it shouldn't really matter - I have markdownlint-cli2, so I'll try to use it. I replace my config file with part of the contents of your example:

{
  "default": true,
  "MD013": {
    "code_block_line_length": 120
  },
  "MD046": false
}

and then:

markdownlint-cli2 **/*.md --config .markdownlint-cli2.jsonc

and here's part of my output:

script/README.md:28:81 MD013/line-length Line length [Expected: 80; Actual: 151]

How the heck do I get it to respect the line length I want?

<!-- gh-comment-id:939062039 --> @pabrams commented on GitHub (Oct 8, 2021): I went back and looked at the "overview section of the README", but all that is said about the ruby version is that it inspired your stuff: > markdownlint is a static analysis tool for Node.js with a library of rules to enforce standards and consistency for Markdown files. It was inspired by - and heavily influenced by - Mark Harrison's markdownlint for Ruby. The initial rules, rule documentation, and test cases came directly from that project. That doesn't help me understand what's going on, or how I ended up with it installed I also reviewed the "ways of using markdownlint" in your "Related" section of the README: > Related CLI markdownlint-cli command-line interface for Node.js markdownlint-cli2 command-line interface for Node.js GitHub GitHub Super-Linter Action GitHub Actions problem matcher for markdownlint-cli Editor vscode-markdownlint extension for VS Code Sublime Text markdownlint for Sublime Text linter-node-markdownlint extension for Atom coc-markdownlint extension for Vim/Neovim Tooling grunt-markdownlint for the Grunt task runner Cake.Markdownlint addin for Cake build automation system Ruby markdownlint/mdl gem for Ruby But I still don't understand how I ended up with 'markdownlint' cli... Did I set an alias and forget that I did that? Anyway, I'll forget about that for a minute, because it seems like it shouldn't really matter - I have markdownlint-cli2, so I'll try to use it. I replace my config file with part of the contents of your example: ``` .markdownlint-cli2.jsonc { "default": true, "MD013": { "code_block_line_length": 120 }, "MD046": false } ``` and then: `markdownlint-cli2 **/*.md --config .markdownlint-cli2.jsonc` and here's part of my output: > script/README.md:28:81 MD013/line-length Line length [Expected: 80; Actual: 151] How the heck do I get it to respect the line length I want?
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

So, I'll close this issue, since I don't really care about the ruby version of markdownlint, or how I got it. I opened a new issue just to figure out how to use makrdownlint-cli2. Oops, I think I opened it in this repo, but I guess it would be better in the cli2 repo.... so I'll go do that .

<!-- gh-comment-id:939066525 --> @pabrams commented on GitHub (Oct 8, 2021): So, I'll close this issue, since I don't really care about the ruby version of markdownlint, or how I got it. I opened a new issue just to figure out how to use makrdownlint-cli2. Oops, I think I opened it in this repo, but I guess it would be better in the cli2 repo.... so I'll go do that .
Author
Owner

@DavidAnson commented on GitHub (Oct 8, 2021):

You're mixing up the two CLI implementations. CLI2 does not take any "--" command line parameters other than the files to lint. If you just want to customize rule configuration, you can use JSON like you show in a file named .markdownlint.json in the root of your project and it will automatically be picked up and applied by CLI and CLI2.  If you want to use the richer configuration format supported by only CLI2, you can embed the JSON you have in a file named .markdownlint-cli2.jsonc in the root of your project and it will be picked up automatically. Here is an example of that file structure:  https://github.com/DavidAnson/markdownlint-cli2/blob/main/test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc

<!-- gh-comment-id:939067234 --> @DavidAnson commented on GitHub (Oct 8, 2021): You're mixing up the two CLI implementations. CLI2 does not take any "--" command line parameters other than the files to lint. If you just want to customize rule configuration, you can use JSON like you show in a file named `.markdownlint.json` in the root of your project and it will automatically be picked up and applied by CLI and CLI2.  If you want to use the richer configuration format supported by only CLI2, you can embed the JSON you have in a file named `.markdownlint-cli2.jsonc` in the root of your project and it will be picked up automatically. Here is an example of that file structure:  https://github.com/DavidAnson/markdownlint-cli2/blob/main/test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

Okay thanks for your attention, I'll go try that. I don't get how I ended up with the wrong instructions (I'm extremely confused, and thinking about trying to find some other markdown linter), but I'll try following the ones you give here.

<!-- gh-comment-id:939071576 --> @pabrams commented on GitHub (Oct 8, 2021): Okay thanks for your attention, I'll go try that. I don't get how I ended up with the wrong instructions (I'm extremely confused, and thinking about trying to find some other markdown linter), but I'll try following the ones you give here.
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

What are all these "OBJ" in your comments, anyway? Is there supposed to be something there? Here's what I see. Are you trying to show something different?

image

<!-- gh-comment-id:939072370 --> @pabrams commented on GitHub (Oct 8, 2021): What are all these "OBJ" in your comments, anyway? Is there supposed to be something there? Here's what I see. Are you trying to show something different? ![image](https://user-images.githubusercontent.com/1376688/136615859-f07e3a51-1754-4ee0-b187-e6f9f0f5272f.png)
Author
Owner

@DavidAnson commented on GitHub (Oct 8, 2021):

The OBJ characters get added by iOS dictation, sorry!

<!-- gh-comment-id:939076369 --> @DavidAnson commented on GitHub (Oct 8, 2021): The OBJ characters get added by iOS dictation, sorry!
Author
Owner

@pabrams commented on GitHub (Oct 8, 2021):

Okay, just making sure my corporate network wasn`t stripping out screenshots, or something....

<!-- gh-comment-id:939076584 --> @pabrams commented on GitHub (Oct 8, 2021): Okay, just making sure my corporate network wasn`t stripping out screenshots, or something....
Author
Owner

@pabrams commented on GitHub (Oct 12, 2021):

I finally managed to get it working. I guess my node was corrupted or something, because it only worked after I deleted node_modules and redid npm install. I also made sure to npm remove --global all of markdownlint, markdowlint-cli, and markdownlint-cli2.

In case anyone else is as obtuse as I am, here`s my minimum viable repro, which finally gave me the result I wanted.

.markdownlint-cli2.jsonc :

{
    "config": {
        "MD013": {
          "line_length": 120,
          "code_block_line_length": 120
        }
    }
}

The dependencies in my package.json:

  "devDependencies": {},
  "dependencies": {
    "markdownlint-cli2": "^0.3.2",
    "rimraf": "^3.0.2"
  }
}

test.md:

# test

XXXXXXXXXX/doc/test.md:25:81 MD013/line-length Line length [Expected: 80; Actual: 256]
XXXXXXXXXX/doc/test.md:29:81 MD013/line-length Line length [Expected: 80; Actual: 464]
XXXXXXXXXX/doc/test.md:31 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# 2. Performance Testing"]
XXXXXXXXXX/doc/test.md:35:81 MD013/line-length Line length [Expected: 80; Actual: 165]

command line:
npx markdownlint-cli2 test.md

output:

PS> npx markdownlint-cli2 test.md
npx: installed 36 in 6.188s
markdownlint-cli2 v0.3.2 (markdownlint v0.24.0)
Finding: test.md
Linting: 1 file(s)
Summary: 1 error(s)
test.md:5:121 MD013/line-length Line length [Expected: 120; Actual: 141]
PS>

<!-- gh-comment-id:941692974 --> @pabrams commented on GitHub (Oct 12, 2021): I finally managed to get it working. I guess my node was corrupted or something, because it only worked after I deleted node_modules and redid `npm install`. I also made sure to `npm remove --global` all of markdownlint, markdowlint-cli, and markdownlint-cli2. In case anyone else is as obtuse as I am, here`s my minimum viable repro, which finally gave me the result I wanted. .markdownlint-cli2.jsonc : ``` json { "config": { "MD013": { "line_length": 120, "code_block_line_length": 120 } } } ``` The dependencies in my package.json: ``` json "devDependencies": {}, "dependencies": { "markdownlint-cli2": "^0.3.2", "rimraf": "^3.0.2" } } ``` test.md: ``` markdown # test XXXXXXXXXX/doc/test.md:25:81 MD013/line-length Line length [Expected: 80; Actual: 256] XXXXXXXXXX/doc/test.md:29:81 MD013/line-length Line length [Expected: 80; Actual: 464] XXXXXXXXXX/doc/test.md:31 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# 2. Performance Testing"] XXXXXXXXXX/doc/test.md:35:81 MD013/line-length Line length [Expected: 80; Actual: 165] ``` command line: `npx markdownlint-cli2 test.md` output: > PS> npx markdownlint-cli2 test.md npx: installed 36 in 6.188s markdownlint-cli2 v0.3.2 (markdownlint v0.24.0) Finding: test.md Linting: 1 file(s) Summary: 1 error(s) test.md:5:121 MD013/line-length Line length [Expected: 120; Actual: 141] > PS>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#367
No description provided.