enforce-lf
Installation
SKILL.md
Enforce LF Line Endings
在 pnpm + Prettier + simple-git-hooks 项目中一键部署四层跨平台 LF 行尾守卫,确保 Windows/macOS/Linux 协作时行尾始终为 LF。
四层守卫概览
| 层级 | 文件 | 作用 | 触发时机 |
|---|---|---|---|
| 1 | .gitattributes |
Git 层:checkout/commit 时强制 LF | git checkout / git add |
| 2 | .editorconfig |
编辑器层:新建/保存文件时使用 LF | 文件编辑 |
| 3 | .prettierrc.json |
格式化层:prettier --write 时转换为 LF |
手动或自动格式化 |
| 4 | package.json (lint-staged + simple-git-hooks) |
提交层:pre-commit 钩子自动格式化 | git commit |
适用范围
- 使用 pnpm 作为包管理器的项目
- 已有或即将使用 Prettier 的项目
- 已有或即将使用 simple-git-hooks 的项目
- 支持 monorepo(Turborepo / pnpm workspaces)和单体项目