Lint

Lint your document with custom rules.

Loading...

The Lint feature allows you to enforce custom rules and configurations on your documents.

Features

  • Customizable linting config, plugins and rules with a similar API to ESLint
  • Provides suggestions and fixes for each rule

Installation

npm install @udecode/plate-lint

Usage

import { resolveLintConfigs } from '@udecode/plate-lint/react';
import { emojiLintPlugin } from '@udecode/plate-lint/plugins';
 
const lintConfigs = resolveLintConfigs([
  emojiLintPlugin.configs.all,
  // ...otherConfigs
]);

Configuration

To configure the linting rules, you can use the resolveLintConfigs function to merge multiple configurations:

const configs = [
  emojiLintPlugin.configs.all,
  {
    languageOptions: {
      parserOptions: {
        minLength: 4,
      },
    },
    settings: {
      emojiMap: wordToEmojisMap,
      maxSuggestions: 5,
    },
  },
];

Plugins

EmojiLintPlugin

A plugin that provides linting rules for replacing text with emojis.

Options

Collapse all

    Map of words to their corresponding emoji suggestions.

    Maximum number of emoji suggestions to provide. Default: 8

API

resolveLintConfigs

Merges multiple lint configurations into a single set of resolved rules.

Parameters

Collapse all

    Array of lint configurations to merge.

Returns

Collapse all

    Object containing the resolved lint rules.