A helper package for the unified ecosystem that simplifies creating linting rules for processors like remark, retext, and rehype. Version 3.0.1 is the current stable release (ESM-only, requires Node.js 16+). It provides a `lintRule` function that takes metadata and a rule callback, handling plugin registration, error messages via VFile, and severity levels. Key differentiators: reduces boilerplate for unified lint rule authors, supports both sync and async rules, includes TypeScript types, and is part of the official remark-lint family.
npm install unified-lint-ruleNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a custom rule that checks file extension, showing the minimal API to build a lint rule.
Switch to ES module syntax (import) and ensure package.json has "type": "module" or use .mjs extension.
Define rule with exactly 3 parameters for sync, or 4 parameters (including `Next`) for async, and always call next() to avoid hanging.
Check for undefined options and provide defaults explicitly (e.g., `const opts = options || 'md'`).
Ensure your unified version is compatible (>=10). No code changes needed if using unified's .use().
Convert to ES module syntax: use `import { lintRule } from 'unified-lint-rule'` and set "type": "module" in package.json.Ensure the first argument to `file.message` is a string describing the lint error: `file.message('Incorrect extension: use `' + option + '`')`.Provide a properly formatted origin string like 'remark-lint:my-rule' (must contain a colon).
No dependency data recorded yet.