remark-lint-directive-collapsed-attribute

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

A remark-lint rule that enforces collapsed attribute notation in directives, warning when verbose attribute values are used (e.g., `{largest=""}` instead of `{largest}`). Version 1.0.1, ESM-only, requires Node.js 16+. Ships TypeScript types. Part of the unified/remark ecosystem. Does not ship with any preset.

error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'remark-lint-directive-collapsed-attribute'
cause CommonJS require() used on ESM-only package.
fix
Replace require() with import: import remarkLintDirectiveCollapsedAttribute from 'remark-lint-directive-collapsed-attribute'
error TypeError: remarkLintDirectiveCollapsedAttribute is not a function
cause Importing the package incorrectly (e.g., named import instead of default).
fix
Ensure you use the default import: import remarkLintDirectiveCollapsedAttribute from 'remark-lint-directive-collapsed-attribute'
error 1:18-1:25: Unexpected verbose attribute value, expected collapsed attribute
cause Using verbose attribute notation like `{largest=""}` instead of collapsed `{largest}`.
fix
Use collapsed attribute syntax: :planet[Jupiter]{largest}
breaking Package is ESM-only and cannot be imported using require().
fix Use import syntax or dynamic import(). For Node.js CJS, consider using a bundler or setting type: module.
gotcha The rule only works on directives parsed by remark-directive; without it, directives are not recognized and no warnings are emitted.
fix Ensure you have remark-directive installed and added to the unified pipeline before this rule.
deprecated No deprecation warnings known.
fix N/A
npm install remark-lint-directive-collapsed-attribute
yarn add remark-lint-directive-collapsed-attribute
pnpm add remark-lint-directive-collapsed-attribute

Demonstrates how to use the rule with unified pipeline: parse markdown, apply linting, and check for collapsed attribute warnings.

import remarkLint from 'remark-lint';
import remarkLintDirectiveCollapsedAttribute from 'remark-lint-directive-collapsed-attribute';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import { unified } from 'unified';
import { read } from 'to-vfile';

const file = await read('example.md');

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

console.log(file.messages);