{"id":20424,"library":"prettier-plugin-sort-markdown-table","title":"prettier-plugin-sort-markdown-table","description":"Prettier plugin that sorts the rows of markdown tables alphabetically by the first column. Current stable version is 2.0.0, released May 2025, with a slow release cadence. Requires Prettier 3.x. Table sorting is opt-in: only tables preceded by a `<!-- prettier-sort-markdown-table -->` comment are sorted. Key differentiator: minimal configuration — just drop in and annotate — unlike other markdown formatters that require manual sorting.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/SevenOutman/prettier-plugin-sort-markdown-table","tags":["javascript","prettier","plugin","markdown","table","typescript"],"install":[{"cmd":"npm install prettier-plugin-sort-markdown-table","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-sort-markdown-table","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-sort-markdown-table","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency — plugin requires Prettier 3.x","package":"prettier","optional":false}],"imports":[{"note":"Prettier plugins are typically loaded via require in .prettierrc.js or prettier.config.js; ESM import is not recommended for plugin registration.","wrong":"import prettierPluginSortMarkdownTable from 'prettier-plugin-sort-markdown-table'","symbol":"plugin","correct":"plugins: [require('prettier-plugin-sort-markdown-table')]"},{"note":"The package does not export any symbols for programmatic usage; it only registers as a Prettier plugin.","wrong":"import { default } from 'prettier-plugin-sort-markdown-table'","symbol":"default export","correct":"export default { plugins: ['prettier-plugin-sort-markdown-table'] }"},{"note":"The plugin must be specified with --plugin flag when running prettier CLI if not auto-loaded.","wrong":"prettier --plugin='prettier-plugin-sort-markdown-table' README.md","symbol":"CLI usage","correct":"npx prettier --plugin=prettier-plugin-sort-markdown-table --write README.md"}],"quickstart":{"code":"npm i -D prettier prettier-plugin-sort-markdown-table\n\ncat > .prettierrc.js << 'EOF'\nmodule.exports = {\n  plugins: ['prettier-plugin-sort-markdown-table'],\n};\nEOF\n\ncat > README.md << 'EOF'\n<!-- prettier-sort-markdown-table -->\n| name | email |\n| ---- | ----- |\n| zhang | zhang@a.com |\n| wang | wang@a.com |\n| alice | alice@example.com |\nEOF\n\nnpx prettier --write README.md\n\n# Output README.md rows sorted by first column alphabetically: alice, wang, zhang","lang":"typescript","description":"Installs the plugin, configures Prettier to load it automatically, then formats a markdown table with the opt-in comment."},"warnings":[{"fix":"Upgrade Prettier to version 3.x","message":"v2.0.0 drops support for Prettier 2; requires Prettier 3.x","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Add `<!-- prettier-sort-markdown-table -->` on the line immediately above the table.","message":"Table sorting only works when preceded by the annotation comment `<!-- prettier-sort-markdown-table -->`. Without it, no sorting occurs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure plugins are listed in the correct order or test formatting with both plugins enabled.","message":"The plugin may conflict with other prettier plugins that also process markdown (e.g., prettier-plugin-md-nocjsp) leading to unexpected order of operations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to v2.0.0 and Prettier 3.x","message":"v1.x is deprecated and may not work with newer Prettier versions; upgrade to v2 for compatibility.","severity":"deprecated","affected_versions":">=1.0.0 <2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm i -D prettier-plugin-sort-markdown-table`","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'prettier-plugin-sort-markdown-table'"},{"fix":"Upgrade Prettier to 3.x and use plugin v2.0.0 or later","cause":"Prettier version is too old (pre v3) or plugin is not compatible.","error":"Error: Invalid plugin: prettier-plugin-sort-markdown-table"},{"fix":"Use `pretty-quick --pattern '**/*.md'`","cause":"Running pretty-quick without specifying markdown files, or using wrong glob pattern.","error":"Error: [pretty-quick] No files matching the pattern found in the working tree."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}