{"id":26203,"library":"remark-lint-directive-attribute-sort","title":"remark-lint-directive-attribute-sort","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","attribute","compare","directive","lint","order","remark","remark-lint","remark-lint-rule","typescript"],"install":[{"cmd":"npm install remark-lint-directive-attribute-sort","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-directive-attribute-sort","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-directive-attribute-sort","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provided unified plugin that adds linting infrastructure","package":"remark-lint","optional":false},{"reason":"Required to parse directive syntax in Markdown","package":"remark-directive","optional":false},{"reason":"Core processing engine for remark and plugins","package":"unified","optional":false}],"imports":[{"note":"Package is ESM-only; CommonJS require() throws. Must use import statement or dynamic import().","wrong":"const remarkLintDirectiveAttributeSort = require('remark-lint-directive-attribute-sort')","symbol":"remarkLintDirectiveAttributeSort","correct":"import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort'"},{"note":"The package exports a single default export; named import syntax gives undefined.","wrong":"import { remarkLintDirectiveAttributeSort } from 'remark-lint-directive-attribute-sort'","symbol":"default export (unnamed)","correct":"import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort'"},{"note":"TypeScript types are shipped; no separate type import needed.","wrong":"","symbol":"type (if using TypeScript)","correct":"import type { Plugin } from 'unified';\nimport remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort'"}],"quickstart":{"code":"import { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkStringify from 'remark-stringify';\nimport remarkDirective from 'remark-directive';\nimport remarkLint from 'remark-lint';\nimport remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort';\nimport { reporter } from 'vfile-reporter';\nimport { read } from 'to-vfile';\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkDirective)\n  .use(remarkLint)\n  .use(remarkLintDirectiveAttributeSort)\n  .use(remarkStringify)\n  .process(await read('example.md'));\n\nconsole.error(reporter(file));","lang":"typescript","description":"Configure unified pipeline with remark-parse, remark-directive, remark-lint, and the rule; lint example.md and report errors to stderr."},"warnings":[{"fix":"Add .use(remarkDirective) before .use(remarkLintDirectiveAttributeSort)","message":"Missing remark-directive: If remark-directive is not added to the pipeline, directives are not parsed and the rule will not lint.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to Node.js 16+ or use dynamic import().","message":"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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove any options; the rule only checks alphabetical order as-is.","message":"No options: The rule accepts no parameters, but users sometimes try to pass options like { caseSensitive: true } which are silently ignored.","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":"Use import instead: import remarkLintDirectiveAttributeSort from 'remark-lint-directive-attribute-sort'","cause":"CommonJS require() used on an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Run npm install remark-lint-directive-attribute-sort (and its peer deps remark-lint, remark-directive, unified, etc.)","cause":"Package not installed or missing dependencies.","error":"Error: Cannot find module 'remark-lint-directive-attribute-sort'"},{"fix":"Change import { remarkLintDirectiveAttributeSort } to import remarkLintDirectiveAttributeSort","cause":"Using named import instead of default import.","error":"TypeError: remarkLintDirectiveAttributeSort is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}