or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-remark-lint

remark plugin to lint Markdown code style

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/remark-lint@10.0.x

To install, run

npx @tessl/cli install tessl/npm-remark-lint@10.0.0

index.mddocs/

remark-lint

remark-lint is a remark plugin that adds support for configuration comments to control remark lint rule messages. It serves as the foundational plugin that enables ignoring lint warnings through HTML comments and provides the core infrastructure for the entire remark-lint ecosystem.

Package Information

  • Package Name: remark-lint
  • Package Type: npm
  • Language: JavaScript (ESM)
  • Installation: npm install remark-lint

Core Imports

import remarkLint from 'remark-lint';

For Deno:

import remarkLint from 'https://esm.sh/remark-lint@10';

For browsers:

<script type="module">
  import remarkLint from 'https://esm.sh/remark-lint@10?bundle';
</script>

Basic Usage

import remarkLint from 'remark-lint';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import {read} from 'to-vfile';
import {unified} from 'unified';
import {reporter} from 'vfile-reporter';

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

await unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkStringify)
  .process(file);

console.error(reporter(file));

Architecture

remark-lint follows the unified plugin architecture:

  • Plugin Function: Main export that integrates with unified processors
  • Message Control: Uses remark-message-control to handle configuration comments
  • Lint Infrastructure: Provides the foundation for all remark-lint rules to operate consistently
  • Configuration Comments: Enables HTML-style comments to control lint behavior on a per-document basis

Capabilities

Configuration Comment Support

The core capability that enables authors to ignore or control lint messages using HTML comments embedded in markdown documents.

/**
 * Add support for configuration comments to control remark lint rule messages.
 * This is the main and only export of the remark-lint package.
 * 
 * When used as a unified plugin, this function registers a transformer that enables
 * configuration comments like <!--lint ignore--> in markdown documents.
 * The function calls this.use() internally to register the message control transformer.
 * 
 * @this {Processor} - Unified processor instance (plugin is bound to this context)
 * @returns {undefined} - No explicit return value (modifies processor via this.use())
 */
export default function remarkLint(): undefined;

Configuration Comment Syntax:

<!-- Ignore all lint rules for the next content -->
<!--lint ignore-->

<!-- Disable specific rule -->
<!--lint disable rule-name-->

<!-- Enable specific rule -->
<!--lint enable rule-name-->

<!-- Disable multiple rules -->
<!--lint disable rule-name-1 rule-name-2-->

Usage with Lint Rules:

import {unified} from 'unified';
import remarkParse from 'remark-parse';
import remarkLint from 'remark-lint';
import remarkLintFinalNewline from 'remark-lint-final-newline';
import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation';

const processor = unified()
  .use(remarkParse)
  .use(remarkLint)  // Must be included for comment support
  .use(remarkLintFinalNewline)
  .use(remarkLintNoHeadingPunctuation);

const file = await processor.process(markdownContent);

Integration Patterns:

// Can be used before lint rules
const processor1 = unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintFinalNewline);

// Can be used after lint rules  
const processor2 = unified()
  .use(remarkParse)
  .use(remarkLintFinalNewline)
  .use(remarkLint);

// Both patterns provide identical functionality

Rule Configuration:

// Rules can be configured with severity levels
unified()
  .use(remarkParse)
  .use(remarkLint)
  .use(remarkLintFinalNewline, [2])  // Error level (fatal)
  .use(remarkLintNoHeadingPunctuation, true)  // Warning level
  .use(remarkLintNoUndefinedReferences, false);  // Disabled

Types

/**
 * Internal helper function that configures remark-message-control.
 * This function is not directly exported but is used internally by remarkLint.
 * It calls remarkMessageControl with the appropriate configuration for lint messages.
 * 
 * @returns {Function} Transform function from remark-message-control configured for lint
 */
function lintMessageControl(): Function;

Error Handling

remark-lint integrates with the vfile message system to provide consistent error reporting:

  • Message Structure: All lint messages include line/column positions, rule IDs, and source attribution
  • Severity Levels: Support for warning (1) and error (2) severity levels
  • Rule Attribution: Messages include ruleId and source fields for identification
  • URL References: Messages can include URLs to rule documentation

Example Error Output:

virtual.md:3:1-3:24: Unexpected character `.` at end of heading, remove it
  3:1-3:24  warning  no-heading-punctuation  remark-lint

Compatibility

  • Node.js: 16+ (ESM only)
  • Unified: Compatible with unified 11.0.0+
  • remark: Works with all remark parsers and compilers
  • Ecosystem: Foundation for 80+ specialized lint rule packages

Dependencies

  • @types/mdast: ^4.0.0 - TypeScript definitions for mdast syntax tree
  • remark-message-control: ^8.0.0 - Core message control functionality
  • unified: ^11.0.0 - Plugin architecture foundation