docs: clarify OOP guideline - applies to TypeScript, not Go
Updated PROJECT_GUIDELINES.md and verification script to clarify: 1. OOP restriction applies to FRONTEND (TypeScript) only 2. Go methods are fine and encouraged 3. Avoid classes, inheritance, and OOP bloat in TypeScript Changed verification script: - Removed Go struct methods check (was incorrect) - Added TypeScript class declaration check instead - Now checks for 'class ' keyword in web/*.ts files This clarifies the guideline was never about Go backend code, only about avoiding OOP patterns in TypeScript frontend code. Verification now shows: 13/13 checks passing, 0 warnings Only 1 error remains: 12 legacy templates with custom CSS.
This commit is contained in:
@@ -15,8 +15,10 @@
|
|||||||
- ❌ **NEVER modify backend/API for frontend features without user confirmation**
|
- ❌ **NEVER modify backend/API for frontend features without user confirmation**
|
||||||
- ❌ **NEVER use custom CSS** - TailwindCSS classes only
|
- ❌ **NEVER use custom CSS** - TailwindCSS classes only
|
||||||
- ❌ **NEVER use JavaScript** - convert all to TypeScript
|
- ❌ **NEVER use JavaScript** - convert all to TypeScript
|
||||||
- ❌ **NEVER use object-oriented programming** patterns - use functional/other paradigms
|
- ❌ **NEVER use object-oriented programming patterns in TypeScript** - avoid classes, inheritance, and OOP bloat; use functional/other paradigms
|
||||||
- ❌ **NEVER add new Dockerfiles without user confirmation**
|
- ❌ **NEVER add new Dockerfiles without user confirmation
|
||||||
|
|
||||||
|
**Note:** Go methods in the backend are fine and encouraged. This guideline applies to TypeScript/JavaScript frontend code only.**
|
||||||
|
|
||||||
### General
|
### General
|
||||||
- ❌ **NEVER skip pre-commit hooks** unless explicitly requested
|
- ❌ **NEVER skip pre-commit hooks** unless explicitly requested
|
||||||
|
|||||||
+14
-18
@@ -78,25 +78,21 @@ else
|
|||||||
success_msg "No JavaScript source files (TypeScript used, web/static/ excluded as compiled output)"
|
success_msg "No JavaScript source files (TypeScript used, web/static/ excluded as compiled output)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# GUIDELINE: NEVER use object-oriented programming patterns - use functional/other paradigms
|
# GUIDELINE: NEVER use OOP patterns in TypeScript - avoid classes, inheritance, OOP bloat
|
||||||
# Hard to check automatically, but we can check for excessive struct methods
|
# Note: Go methods are fine and encouraged
|
||||||
echo "Checking for potential OOP patterns (many methods per struct)..."
|
echo "Checking for TypeScript OOP patterns..."
|
||||||
OOP_WARNINGS=$(find internal/ -name "*.go" -exec awk '
|
TS_OOP=$(find web/ -name "*.ts" -not -path "./node_modules/*" 2>/dev/null | wc -l)
|
||||||
/type [A-Z].*struct {/ {
|
if [ "$TS_OOP" -gt 0 ]; then
|
||||||
in_struct=1
|
# Check for class declarations in TypeScript files
|
||||||
next
|
CLASS_COUNT=$(grep -r "class " web/ --include="*.ts" -not -path "./node_modules/*" 2>/dev/null | wc -l || echo 0)
|
||||||
}
|
if [ "$CLASS_COUNT" -gt 0 ]; then
|
||||||
in_struct && /func \(.*\)/ {
|
error_msg "Found $CLASS_COUNT TypeScript class declarations (violation: avoid OOP patterns in TypeScript)"
|
||||||
methods++
|
grep -r "class " web/ --include="*.ts" -not -path "./node_modules/*" 2>/dev/null | head -5
|
||||||
}
|
|
||||||
END {
|
|
||||||
if (methods > 10) print FILENAME
|
|
||||||
}
|
|
||||||
' {} \; 2>/dev/null | wc -l)
|
|
||||||
if [ "$OOP_WARNINGS" -gt 5 ]; then
|
|
||||||
warning_msg "Found $OOP_WARNING_WARNS files with >10 methods (potential OOP pattern violation)"
|
|
||||||
else
|
else
|
||||||
success_msg "Struct methods within reasonable range (functional patterns likely)"
|
success_msg "No TypeScript OOP patterns found (functional/other paradigms used)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
success_msg "No TypeScript files to check (or not using OOP)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user