remark-lint-no-trailing-spaces

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

A remark-lint external rule that warns when lines end with trailing spaces or tabs. Current stable version: 4.0.3. Released as a standalone package, it integrates with the remark-lint ecosystem for linting Markdown. Simple and focused: only checks for trailing whitespace, no configuration options. Differentiates from similar rules by being an external rule from the unified collective, maintained separately. Release cadence is irregular.

error Cannot find module 'remark-lint-no-trailing-spaces'
cause Package not installed or import path incorrect.
fix
npm install remark-lint-no-trailing-spaces
error TypeError: noTrailingSpaces is not a function
cause Using ES import in a CommonJS environment without default handling.
fix
Use: const noTrailingSpaces = require('remark-lint-no-trailing-spaces').default; OR switch to ESM.
error Error: Cannot find module 'remark-lint'
cause remark-lint peer dependency not installed.
fix
npm install remark-lint
breaking Version 4.0.0 drops support for Node.js < 18.
fix Upgrade Node.js to version 18 or later.
breaking Version 4.0.0 switches to ESM-only; CommonJS require() will not work without .default property.
fix Use import statement or const noTrailingSpaces = require('remark-lint-no-trailing-spaces').default.
deprecated As of v3, the package is still CJS compatible.
fix No action needed; but consider migrating to ESM for future compatibility.
gotcha This rule only lints for trailing spaces and tabs; it does not check for trailing newlines or other whitespace issues.
fix Use additional remark-lint rules like remark-lint-no-consecutive-blank-lines or remark-lint-final-newline for related checks.
npm install remark-lint-no-trailing-spaces
yarn add remark-lint-no-trailing-spaces
pnpm add remark-lint-no-trailing-spaces

Shows how to use the rule with remark-lint to detect trailing spaces in a Markdown document.

import { remark } from 'remark';
import lint from 'remark-lint';
import noTrailingSpaces from 'remark-lint-no-trailing-spaces';

const file = await remark()
  .use(lint)
  .use(noTrailingSpaces)
  .process('# Title  \nHello world!');

console.log(file.messages);
// Output: [1:8-1:9 warning Remove trailing spaces no-trailing-spaces remark-lint]