Skip to content

Commit a0c7b2b

Browse files
committed
Add trailing whitespace checking and fixing infrastructure
- Add check-trailing-whitespace Makefile target to detect trailing whitespaces in source files - Add fix-trailing-whitespace Makefile target to automatically remove trailing whitespaces - Create CI workflow to check for trailing whitespaces on all pushes - Update CLAUDE.md with trailing whitespace removal requirements - Wrap Makefile target commands to 80 characters for better readability All file types covered: .rs, .toml, .md, .yaml, .yml, .json, .ts, .tsx, .js, .jsx with appropriate directory exclusions for build artifacts and dependencies.
1 parent 2b06fba commit a0c7b2b

File tree

3 files changed

+83
-8
lines changed

3 files changed

+83
-8
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Trailing Whitespace Check
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
check-whitespace:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Check for trailing whitespaces
17+
run: make check-trailing-whitespace

CLAUDE.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Each component directory contains a `summary.md` file documenting:
130130
OpenMina includes a comprehensive documentation website built with Docusaurus:
131131

132132
### Quick Access
133+
133134
```bash
134135
# Start local documentation server
135136
make docs-serve
@@ -144,16 +145,22 @@ make help | grep docs
144145
The website is available at http://localhost:3000 when running locally.
145146

146147
### Structure
147-
- **Node Runners** (`website/docs/node-runners/`) - Installation and operation guides
148-
- **Developers** (`website/docs/developers/`) - Architecture and contribution guides
149-
- **Researchers** (`website/docs/researchers/`) - Protocol and cryptography documentation
148+
149+
- **Node Runners** (`website/docs/node-runners/`) - Installation and operation
150+
guides
151+
- **Developers** (`website/docs/developers/`) - Architecture and contribution
152+
guides
153+
- **Researchers** (`website/docs/researchers/`) - Protocol and cryptography
154+
documentation
150155

151156
### Adding Documentation
157+
152158
1. Create markdown files in the appropriate `website/docs/` subdirectory
153159
2. Add frontmatter with title, description, and sidebar position
154160
3. Update `website/sidebars.ts` if needed for navigation
155161

156-
The website supports versioning and will be automatically deployed when commits are made to `develop` or when tags are created.
162+
The website supports versioning and will be automatically deployed when commits
163+
are made to `develop` or when tags are created.
157164

158165
## Additional Resources
159166

@@ -203,7 +210,16 @@ referencing Claude.
203210

204211
1. Make your code changes
205212
2. Run the appropriate formatting command based on file types modified
206-
3. Verify formatting with check commands if needed
207-
4. **Verify commit message does not include Claude as co-author**
208-
5. **Verify commit message contains no emojis and follows 80-character wrap**
209-
6. Proceed with testing or committing changes
213+
3. **ALWAYS run `make fix-trailing-whitespace` before committing or ending any task**
214+
4. Verify formatting with check commands if needed
215+
5. **Verify commit message does not include Claude as co-author**
216+
6. **Verify commit message contains no emojis and follows 80-character wrap**
217+
7. Proceed with testing or committing changes
218+
219+
### Critical Pre-Commit Requirements
220+
221+
- **MANDATORY**: Run `make fix-trailing-whitespace` before every commit
222+
- **MANDATORY**: Run `make check-trailing-whitespace` to verify no trailing
223+
whitespaces remain
224+
- This applies to ALL file modifications, regardless of file type
225+
- Trailing whitespaces are strictly prohibited in the codebase

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,48 @@ check-md: ## Check if markdown files are properly formatted
8989
npx prettier --check "**/*.md"
9090
@echo "Markdown format check completed."
9191

92+
.PHONY: fix-trailing-whitespace
93+
fix-trailing-whitespace: ## Remove trailing whitespaces from all files
94+
@echo "Removing trailing whitespaces from all files..."
95+
@find . -type f \( \
96+
-name "*.rs" -o -name "*.toml" -o -name "*.md" -o -name "*.yaml" \
97+
-o -name "*.yml" -o -name "*.json" -o -name "*.ts" -o -name "*.tsx" \
98+
-o -name "*.js" -o -name "*.jsx" -o -name "*.sh" \) \
99+
-not -path "./target/*" \
100+
-not -path "./node_modules/*" \
101+
-not -path "./website/node_modules/*" \
102+
-not -path "./website/build/*" \
103+
-not -path "./website/static/api-docs/*" \
104+
-not -path "./website/.docusaurus/*" \
105+
-not -path "./.git/*" \
106+
-exec sed -i 's/[[:space:]]*$$//' {} + && \
107+
echo "Trailing whitespaces removed."
108+
109+
.PHONY: check-trailing-whitespace
110+
check-trailing-whitespace: ## Check for trailing whitespaces in source files
111+
@echo "Checking for trailing whitespaces..."
112+
@files_with_trailing_ws=$$(find . -type f \( \
113+
-name "*.rs" -o -name "*.toml" -o -name "*.md" -o -name "*.yaml" \
114+
-o -name "*.yml" -o -name "*.json" -o -name "*.ts" -o -name "*.tsx" \
115+
-o -name "*.js" -o -name "*.jsx" -o -name "*.sh" \) \
116+
-not -path "./target/*" \
117+
-not -path "./node_modules/*" \
118+
-not -path "./website/node_modules/*" \
119+
-not -path "./website/build/*" \
120+
-not -path "./website/static/api-docs/*" \
121+
-not -path "./website/.docusaurus/*" \
122+
-not -path "./.git/*" \
123+
-exec grep -l '[[:space:]]$$' {} + 2>/dev/null || true); \
124+
if [ -n "$$files_with_trailing_ws" ]; then \
125+
echo "❌ Files with trailing whitespaces found:"; \
126+
echo "$$files_with_trailing_ws" | sed 's/^/ /'; \
127+
echo ""; \
128+
echo "Run 'make fix-trailing-whitespace' to fix automatically."; \
129+
exit 1; \
130+
else \
131+
echo "✅ No trailing whitespaces found."; \
132+
fi
133+
92134
.PHONY: clean
93135
clean: ## Clean build artifacts
94136
cargo clean

0 commit comments

Comments
 (0)