Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Latest commit

 

History

History
72 lines (60 loc) · 1.64 KB

api.md

File metadata and controls

72 lines (60 loc) · 1.64 KB

API

Usage

Dependencies:

var remark = require('remark');
var lint = require('remark-lint');
var processor = remark().use(lint);

Example document.

var doc = '* Hello\n' +
    '\n' +
    '-   World\n';

Process.

processor.process(doc, function (err, file, res) {
    var messages = file.messages;
    /**
     * Yields:
     * [
     *   {
     *     "name": "1:3-1:8",
     *     "file": "",
     *     "reason": "Incorrect list-item content indent: add 2 spaces",
     *     "line": 1,
     *     "column": 3,
     *     "fatal": false,
     *     "ruleId": "list-item-indent"
     *   },
     *   {
     *     "name": "3:1-3:10",
     *     "file": "",
     *     "reason": "Invalid ordered list item marker: should be `*`",
     *     "line": 3,
     *     "column": 1,
     *     "fatal": false,
     *     "ruleId": "unordered-list-marker-style"
     *   }
     * ]
     */
});

remark.use(lint, options)

Adds warnings for style violations to a given virtual file using remark’s warning API.

When processing a file, these warnings are available at file.messages, and look as follows:

{
  "fatal": false,
  "reason": "Marker style should be `*`",
  "file": "~/example.md",
  "line": 3,
  "column": 1,
  "ruleId": "unordered-list-marker-style"
}

See VFileMessage for more information.