{"id":20344,"library":"prettier-plugin-codeowners","title":"Prettier Plugin for CODEOWNERS","description":"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.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/jeffreylo/prettier-plugin-codeowners","tags":["javascript","prettier","plugin","codeowners","formatter"],"install":[{"cmd":"npm install prettier-plugin-codeowners","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-codeowners","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-codeowners","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - plugin requires Prettier 3.x to function","package":"prettier","optional":false}],"imports":[{"note":"Plugin is used via Node.js require in Prettier config files, not typically imported directly.","wrong":"","symbol":"default plugin","correct":"const plugin = require('prettier-plugin-codeowners');"},{"note":"The plugin is a default export. Named import will fail.","wrong":"import { plugin } from 'prettier-plugin-codeowners';","symbol":"plugin (ESM)","correct":"import plugin from 'prettier-plugin-codeowners';"},{"note":"The plugin must be loaded via --plugin flag or in config. --parser alone will not find the plugin.","wrong":"prettier --write .github/CODEOWNERS --parser=codeowners","symbol":"CLI usage","correct":"prettier --write .github/CODEOWNERS --plugin=prettier-plugin-codeowners"}],"quickstart":{"code":"// Install:\n// npm install -D prettier prettier-plugin-codeowners\n\n// 1. Add to .prettierrc:\n// {\n//   \"plugins\": [\"prettier-plugin-codeowners\"]\n// }\n\n// 2. Format a CODEOWNERS file:\n// prettier --write .github/CODEOWNERS\n\n// 3. Or use programmatically:\nimport * as prettier from 'prettier';\nimport plugin from 'prettier-plugin-codeowners';\n\nconst source = `*       @owner1\n*.js         @owner2\n`;\n\nconst formatted = await prettier.format(source, {\n  plugins: [plugin],\n});\n\nconsole.log(formatted);\n// Output:\n// *            @owner1\n// *.js         @owner2\n","lang":"javascript","description":"Demonstrates installation, configuration, and programmatic usage of the plugin to format a CODEOWNERS file."},"warnings":[{"fix":"Add blank lines between sections to control alignment boundaries.","message":"Column alignment is per-section, not global across file. If you have multiple sections separated by blank lines, each section will have its own alignment width.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add text after # if you want to keep the comment, or remove # if you want the pattern with no comment.","message":"Inline comments with no text after # are dropped entirely. A line like '*.js @owner #' becomes '*.js @owner'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Do not depend on leading blank lines for formatting.","message":"Leading and trailing blank lines in the file are stripped. If your CODEOWNERS relies on leading whitespace semantically, it will be removed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Prettier to version 3.x.","message":"Prettier 2.x is not supported. This plugin requires Prettier ^3.0.0.","severity":"deprecated","affected_versions":"<3.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 install -D prettier-plugin-codeowners'","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'prettier-plugin-codeowners'"},{"fix":"Add the plugin to .prettierrc { \"plugins\": [\"prettier-plugin-codeowners\"] } or use --plugin=prettier-plugin-codeowners in CLI.","cause":"Plugin not loaded in Prettier config or CLI flags.","error":"Error: Cannot resolve parser 'codeowners'"},{"fix":"Update Prettier to version 3.x: 'npm install -D prettier@latest'","cause":"Incompatible Prettier version installed.","error":"Error: prettier-plugin-codeowners requires prettier version ^3.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}