remark-lint-no-file-name-irregular-characters

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

A remark-lint rule that warns when Markdown file names contain characters outside a configurable allowed set (default: alphanumeric, dash, dot). Current stable version is 3.0.1. It is part of the unified/remark ecosystem, maintained by the remark organization, and follows semantic versioning. Key differentiator: allows custom regex patterns to define which characters are irregular, enabling project-specific naming conventions. Supports ESM only, Node.js 16+, and TypeScript types.

error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Using require() to import an ESM-only package (v3+).
fix
Change to import: import remarkLintNoFileNameIrregularCharacters from 'remark-lint-no-file-name-irregular-characters'
error Unexpected character `_` in file name
cause The underscore is not in the allowed characters set by default.
fix
Configure the plugin with an options string that includes underscore: .use(remarkLintNoFileNameIrregularCharacters, '\.a-z0-9_')
breaking This package is ESM-only from version 3.0.0 onwards. Importing with require() will fail.
fix Use import syntax instead of require(). If you need CJS, stick with version 2.x.
breaking Node.js version <16 is no longer supported from version 3.0.0.
fix Upgrade Node.js to version 16 or later.
gotcha The options parameter can be a string or RegExp. If string, it is used as the allowed characters set (inverted to form the irregular pattern). Be careful to escape regex special characters in the string.
fix Check your options string: it should represent allowed characters, e.g., '\.a-z0-9' for dots, lowercase letters, and digits.
gotcha The default regular expression allows only letters (A-Za-z), digits (0-9), dash (-), and dot (.). Underscores and spaces are considered irregular.
fix If you need underscores, pass a custom options string like '\.a-z0-9_' or a RegExp.
npm install remark-lint-no-file-name-irregular-characters
yarn add remark-lint-no-file-name-irregular-characters
pnpm add remark-lint-no-file-name-irregular-characters

Configures remark with the lint rule to check file names for irregular characters, processes a Markdown file, and reports messages.

import remarkLint from 'remark-lint';
import remarkLintNoFileNameIrregularCharacters from 'remark-lint-no-file-name-irregular-characters';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import {read} from 'to-vfile';
import {unified} from 'unified';
import {reporter} from 'vfile-reporter';

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

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

console.error(reporter(file));