{"id":26210,"library":"remark-lint-file-extension","title":"remark-lint-file-extension","description":"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+.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","extension","extname","file","lint","remark","remark-lint","remark-lint-rule","rule","typescript"],"install":[{"cmd":"npm install remark-lint-file-extension","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-file-extension","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-file-extension","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core unified plugin framework","package":"unified","optional":false},{"reason":"required to run any remark-lint rule","package":"remark-lint","optional":false},{"reason":"needed for parsing markdown in API usage","package":"remark-parse","optional":true},{"reason":"needed for serializing markdown in API usage","package":"remark-stringify","optional":true}],"imports":[{"note":"ESM-only since v3; CommonJS require() will throw","wrong":"const remarkLintFileExtension = require('remark-lint-file-extension')","symbol":"remarkLintFileExtension","correct":"import remarkLintFileExtension from 'remark-lint-file-extension'"},{"note":"TypeScript type for allowed extensions, only available as type import","wrong":"","symbol":"Extensions","correct":"import type { Extensions } from 'remark-lint-file-extension'"},{"note":"TypeScript type for plugin options, only available as type import","wrong":"","symbol":"Options","correct":"import type { Options } from 'remark-lint-file-extension'"}],"quickstart":{"code":"import { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkStringify from 'remark-stringify';\nimport remarkLint from 'remark-lint';\nimport remarkLintFileExtension from 'remark-lint-file-extension';\nimport { read } from 'to-vfile';\nimport { reporter } from 'vfile-reporter';\n\nconst file = await read('example.md');\n\nawait unified()\n  .use(remarkParse)\n  .use(remarkLint)\n  .use(remarkLintFileExtension, { extensions: ['md'], allowExtensionless: true })\n  .use(remarkStringify)\n  .process(file);\n\nconsole.error(reporter(file));","lang":"typescript","description":"Shows how to use remark-lint-file-extension with the unified API to validate a file's extension."},"warnings":[{"fix":"Use import or dynamic import() instead of require(). For Node.js, ensure \"type\": \"module\" in package.json or use .mjs extension.","message":"ESM-only since v3: package no longer supports CommonJS require()","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade Node.js to v16 or later, or use an older version (v2.x) of the package.","message":"Node.js version requirement: v16+ starting from v3","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Explicitly set extensions option if you need different values.","message":"Default extensions changed from ['md', 'mdx'] to ['md', 'mdx'] in v3 (no change but worth noting that config is required to override)","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Ensure .use(remarkLint) is called before .use(remarkLintFileExtension).","message":"Plugin must be used after remark-lint plugin in the unified chain","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install remark-lint-file-extension' and ensure import path matches: 'remark-lint-file-extension'","cause":"Missing installation or wrong import path","error":"Cannot find module 'remark-lint-file-extension'"},{"fix":"Use 'import' syntax or 'import()' dynamic import. For old projects, stick to version 2.x.","cause":"Using CommonJS require() on an ESM-only package","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Make sure to call .use(remarkLint) before .use(remarkLintFileExtension).","cause":"remark-lint plugin not applied before the rule in the unified chain","error":"TypeError: remarkLint is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}