markdownlint-cli2
lets you customize its output by specifying one or more
output formatters in its configuration file. Output
formatters can be defined by scripts within a project or imported from a package
(keyword markdownlint-cli2-formatter
on npm).
Output formatters are called after linting is done and are passed arguments that
include the results, logging functions, and formatter parameters. They are
expected to return a Promise
that resolves when output formatting is complete
or void
if execution completes synchronously.
Output formatters export a function like:
module.exports = (options, params) => { ... }
Where options
is an object that looks like:
directory
:String
that identifies the base directory for relative paths (using POSIX syntax)results
:Array
ofmarkdownlint
LintError
objects, each with an addedString
propertyfileName
containing a relative pathlogMessage
:Function
that takes a singleString
argument and logs it to standard outputlogError
:Function
that takes a singleString
argument and logs it to standard error
And params
is an object containing formatter parameters from configuration.
For a .markdownlint-cli2.jsonc
like:
{
"outputFormatters": [
[ "markdownlint-cli2-formatter-json", { "name": "custom-name.json", "spaces": 1 } ]
]
}
params
would be:
{
"name": "custom-name.json",
"spaces": 1
}