A Prettier plugin (v0.1.1) that formats CODEOWNERS files used by GitHub to define code ownership. It automatically detects files named CODEOWNERS in any directory and applies formatting rules such as aligning owner columns per section, sorting owners alphabetically per line, preserving inline comments, normalizing whitespace, and collapsing blank lines. It requires Prettier ^3.0.0 as a peer dependency and is available on npm with active maintenance. Unlike generic file formatters, it understands CODEOWNERS syntax specific sections and no-owner lines.
npm install prettier-plugin-codeownersVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation, configuration, and programmatic usage of the plugin to format a CODEOWNERS file.
Add blank lines between sections to control alignment boundaries.
Add text after # if you want to keep the comment, or remove # if you want the pattern with no comment.
Do not depend on leading blank lines for formatting.
Upgrade Prettier to version 3.x.
Run 'npm install -D prettier-plugin-codeowners'
Add the plugin to .prettierrc { "plugins": ["prettier-plugin-codeowners"] } or use --plugin=prettier-plugin-codeowners in CLI.Update Prettier to version 3.x: 'npm install -D prettier@latest'