.cursorrules 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Coding Standards
  2. ## 1. Meaningful variable names, file names, folder names. Use abbreviations for words over ten characters. Abbreviations must be over three characters.
  3. - ✅ `update-btn` (refresh button), `device-list`, `user-profile-settings` (profile = abbreviation)
  4. - ❌ `btn` (too vague), `d1` (meaningless), `temp` (unclear), `us` (abbreviation too short)
  5. ## 2. Use hyphens (`-`) for multi-word names.
  6. ## 3. Comments: One Function, One Comment, English Only
  7. ## 4. Use functions to separate different logic. Avoid writing too much logic in a single function.
  8. ## 5. Never use try-catch. Let errors crash.
  9. ## 6. GUI components must split into three files:
  10. - `.jsx`: Layout only (no logic, no styles)
  11. - `.js`: Logic only (functions, state, business logic)
  12. - `.scss`: Styles only (no logic, no JSX)
  13. **Never write logic or inline styles in `.jsx` files.**
  14. ## 7. Use the least code to implement functionality.
  15. ## 8. Do not add any `console.log` statements in production code.
  16. ## 9. Do not create script files unnecessarily. If you can call PowerShell directly, use PowerShell instead of creating a separate script file.
  17. ## 10. If you need to create any new files, you must ask first.
  18. ## 11. Use `switch` statements instead of multiple `if-else` chains when checking the same variable against multiple values.
  19. ## 12. Prefer Early Return Over Else Blocks
  20. Prefer early return pattern:
  21. ```javascript
  22. if (condition) {
  23. ...
  24. return;
  25. }
  26. ```
  27. Instead of:
  28. ```javascript
  29. if (condition) {
  30. ...
  31. } else {
  32. ...
  33. }
  34. ```
  35. ## 13. No Existence Checks
  36. Do not add if statements to check if directories exist, files exist, or if parsing succeeded. Let errors crash.