Socket
Socket
Sign inDemoInstall

unified-message-control

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unified-message-control

Enable, disable, and ignore messages from unified processors


Version published
Weekly downloads
190K
increased by9.74%
Maintainers
1
Weekly downloads
 
Created
Source

unified-message-control

Build Coverage Downloads Size Sponsors Backers Chat

Enable, disable, and ignore messages with unified.

Install

npm:

npm install unified-message-control

Use

Say we have the following file, example.md:

<!--foo ignore-->

## Heading

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var remark = require('remark')
var control = require('unified-message-control')
var mdastMarker = require('mdast-comment-marker')

remark()
  .use(warn)
  .use(control, {name: 'foo', marker: mdastMarker, test: 'html'})
  .process(vfile.readSync('example.md'), function (err, file) {
    console.error(report(err || file))
  })

function warn() {
  return function (tree, file) {
    file.message('Whoops!', tree.children[1], 'foo:thing')
  }
}

Now, running node example yields:

example.md: no issues found

API

unified.use(control, options)

Let comment markers control messages from certain sources.

Options
options.name

Name of markers that can control the message sources (string).

For example, {name: 'alpha'} controls alpha markers:

<!--alpha ignore-->
options.test

Test for possible markers (Function, string, Object, or Array.<Test>). See unist-util-is.

options.marker

Parse a possible marker to a comment marker object (Function). If the possible marker actually isn’t a marker, should return null.

options.known

List of allowed ruleIds (Array.<string>, optional). When given, a warning is shown when someone tries to control an unknown rule.

For example, {name: 'alpha', known: ['bravo']} results in a warning if charlie is configured:

<!--alpha ignore charlie-->
options.reset

Whether to treat all messages as turned off initially (boolean, default: false).

options.enable

List of ruleIds to initially turn on if reset: true (Array.<string>, optional). By default (reset: false), all rules are turned on.

options.disable

List of ruleIds to turn on if reset: false (Array.<string>, optional).

options.sources

Sources that can be controlled with name markers (string or Array.<string>, default: options.name)

Markers

disable

The disable keyword turns off all messages of the given rule identifiers. When without identifiers, all messages are turned off.

For example, to turn off certain messages:

<!--lint disable list-item-bullet-indent strong-marker-->

*   **foo**

A paragraph, and now another list.

  * __bar__
enable

The enable keyword turns on all messages of the given rule identifiers. When without identifiers, all messages are turned on.

For example, to enable certain messages:

<!--lint enable strong-marker-->

**foo** and __bar__.
ignore

The ignore keyword turns off all messages of the given ruleIds occurring in the following node. When without ruleIds, all messages are ignored.

After the end of the following node, messages are turned on again.

For example, to turn off certain messages for the next node:

<!--lint ignore list-item-bullet-indent strong-marker-->

*   **foo**
    * __bar__

Contribute

See contributing.md in unifiedjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 09 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc