|
@@ -1,27 +1,19 @@
|
|
|
-# Project Coding Standards
|
|
|
|
|
|
|
+# Coding Standards
|
|
|
|
|
|
|
|
-Follow these coding standards strictly for all code in this project.
|
|
|
|
|
-
|
|
|
|
|
-## 1. Variable Naming
|
|
|
|
|
-
|
|
|
|
|
-Meaningful variable names, file names, folder names. Use abbreviations for words over ten characters. Abbreviations must be over three characters.
|
|
|
|
|
|
|
+## 1. Meaningful variable names, file names, folder names. Use abbreviations for words over ten characters. Abbreviations must be over three characters.
|
|
|
|
|
|
|
|
- ✅ `update-btn` (refresh button), `device-list`, `user-profile-settings` (profile = abbreviation)
|
|
- ✅ `update-btn` (refresh button), `device-list`, `user-profile-settings` (profile = abbreviation)
|
|
|
- ❌ `btn` (too vague), `d1` (meaningless), `temp` (unclear), `us` (abbreviation too short)
|
|
- ❌ `btn` (too vague), `d1` (meaningless), `temp` (unclear), `us` (abbreviation too short)
|
|
|
|
|
|
|
|
-## 2. Word Separation: Kebab-Case
|
|
|
|
|
-
|
|
|
|
|
-Use hyphens (`-`) for multi-word names.
|
|
|
|
|
-
|
|
|
|
|
-## 3. Comments: One Block, One Comment, English Only
|
|
|
|
|
|
|
+## 2. Use hyphens (`-`) for multi-word names.
|
|
|
|
|
|
|
|
-## 4. No Try-Catch
|
|
|
|
|
|
|
+## 3. Comments: One Function, One Comment, English Only
|
|
|
|
|
|
|
|
-Never use try-catch. Let errors crash.
|
|
|
|
|
|
|
+## 4. Use functions to separate different logic. Avoid writing too much logic in a single function.
|
|
|
|
|
|
|
|
-## 5. GUI File Structure: Separate JSX, JS, SCSS
|
|
|
|
|
|
|
+## 5. Never use try-catch. Let errors crash.
|
|
|
|
|
|
|
|
-GUI components must split into three files:
|
|
|
|
|
|
|
+## 6. GUI components must split into three files:
|
|
|
|
|
|
|
|
- `.jsx`: Layout only (no logic, no styles)
|
|
- `.jsx`: Layout only (no logic, no styles)
|
|
|
- `.js`: Logic only (functions, state, business logic)
|
|
- `.js`: Logic only (functions, state, business logic)
|
|
@@ -29,22 +21,35 @@ GUI components must split into three files:
|
|
|
|
|
|
|
|
**Never write logic or inline styles in `.jsx` files.**
|
|
**Never write logic or inline styles in `.jsx` files.**
|
|
|
|
|
|
|
|
-## 6. Code Simplicity: Minimal Code
|
|
|
|
|
|
|
+## 7. Use the least code to implement functionality.
|
|
|
|
|
|
|
|
-Use the least code to implement functionality.
|
|
|
|
|
|
|
+## 8. Do not add any `console.log` statements in production code.
|
|
|
|
|
|
|
|
-## 7. No Console.log
|
|
|
|
|
|
|
+## 9. Do not create script files unnecessarily. If you can call PowerShell directly, use PowerShell instead of creating a separate script file.
|
|
|
|
|
|
|
|
-Do not add any `console.log` statements in production code.
|
|
|
|
|
|
|
+## 10. If you need to create any new files, you must ask first.
|
|
|
|
|
|
|
|
-## 8. Avoid Creating Script Files
|
|
|
|
|
|
|
+## 11. Use `switch` statements instead of multiple `if-else` chains when checking the same variable against multiple values.
|
|
|
|
|
|
|
|
-Do not create script files unnecessarily. If you can call PowerShell directly, use PowerShell instead of creating a separate script file.
|
|
|
|
|
|
|
+## 12. Prefer Early Return Over Else Blocks
|
|
|
|
|
|
|
|
-## 9. Ask Before Creating New Files
|
|
|
|
|
|
|
+Prefer early return pattern:
|
|
|
|
|
+```javascript
|
|
|
|
|
+if (condition) {
|
|
|
|
|
+ ...
|
|
|
|
|
+ return;
|
|
|
|
|
+}
|
|
|
|
|
+```
|
|
|
|
|
|
|
|
-If you need to create any new files, you must ask first.
|
|
|
|
|
|
|
+Instead of:
|
|
|
|
|
+```javascript
|
|
|
|
|
+if (condition) {
|
|
|
|
|
+ ...
|
|
|
|
|
+} else {
|
|
|
|
|
+ ...
|
|
|
|
|
+}
|
|
|
|
|
+```
|
|
|
|
|
|
|
|
-## 10. Prefer Switch Statements Over If-Else Chains
|
|
|
|
|
|
|
+## 13. No Existence Checks
|
|
|
|
|
|
|
|
-Use `switch` statements instead of multiple `if-else` chains when checking the same variable against multiple values.
|
|
|
|
|
|
|
+Do not add if statements to check if directories exist, files exist, or if parsing succeeded. Let errors crash.
|