Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unified-message-control

Package Overview
Dependencies
Maintainers
2
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

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
198K
increased by21%
Maintainers
2
Weekly downloads
 
Created
Source

unified-message-control Build Status Coverage Status Chat

Enable, disable, and ignore messages with unified.

Installation

npm:

npm install unified-message-control

Usage

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 a certain sources.

Options
options.name

string — Name of markers that can control the message sources.

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

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

function — function that returns a comment marker object for a matched comment, and null for a non-matched comment.

options.test

(Function, string, Object, or Array.<Test>) — When string, works like passing function (node) {return node.type === test}. When array, checks any one of the subtests pass. When object, checks that all keys in test are in node, and that they have (strictly) equal values

options.known

Array.<string>, optional — List of allowed ruleIds. 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

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

options.enable

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

options.disable

Array.<string>, optional — List of disallowed ruleIds used when reset: false to initially turn off.

options.sources

string or Array.<string>, optional — One or more sources which markers by the specified name can control. Defaults to options.name.

Markers

disable

The disable marker 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 marker 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 marker turns off all messages of the given rule identifiers occurring in the following node. When without identifiers, all messages are turned off.

After the end of the following node, messages are allowed 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 unified/unified for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 05 May 2018

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