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

unified-lint-rule

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unified-lint-rule

unified plugin to make it a bit easier to create linting rules

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
198K
decreased by-12.18%
Maintainers
3
Weekly downloads
 
Created

What is unified-lint-rule?

The `unified-lint-rule` package is a utility for creating linting rules for unified processors. Unified is a project that provides a suite of tools for processing content, such as Markdown and HTML, in a structured way. The `unified-lint-rule` package allows developers to define custom linting rules that can be used to enforce coding standards, catch errors, and ensure consistency in content processing.

What are unified-lint-rule's main functionalities?

Creating a Custom Lint Rule

This feature allows you to create a custom linting rule. In this example, the rule checks for the presence of the word 'foo' in text nodes and reports a message if it is found.

const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');

const noFoo = rule('example/no-foo', (tree, file) => {
  visit(tree, 'text', (node) => {
    if (node.value.includes('foo')) {
      file.message('Do not use the word "foo"', node);
    }
  });
});

module.exports = noFoo;

Integrating with Unified Processor

This feature demonstrates how to integrate a custom linting rule with a unified processor. The example shows how to use the `unified`, `remark-parse`, and `remark-lint` packages along with the custom `noFoo` rule to process a Markdown string and report any linting messages.

const unified = require('unified');
const markdown = require('remark-parse');
const lint = require('remark-lint');
const noFoo = require('./path-to-no-foo-rule');

unified()
  .use(markdown)
  .use(lint)
  .use(noFoo)
  .process('This is a foo test', (err, file) => {
    if (err) throw err;
    console.error(report(file));
  });

Other packages similar to unified-lint-rule

Keywords

FAQs

Package last updated on 09 Apr 2024

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