require-single-codeowners-file
Require exactly one authoritative CODEOWNERS file location.
Targeted pattern scopeâ
This rule checks all recognised CODEOWNERS locations across platforms:
.github/CODEOWNERSâ GitHub: highest priority.gitlab/CODEOWNERSâ GitLab: highest priority.bitbucket/CODEOWNERSâ Bitbucket Cloud: supported locationCODEOWNERSâ shared root locationdocs/CODEOWNERSâ GitHub: lowest priority
What this rule reportsâ
This rule reports repositories that define CODEOWNERS in more than one of
those locations.
Each platform applies its own precedence when multiple files exist and only uses the first one it finds:
GitHub (highest â lowest):
.github/CODEOWNERSCODEOWNERSdocs/CODEOWNERS
GitLab (highest â lowest):
.gitlab/CODEOWNERSCODEOWNERS
Bitbucket Cloud:
.bitbucket/CODEOWNERS
Why this rule existsâ
Multiple CODEOWNERS files create policy ambiguity.
Teams may update a lower-precedence file and expect behavior to change, while the platform silently keeps using the higher-precedence file. That leads to incorrect review routing and surprise ownership gaps.
â Incorrectâ
// Repository files
// .
// âââ CODEOWNERS
// âââ .github/
// âââ CODEOWNERS
//
// GitHub will use .github/CODEOWNERS and silently ignore root CODEOWNERS.
// Repository files
// .
// âââ CODEOWNERS
// âââ .gitlab/
// âââ CODEOWNERS
//
// GitLab will use .gitlab/CODEOWNERS and silently ignore root CODEOWNERS.
// Repository files
// .
// âââ CODEOWNERS
// âââ .bitbucket/
// âââ CODEOWNERS
//
// Bitbucket Cloud uses .bitbucket/CODEOWNERS; the extra root file is ambiguity.
â Correctâ
// Repository files
// .
// âââ .github/
// â âââ CODEOWNERS
// âââ README.md
// Repository files
// .
// âââ .gitlab/
// â âââ CODEOWNERS
// âââ README.md
// Repository files
// .
// âââ .bitbucket/
// â âââ CODEOWNERS
// âââ README.md
// Repository files
// .
// âââ CODEOWNERS
// âââ README.md
ESLint flat config exampleâ
import repoPlugin from "eslint-plugin-repo";
export default [
repoPlugin.configs.strict,
{
plugins: { "repo-compliance": repoPlugin },
rules: {
"repo-compliance/require-single-codeowners-file": "error",
},
},
];
When not to use itâ
Disable this rule if your repository intentionally maintains separate CODEOWNERS
files for different CI/CD platforms â for example, a monorepo mirrored to both
GitHub, GitLab, and Bitbucket Cloud with platform-specific ownership policies
stored in .github/CODEOWNERS, .gitlab/CODEOWNERS, and
.bitbucket/CODEOWNERS respectively. In that scenario, the files serve
different runtimes and coexistence is deliberate.
Disable it for all other multi-file cases only after documenting the intended precedence behavior for your team.
Rule catalog ID: R116