npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unified-message-control

v5.0.0

Published

Enable, disable, and ignore messages from unified processors

Downloads

933,661

Readme

unified-message-control

Build Coverage Downloads Size Sponsors Backers Chat

unified utility to enable, disable, and ignore messages.

Contents

What is this?

This is a lego block that is meant to be extended, such as is done by remark-message-control, so that lint messages can be controlled from content.

When should I use this?

You can use this if you’re building an ecosystem like remark for some different content type, and want to let authors control messages from that content.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install unified-message-control

In Deno with esm.sh:

import {messageControl} from 'https://esm.sh/unified-message-control@5'

In browsers with esm.sh:

<script type="module">
  import {messageControl} from 'https://esm.sh/unified-message-control@5?bundle'
</script>

Use

Say our document example.md contains:

<!--foo ignore-->

## Heading

…and our module example.js looks as follows:

import {commentMarker} from 'mdast-comment-marker'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import {read} from 'to-vfile'
import {unified} from 'unified'
import {messageControl} from 'unified-message-control'
import {reporter} from 'vfile-reporter'

const file = await read('example.md')

await unified()
  .use(remarkParse)
  .use(remarkStringify)
  .use(function () {
    return function (tree, file) {
      file.message('Whoops!', tree.children[1], 'foo:thing')
    }
  })
  .use(messageControl, {
    marker: commentMarker,
    name: 'foo',
    test: 'html'
  })
  .process(file)

console.error(reporter(file))

…now running node example.js yields:

example.md: no issues found

API

This package exports no identifiers. It exports the identifier messageControl.

messageControl(tree, options)

Let comment markers control messages.

Parameters
  • tree (Node) — tree
  • options (Options) — configuration (required)
Returns

Nothing (undefined).

Marker

Comment marker (TypeScript type).

Notes

The disable keyword turns off messages. For example:

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

*   **foo**

A paragraph, and now another list.

  * __bar__

The enable keyword turns on messages. For example:

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

**foo** and __bar__.

The ignore keyword turns off messages in the following node. After the end of the following node, messages are turned on again. For example:

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

*   **foo**
    * __bar__
Fields
  • name (string) — name of marker
  • attributes (string) — raw values (space-separated); the first should be enable, disable, or ignore, the rest are optional rule identifiers

MarkerParser

Parse a possible comment marker (TypeScript type).

Parameters
  • node (Node) — potential marker
Returns

Marker (Marker, optional).

Options

Configuration (TypeScript type).

Notes

The given name defines which comments work. Assuming there’s a marker configured that parses HTML comments such as <!--x y z--> to a mark with name: 'x', then giving name: 'x' will use comments such as:

<!--alpha ignore-->

When known is given, a warning is shown when unknown rules are controlled. For example, {name: 'alpha', known: ['bravo']} results in a warning (for charlie):

<!--alpha ignore charlie-->
Fields
  • enable (Array<string>, optional) — list of ruleIds to initially turn on; used if reset is true
  • disable (Array<string>, optional) — list of ruleIds to initially turn off; used if reset is not true
  • known (Array<string>, optional) — list of allowed ruleIds
  • file (VFile, required) — corresponding file
  • marker (MarkerParser, required) — parse nodes to Marker objects
  • name (string, required) — name of markers that can control the message sources
  • reset (boolean, default: false) — whether to treat all messages as turned off initially
  • source (Array<string> or string, default: options.name) — sources that can be controlled with markers
  • test (Test, optional) — test for possible markers

Types

This package is fully typed with TypeScript. It exports the additional types Marker, MarkerParser, and Options.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, unified-message-control@^5, compatible with Node.js 16.

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