remark-lint-directive-attribute-sort

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

remark-lint rule to lint and enforce alphabetical ordering of attributes on Markdown directives (e.g., :planet[Saturn]{attr1="val1" attr2="val2"). Stable version 1.0.1 is ESM-only for Node.js 16+. Part of the remark-lint ecosystem, it checks attribute order but does not differentiate attribute values or collapsed syntax. It requires remark-directive to parse directives. Unlike generic linters, it integrates seamlessly into remark pipelines via unified. Released as part of the remark-lint monorepo with TypeScript types included.

error SyntaxError: Unexpected token 'export'
cause CommonJS require() used on an ESM-only package.
fix
Use import instead: import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort'
error Error: Cannot find module 'remark-lint-directive-attribute-sort'
cause Package not installed or missing dependencies.
fix
Run npm install remark-lint-directive-attribute-sort (and its peer deps remark-lint, remark-directive, unified, etc.)
error TypeError: remarkLintDirectiveAttributeSort is not a function
cause Using named import instead of default import.
fix
Change import { remarkLintDirectiveAttributeSort } to import remarkLintDirectiveAttributeSort
gotcha Missing remark-directive: If remark-directive is not added to the pipeline, directives are not parsed and the rule will not lint.
fix Add .use(remarkDirective) before .use(remarkLintDirectiveAttributeSort)
gotcha ESM only: In Node.js <16 (especially 14 or 12) the package fails to load because it is ESM-only and requires 'type': 'module' in package.json.
fix Upgrade to Node.js 16+ or use dynamic import().
gotcha No options: The rule accepts no parameters, but users sometimes try to pass options like { caseSensitive: true } which are silently ignored.
fix Remove any options; the rule only checks alphabetical order as-is.
npm install remark-lint-directive-attribute-sort
yarn add remark-lint-directive-attribute-sort
pnpm add remark-lint-directive-attribute-sort

Configure unified pipeline with remark-parse, remark-directive, remark-lint, and the rule; lint example.md and report errors to stderr.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkDirective from 'remark-directive';
import remarkLint from 'remark-lint';
import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort';
import { reporter } from 'vfile-reporter';
import { read } from 'to-vfile';

const file = await unified()
  .use(remarkParse)
  .use(remarkDirective)
  .use(remarkLint)
  .use(remarkLintDirectiveAttributeSort)
  .use(remarkStringify)
  .process(await read('example.md'));

console.error(reporter(file));