remark-lint-no-file-name-outer-dashes

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

A remark-lint rule that warns when file names start or end with dashes. Current stable version is 3.0.1, compatible with Node.js 16+. It is part of the remark-lint ecosystem and is ESM-only. This rule helps enforce consistent file naming conventions by flagging leading or trailing hyphens, which are often unintended. It is included in the `remark-preset-lint-markdown-style-guide` preset. Releases follow the unified collective's schedule with occasional patches across all packages.

error Cannot find module 'remark-lint-no-file-name-outer-dashes'
cause Package not installed or wrong import path.
fix
Run 'npm install remark-lint-no-file-name-outer-dashes' and ensure correct import statement.
error ERR_REQUIRE_ESM: require() of ES Module
cause Using require() with an ESM-only package.
fix
Change to import statement: import remarkLintNoFileNameOuterDashes from 'remark-lint-no-file-name-outer-dashes'
breaking ESM-only: Package is ESM-only since v3. require() will throw an error.
fix Use import instead of require. For older Node.js, use dynamic import or migrate to ESM.
breaking Node.js 16+ required: As of v3, the package requires Node.js 16 or later.
fix Upgrade Node.js to version 16 or higher.
deprecated No longer supports Node.js <16: Dropped support for Node.js versions below 16.
fix Upgrade Node.js to 16+.
npm install remark-lint-no-file-name-outer-dashes
yarn add remark-lint-no-file-name-outer-dashes
pnpm add remark-lint-no-file-name-outer-dashes

Shows how to use the rule in Node.js with unified to detect leading dashes in a filename.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintNoFileNameOuterDashes from 'remark-lint-no-file-name-outer-dashes';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';

const file = await read('-mercury.md');

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

console.error(reporter(file));
// Output: 1:1: Unexpected initial or final dashes in file name, expected dashes to join words