Registry / devops / prettier-plugin-codeowners

prettier-plugin-codeowners

JSON →
library0.1.1jsnpmunverified

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-codeowners
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-CO
P
prettier-plugin-codeowners
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default plugin
const plugin = require('prettier-plugin-codeowners');
Plugin is used via Node.js require in Prettier config files, not typically imported directly.
plugin (ESM)
import plugin from 'prettier-plugin-codeowners';
import { plugin } from 'prettier-plugin-codeowners';
The plugin is a default export. Named import will fail.
CLI usage
prettier --write .github/CODEOWNERS --plugin=prettier-plugin-codeowners
prettier --write .github/CODEOWNERS --parser=codeowners
The plugin must be loaded via --plugin flag or in config. --parser alone will not find the plugin.

Demonstrates installation, configuration, and programmatic usage of the plugin to format a CODEOWNERS file.

// Install: // npm install -D prettier prettier-plugin-codeowners // 1. Add to .prettierrc: // { // "plugins": ["prettier-plugin-codeowners"] // } // 2. Format a CODEOWNERS file: // prettier --write .github/CODEOWNERS // 3. Or use programmatically: import * as prettier from 'prettier'; import plugin from 'prettier-plugin-codeowners'; const source = `* @owner1 *.js @owner2 `; const formatted = await prettier.format(source, { plugins: [plugin], }); console.log(formatted); // Output: // * @owner1 // *.js @owner2
Debug
Known issues
gotchaColumn 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.
fix
Add blank lines between sections to control alignment boundaries.
affects: >=0.0.0
gotchaInline comments with no text after # are dropped entirely. A line like '*.js @owner #' becomes '*.js @owner'.
fix
Add text after # if you want to keep the comment, or remove # if you want the pattern with no comment.
affects: >=0.0.0
gotchaLeading and trailing blank lines in the file are stripped. If your CODEOWNERS relies on leading whitespace semantically, it will be removed.
fix
Do not depend on leading blank lines for formatting.
affects: >=0.0.0
deprecatedPrettier 2.x is not supported. This plugin requires Prettier ^3.0.0.
fix
Upgrade Prettier to version 3.x.
affects: <3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-codeowners'
Plugin not installed or not in node_modules.
fix
Run 'npm install -D prettier-plugin-codeowners'
Error: Cannot resolve parser 'codeowners'
Plugin not loaded in Prettier config or CLI flags.
fix
Add the plugin to .prettierrc { "plugins": ["prettier-plugin-codeowners"] } or use --plugin=prettier-plugin-codeowners in CLI.
Error: prettier-plugin-codeowners requires prettier version ^3.0.0
Incompatible Prettier version installed.
fix
Update Prettier to version 3.x: 'npm install -D prettier@latest'
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
prettierrequiredpeer dependency - plugin requires Prettier 3.x to function
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-codeowners — npm install prettier-plugin-codeowners · libregistry