require-gitattributes-file
Require a .gitattributes file in the repository root.
Targeted pattern scopeâ
This rule checks the repository root for the presence of a .gitattributes file.
What this rule reportsâ
This rule reports when no .gitattributes file is found.
Why this rule existsâ
A .gitattributes file controls how Git handles line endings, merge strategies,
diffs, binary detection, and export content. Without it, contributors on different
operating systems may silently corrupt line endings in text files, binary files may
be diffed as text, and git archive outputs may include development-only files.
Establishing a .gitattributes file early avoids difficult cross-platform inconsistencies.
â Incorrectâ
.github/
src/
README.md
package.json
â Correctâ
.gitattributes â present at root
.github/
src/
README.md
package.json
ESLint flat config exampleâ
import repoPlugin from "eslint-plugin-repo";
export default [
repoPlugin.configs.recommended,
{
plugins: { "repo-compliance": repoPlugin },
rules: {
"repo-compliance/require-gitattributes-file": "warn",
},
},
];
When not to use itâ
Disable this rule if your repository intentionally delegates line-ending normalisation and binary handling entirely to host-level git configuration or tool defaults.
Rule catalog ID: R037