From 2c35ff40a77293ecb9cfec18b9a49c9f9bd91fa1 Mon Sep 17 00:00:00 2001 From: Eugene Mikhantyev Date: Sat, 18 Apr 2026 15:20:20 +0100 Subject: [PATCH] chore: enforce LF line endings via gitattributes, editorconfig, pre-commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a three-layer defence against CRLF/LF drift: - `.gitattributes` normalizes all text files to LF on commit and checkout; Windows-native scripts (*.bat, *.cmd, *.ps1) explicitly keep CRLF. - `.editorconfig` instructs editors (VS Code, JetBrains, vim, etc.) to save with LF by default so the problem is prevented at the source. - `mixed-line-ending --fix=lf` hook in pre-commit catches anything that slips through and auto-fixes it before commit. No file contents are normalized in this commit — that follows in a separate `git add --renormalize .` commit for easier review. --- .editorconfig | 21 +++++++++++++++++ .gitattributes | 51 +++++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 ++ 3 files changed, 74 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c5a593f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.{ts,tsx,js,jsx,mjs,cjs,json,yml,yaml,md,html,css}] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[*.{bat,cmd,ps1}] +end_of_line = crlf + +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..76a3f1c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,51 @@ +# Normalize all text files to LF on commit and checkout. +# Prevents CRLF drift when contributors work on Windows with core.autocrlf=true. +* text=auto eol=lf + +# Python and shell — LF everywhere, shebangs require it on Unix. +*.py text eol=lf +*.sh text eol=lf + +# Web / config — LF. +*.ts text eol=lf +*.tsx text eol=lf +*.js text eol=lf +*.jsx text eol=lf +*.mjs text eol=lf +*.cjs text eol=lf +*.json text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.toml text eol=lf +*.md text eol=lf +*.html text eol=lf +*.css text eol=lf + +# KiCad project files are text (S-expressions / JSON) — LF. +*.kicad_sch text eol=lf +*.kicad_pcb text eol=lf +*.kicad_pro text eol=lf +*.kicad_sym text eol=lf +*.kicad_mod text eol=lf +*.kicad_dru text eol=lf +*.kicad_wks text eol=lf +*.net text eol=lf + +# Windows-native scripts — must stay CRLF. +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Binary assets — never touch. +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.pdf binary +*.zip binary +*.gz binary +*.woff binary +*.woff2 binary +*.ttf binary +*.otf binary diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e23b3d..5632418 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,8 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer + - id: mixed-line-ending + args: ["--fix=lf"] - id: check-yaml - id: check-json - id: check-added-large-files