remark-lint-prohibited-strings

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

A remark-lint plugin to prohibit specified strings in markdown files (excluding code blocks). Version 4.0.0 is current and stable, with infrequent releases. It supports case-sensitive and case-insensitive matching, regular expressions, capture group replacement, and optional exclusion of matches adjacent to specified characters. Compared to alternatives, it is lightweight and simple, focused solely on string prohibition without additional linting rules.

error Error: Cannot find module 'remark-lint-prohibited-strings'
cause The package is installed but not registered in the dependencies, or the import path is incorrect.
fix
Run npm install remark-lint-prohibited-strings and use the correct import as shown in the quickstart.
error TypeError: Cannot read properties of undefined (reading 'some')
cause Configuration passed to the plugin is not an array or is malformed.
fix
Ensure the second argument to .use() is an array of rule objects, e.g., [ { no: 'foo', yes: 'bar' } ].
gotcha The plugin does not check inside fenced code blocks or inline code spans, which may cause missed violations if prohibited strings appear in code examples.
fix Use additional linting rules or preprocess the file if code block linting is required.
gotcha Regular expressions in the `no` field are provided as strings; they must be escaped properly (e.g., double backslashes for digit groups).
fix Ensure regex strings are escaped for JavaScript string literal, e.g., '[Rr][Ff][Cc](\\d+)'.
gotcha If `no` is omitted, the prohibited string is derived from `yes` but with case-insensitive matching; any case variation of `yes` will be flagged.
fix Explicitly include `no` with the exact case you want to match if case-insensitive behavior is not desired.
npm install remark-lint-prohibited-strings
yarn add remark-lint-prohibited-strings
pnpm add remark-lint-prohibited-strings

Shows setup of remark-lint with prohibited-strings plugin and linting a simple markdown file.

import { remark } from 'remark';
import remarkLint from 'remark-lint';
import remarkLintProhibitedStrings from 'remark-lint-prohibited-strings';

const file = await remark()
  .use(remarkLint)
  .use(remarkLintProhibitedStrings, [
    { no: 'Javascript', yes: 'JavaScript' },
    { no: 'Github', yes: 'GitHub' }
  ])
  .process('# Hello Javascript world');

console.log(file.messages);
// Output: [1:10-1:19: Replace "Javascript" with "JavaScript" (prohibited-strings)]