Enforcing that the line endings should be LF

This commit is contained in:
Aaron Powell 2025-07-03 12:04:21 +10:00
parent 017312a06b
commit 01666497cc
9 changed files with 156 additions and 26 deletions

34
.editorconfig Normal file
View File

@ -0,0 +1,34 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# All files
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# Markdown files
[*.md]
trim_trailing_whitespace = false
max_line_length = off
# JSON files
[*.json]
indent_size = 2
# JavaScript files
[*.js]
indent_size = 2
# Shell scripts
[*.sh]
end_of_line = lf
# Windows scripts
[*.{cmd,bat}]
end_of_line = crlf

28
.gitattributes vendored Normal file
View File

@ -0,0 +1,28 @@
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf
# Explicitly declare text files to be normalized and converted to native line endings on checkout.
*.md text eol=lf
*.txt text eol=lf
*.js text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.html text eol=lf
*.css text eol=lf
*.scss text eol=lf
*.ts text eol=lf
*.sh text eol=lf
# Windows-specific files that should retain CRLF line endings
*.bat text eol=crlf
*.cmd text eol=crlf
# Binary files that should not be modified
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.zip binary
*.pdf binary

View File

@ -0,0 +1,26 @@
name: Check Line Endings
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
check-line-endings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for CRLF line endings in markdown files
run: |
! grep -l $'\r' $(find . -name "*.md")
if [ $? -eq 0 ]; then
echo "✅ No CRLF line endings found in markdown files"
exit 0
else
echo "❌ CRLF line endings found in markdown files"
echo "Files with CRLF line endings:"
grep -l $'\r' $(find . -name "*.md")
exit 1
fi

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
*.orig
[Cc]opilot-[Pp]rocessing.md

6
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"recommendations": [
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint"
]
}

15
.vscode/settings.json vendored
View File

@ -7,5 +7,20 @@
},
"chat.instructionsFilesLocations": {
"instructions": true
},
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"[markdown]": {
"files.trimTrailingWhitespace": false,
"editor.formatOnSave": true
},
"editor.rulers": [
100
],
"files.associations": {
"*.chatmode.md": "markdown",
"*.instructions.md": "markdown",
"*.prompt.md": "markdown"
}
}

View File

@ -79,6 +79,17 @@ Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, e
- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration
- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide
## 🛠️ Development Configuration
This repository uses various configuration files to ensure consistent code style and avoid issues with line endings:
- [`.editorconfig`](.editorconfig) - Defines coding styles across different editors and IDEs
- [`.gitattributes`](.gitattributes) - Ensures consistent line endings in text files
- [`.vscode/settings.json`](.vscode/settings.json) - VS Code-specific settings for this repository
- [`.vscode/extensions.json`](.vscode/extensions.json) - Recommended VS Code extensions
> 💡 **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.
## 📄 License

9
scripts/fix-line-endings.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# Script to fix line endings in all markdown files
echo "Normalizing line endings in markdown files..."
# Find all markdown files and convert CRLF to LF
find . -name "*.md" -type f -exec sed -i 's/\r$//' {} \;
echo "Done! All markdown files now have LF line endings."