🌜
🌞
markdownlint-rule-helpers

markdownlint-rule-helpers

v0.17.1

A collection of markdownlint helper functions for custom rules

npm install markdownlint-rule-helpers

README

markdownlint-rule-helpers

A collection of markdownlint helper functions for custom rules

Overview

The Markdown linter markdownlint offers a variety of built-in validation rules and supports the creation of custom rules. The internal rules share various helper functions; this package exposes those for reuse by custom rules.

API

Undocumented - This package exports the internal functions as-is. The APIs were not originally meant to be public, are not officially supported, and may change from release to release. There are brief descriptive comments above each function, but no JSDoc annotations. That said, some of what's here will be useful to custom rule authors and may avoid duplicating code.

Example

const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");

module.exports = {
  "names": [ "every-n-lines" ],
  "description": "Rule that reports an error every N lines",
  "tags": [ "test" ],
  "function": (params, onError) => {
    const n = params.config.n || 2;
    forEachLine(getLineMetadata(params), (line, lineIndex) => {
      const lineNumber = lineIndex + 1;
      if ((lineNumber % n) === 0) {
        onError({
          "lineNumber": lineNumber,
          "detail": "Line number " + lineNumber
        });
      }
    });
  }
};

See also: markdownlint built-in rule implementations.

Tests

None - The entire body of code is tested to 100% coverage by the core markdownlint project, so there are no additional tests here.

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
3,332
Community Interest
3,127
Number of Forks
521

Maintenance

Commits
10/219/22040
Last Commit
Open Issues
73
Closed Issues
392
Open Pull Requests
1
Closed Pull Requests
41

Versions

Versions Released
10/219/2201
Latest Version Released
Jul 24, 2022
Current Tags
latest0.17.1

Dependencies

Dependencies (0)
Dev Dependencies (0)

Contributors

DavidAnson
DavidAnson
Commits: 663
nschonni
nschonni
Commits: 8
Yash-Singh1
Yash-Singh1
Commits: 3
ohtake
ohtake
Commits: 2
ciwchris
ciwchris
Commits: 2
jthomerson
jthomerson
Commits: 1
DuncanmaMSFT
DuncanmaMSFT
Commits: 1
mrmanc
mrmanc
Commits: 1
PeterRozum
PeterRozum
Commits: 1
jonlabelle
jonlabelle
Commits: 1
guillaumearm
guillaumearm
Commits: 1
travis-c-lagrone
travis-c-lagrone
Commits: 1
levacic
levacic
Commits: 1
kachkaev
kachkaev
Commits: 1
JensHeinrich
JensHeinrich
Commits: 1