remark-lint-table-pipe-alignment

raw JSON →
4.1.1 verified Fri May 01 auth: no javascript

A remark-lint rule that warns when GFM table cell dividers (pipes) are not aligned consistently. Current stable version is 4.1.1. This package is part of the remark-lint monorepo, which releases updates across all packages simultaneously. It enforces table formatting consistency, complementing other remark-lint table rules like remark-lint-table-cell-padding. Supports custom string length detection function for CJK/emoji characters. ESM-only, requires Node.js 16+.

error Cannot find module 'remark-lint-table-pipe-alignment'
cause Using require() in an ESM-only package or missing npm install.
fix
Run 'npm install remark-lint-table-pipe-alignment' and use import syntax.
error Error: Cannot use import statement outside a module
cause Running the package without 'type': 'module' in package.json or without .mjs extension.
fix
Add "type": "module" to package.json or rename file to .mjs.
error TypeError: remarkLintTablePipeAlignment is not a function
cause Importing the package incorrectly (e.g., const x = require('...') breaks ESM).
fix
Use 'import remarkLintTablePipeAlignment from 'remark-lint-table-pipe-alignment''.
breaking Package is ESM-only since v4. Requires Node.js 16+ and 'import' syntax.
fix Use ES module imports (import ... from 'remark-lint-table-pipe-alignment') instead of require().
deprecated Older versions (v3.x) still support CommonJS but are no longer maintained.
fix Upgrade to v4+ and switch to ESM.
gotcha The rule depends on remark-gfm to parse GFM tables; without it, it may not work as expected.
fix Install remark-gfm and add .use(remarkGfm) before lint rules in the unified pipeline.
gotcha The 'stringLength' option must handle all characters; CJK/emoji may be misaligned without custom length detection.
fix Provide a function that measures display width, e.g., using the 'string-width' package.
npm install remark-lint-table-pipe-alignment
yarn add remark-lint-table-pipe-alignment
pnpm add remark-lint-table-pipe-alignment

Uses unified pipeline to parse Markdown, lint table pipe alignment, stringify, and report warnings.

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

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

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

console.error(reporter(file));