markdownlint-rule-trace-template-headers

2.0.3 • Public • Published

markdownlint-rule-trace-template-headers

A custom markdownlint rule that provides the functionality to check the headers of a Markdown file based on the headers of a template file, verifying the match and order of the headers.

This package is compatible with markdownlint-cli2 and not markdownlint-cli.

Usage

CLI

  1. Install dependencies.

    npm install -D markdownlint-cli2 @lainNao/markdownlint-trace-template-headers
  2. Create config file.

    touch .markdownlint-cli2.jsonc
  3. Edit .markdownlint-cli2.jsonc .

    • if markdownlint-rule-trace-template-headers is v2 or higher
    {
      "customRules": [
        "markdownlint-rule-trace-template-headers"
      ],
      "config": {
        "markdownlint-rule-trace-template-headers": {
          "settings": [
            {
              "templateFile": "YOUR_TEMPLATE_FILE.md", // template headers file
              "includedFiles": ["*.md"], // files to lint
              "excludedFiles": [] // files to exclude
            },
            ...
          ]
        }
      }
    }
    • if markdownlint-rule-trace-template-headers is v1 or lower
    {
      "customRules": [
        "markdownlint-rule-trace-template-headers"
      ],
      "config": {
        "markdownlint-rule-trace-template-headers": {
          "templateFile": "YOUR_TEMPLATE_FILE.md", // template headers file
          "includedFiles": ["*.md"], // files to lint
          "excludedFiles": [] // files to exclude
        }
      }
    }
  4. Run lint.

    npx markdownlint-cli2 SOME_MARKDOWN_FILE.md

VSCode

  1. Install markdownlint in your VSCode extensions marketplace.
  2. Create and edit .markdownlint-cli2.jsonc like above.
  3. Verify the lint rule works works in Editor.

Other

To disable the rule, edit .markdownlint-cli2.jsonc .

{
  "customRules": [
    "markdownlint-rule-trace-template-headers"
  ],
  "config": {
    "markdownlint-rule-trace-template-headers": false    // change this value to falsy
  }
}

TODO

  • Improve CI/CD. Add auto tests and auto versioning, updating changelog, release scripts.
  • Create CONTRIBUTION.md
  • Config to select error/warn

Readme

Keywords

Package Sidebar

Install

npm i markdownlint-rule-trace-template-headers

Weekly Downloads

6

Version

2.0.3

License

MIT

Unpacked Size

16.7 kB

Total Files

16

Last publish

Collaborators

  • lainnao