Registry / testing / remark-lint-file-extension

remark-lint-file-extension

JSON →
library3.0.1jsnpmunverified

A remark-lint rule to warn when a file's extension does not match a configured style. Current stable version is 3.0.1, part of the remark-lint monorepo with regular updates. It checks file extensions against a list of allowed values, supports allowing extensionless files (default true), and provides a TypeScript type for configuration. Key differentiator: it enforces consistent file naming conventions in markdown projects, useful for ensuring .md vs .mdx compliance. ESM-only since v3, requires Node.js 16+.

npm install remark-lint-file-extension
INSTALL
IMPORT
SIG · REMARK-LINT-FILE-E
R
remark-lint-file-extension
testingjavascriptv3.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

remarkLintFileExtension
import remarkLintFileExtension from 'remark-lint-file-extension'
const remarkLintFileExtension = require('remark-lint-file-extension')
ESM-only since v3; CommonJS require() will throw
Extensions
import type { Extensions } from 'remark-lint-file-extension'
TypeScript type for allowed extensions, only available as type import
Options
import type { Options } from 'remark-lint-file-extension'
TypeScript type for plugin options, only available as type import

Shows how to use remark-lint-file-extension with the unified API to validate a file's extension.

import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkStringify from 'remark-stringify'; import remarkLint from 'remark-lint'; import remarkLintFileExtension from 'remark-lint-file-extension'; import { read } from 'to-vfile'; import { reporter } from 'vfile-reporter'; const file = await read('example.md'); await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintFileExtension, { extensions: ['md'], allowExtensionless: true }) .use(remarkStringify) .process(file); console.error(reporter(file));
Debug
Known issues
breakingESM-only since v3: package no longer supports CommonJS require()
fix
Use import or dynamic import() instead of require(). For Node.js, ensure "type": "module" in package.json or use .mjs extension.
affects: >=3.0.0
breakingNode.js version requirement: v16+ starting from v3
fix
Upgrade Node.js to v16 or later, or use an older version (v2.x) of the package.
affects: >=3.0.0
deprecatedDefault extensions changed from ['md', 'mdx'] to ['md', 'mdx'] in v3 (no change but worth noting that config is required to override)
fix
Explicitly set extensions option if you need different values.
affects: >=3.0.0
gotchaPlugin must be used after remark-lint plugin in the unified chain
fix
Ensure .use(remarkLint) is called before .use(remarkLintFileExtension).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'remark-lint-file-extension'
Missing installation or wrong import path
fix
Run 'npm install remark-lint-file-extension' and ensure import path matches: 'remark-lint-file-extension'
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using CommonJS require() on an ESM-only package
fix
Use 'import' syntax or 'import()' dynamic import. For old projects, stick to version 2.x.
TypeError: remarkLint is not a function
remark-lint plugin not applied before the rule in the unified chain
fix
Make sure to call .use(remarkLint) before .use(remarkLintFileExtension).
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
unifiedrequiredcore unified plugin framework
remark-lintrequiredrequired to run any remark-lint rule
remark-parseoptionalneeded for parsing markdown in API usage
remark-stringifyoptionalneeded for serializing markdown in API usage
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-file-extension — npm install remark-lint-file-extension · libregistry