CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-remark-preset-lint-recommended

A remark preset to configure remark-lint with rules that prevent mistakes or stuff that fails across vendors.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

remark-preset-lint-recommended

remark-preset-lint-recommended is a unified (remark) preset that configures remark-lint with a curated collection of rules designed to prevent mistakes and ensure consistent markdown rendering across different vendors. It provides a standardized approach to markdown linting with rules for Unix compatibility, consistent formatting, and common mistake prevention.

Package Information

  • Package Name: remark-preset-lint-recommended
  • Package Type: npm
  • Language: JavaScript (ES Module)
  • Installation: npm install remark-preset-lint-recommended

Alternative Installation Methods

Deno:

import remarkPresetLintRecommended from 'https://esm.sh/remark-preset-lint-recommended@6';

Browser:

<script type="module">
  import remarkPresetLintRecommended from 'https://esm.sh/remark-preset-lint-recommended@6?bundle';
</script>

Core Imports

ES Module:

import remarkPresetLintRecommended from 'remark-preset-lint-recommended';

CommonJS:

const remarkPresetLintRecommended = require('remark-preset-lint-recommended');

Basic Usage

import {read} from 'to-vfile'
import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'

main()

async function main() {
  const file = await remark()
    .use(remarkPresetLintRecommended)
    .process(await read('example.md'))

  console.error(reporter(file))
}

CLI usage:

remark --use remark-preset-lint-recommended example.md

Package.json configuration:

{
  "remarkConfig": {
    "plugins": [
      "remark-preset-lint-recommended"
    ]
  }
}

Capabilities

Preset Configuration

The main export is a unified preset that provides a comprehensive linting configuration.

const remarkPresetLintRecommended: Preset;

The preset contains a curated collection of 15 remark-lint rules organized into three categories:

Unix Compatibility:

  • remark-lint-final-newline - Ensures files end with a newline

Consistent Rendering:

  • remark-lint-list-item-bullet-indent - Ensures consistent list item bullet indentation
  • remark-lint-list-item-indent - Enforces tab-size indentation for list items
  • remark-lint-no-blockquote-without-marker - Requires blockquote markers
  • remark-lint-no-literal-urls - Prevents literal URLs
  • remark-lint-ordered-list-marker-style - Uses '.' style for ordered lists

Mistake Prevention:

  • remark-lint-hard-break-spaces - Manages hard break spaces
  • remark-lint-no-duplicate-definitions - Prevents duplicate definitions
  • remark-lint-no-heading-content-indent - Prevents heading content indentation
  • remark-lint-no-inline-padding - Prevents inline padding
  • remark-lint-no-shortcut-reference-image - Prevents shortcut reference images
  • remark-lint-no-shortcut-reference-link - Prevents shortcut reference links
  • remark-lint-no-undefined-references - Prevents undefined references
  • remark-lint-no-unused-definitions - Prevents unused definitions

Preset Interface

The preset follows the unified Preset interface:

interface Preset {
  plugins?: PluggableList;
  settings?: Record<string, unknown>;
}

type PluggableList = Array<Pluggable>;

type Pluggable = Plugin | PluginTuple | Preset;

Rule Configuration

Two rules are configured with specific settings:

// List item indentation uses tab-size
[remarkLintListItemIndent, 'tab-size']

// Ordered list markers use period style
[remarkLintOrderedListMarkerStyle, '.']

All other rules use their default configurations.

Types

The preset is compatible with the unified ecosystem types:

// From unified
interface Preset {
  plugins?: PluggableList;
  settings?: Record<string, unknown>;
}

type PluggableList = Array<Pluggable>;

type Pluggable = Plugin | PluginTuple | Preset;

type Plugin = (this: Processor, ...args: any[]) => Transformer | void;

type PluginTuple = [Plugin, ...any[]];

interface Transformer {
  (tree: Node, file: VFile): Promise<Node | null | undefined> | Node | null | undefined;
}

// From @types/mdast
type Node = import('@types/mdast').Node;

// From vfile
interface VFile {
  readonly path?: string;
  readonly basename?: string;
  readonly stem?: string;
  readonly extname?: string;
  readonly dirname?: string;
  readonly history: string[];
  readonly messages: VFileMessage[];
  data: {[key: string]: unknown};
  value: string | Uint8Array;
}

Usage Patterns

Basic Integration

import remarkPresetLintRecommended from 'remark-preset-lint-recommended';
import {unified} from 'unified';
import remarkParse from 'remark-parse';

const processor = unified()
  .use(remarkParse)
  .use(remarkPresetLintRecommended);

With Additional Configuration

import remarkPresetLintRecommended from 'remark-preset-lint-recommended';
import {unified} from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';

const processor = unified()
  .use(remarkParse)
  .use(remarkPresetLintRecommended)
  .use(remarkStringify, {
    bullet: '*',
    emphasis: '*',
    fences: true
  });

Reconfiguring Rules

Rules can be reconfigured after applying the preset:

import remarkPresetLintRecommended from 'remark-preset-lint-recommended';
import remarkLintOrderedListMarkerStyle from 'remark-lint-ordered-list-marker-style';
import {unified} from 'unified';

const processor = unified()
  .use(remarkPresetLintRecommended)
  // Override the ordered list marker style
  .use(remarkLintOrderedListMarkerStyle, ')');

Compatibility

  • Node.js: 12.20+, 14.14+, 16.0+
  • Environment: ES Module only
  • unified: ^10.0.0
  • remark-lint: ^9.0.0

docs

index.md

tile.json