remark-lint-final-definition
raw JSON → 4.0.2 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when Markdown definitions (e.g., [label]: url) are placed inside the document body instead of at the end. Current stable version is 4.0.2. Part of the remark-lint ecosystem, it helps enforce consistent placement of definitions, typically at the bottom of files. This package is ESM-only, ships TypeScript types, and requires Node.js 16+. Unlike general Markdown linters, it focuses specifically on definition positioning and integrates seamlessly with unified and remark pipelines.
Common errors
error Error: Cannot find module 'remark-lint-final-definition' ↓
cause Package not installed or Node.js cannot resolve it because it is ESM-only and the importing module is CJS.
fix
Install the package with 'npm install remark-lint-final-definition'. If using CommonJS, switch to ESM or use dynamic import.
error SyntaxError: Unexpected token 'export' ↓
cause The package uses ESM syntax but the Node.js project has not enabled ESM (no type: 'module' in package.json).
fix
Add '"type": "module"' to your package.json or rename files to .mjs.
error TypeError: remarkLintFinalDefinition is not a function ↓
cause Using a named import instead of default import. The package exports the plugin as default only.
fix
Use 'import remarkLintFinalDefinition from 'remark-lint-final-definition'' (default import).
Warnings
breaking Version 4.x drops CommonJS support and is ESM-only. ↓
fix Migrate to ESM or use dynamic import(). Ensure your project is configured for ESM (such as type: 'module' in package.json).
deprecated Version 3.x and earlier are no longer maintained. ↓
fix Upgrade to version 4.x and follow ESM migration.
gotcha The plugin requires remark-lint to be registered before it; otherwise it will not function. ↓
fix Ensure remarkLint is used before remarkLintFinalDefinition in the unified pipeline.
gotcha The plugin ignores HTML comments and MDX comments, which may cause unexpected behavior if definitions are placed after such comments. ↓
fix Place definitions strictly at the end of the file, after all comments.
gotcha Using the CLI without --frail may cause lint messages to be ignored in CI. ↓
fix Use the --frail option to exit with a non-zero code on warnings.
Install
npm install remark-lint-final-definition yarn add remark-lint-final-definition pnpm add remark-lint-final-definition Imports
- remarkLintFinalDefinition wrong
const remarkLintFinalDefinition = require('remark-lint-final-definition')correctimport remarkLintFinalDefinition from 'remark-lint-final-definition' - default export
import remarkLintFinalDefinition from 'remark-lint-final-definition' - TypeScript types wrong
import { remarkLintFinalDefinition } from 'remark-lint-final-definition'correctimport type { Transformer } from 'unified'
Quickstart
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintFinalDefinition from 'remark-lint-final-definition';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';
const file = await read('example.md');
await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintFinalDefinition)
.use(remarkStringify)
.process(file);
console.error(reporter(file));