CODING_STANDARDS.md 1.6 KB

Coding Standards

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)
  • btn (too vague), d1 (meaningless), temp (unclear), us (abbreviation too short)

2. Use hyphens (-) for multi-word names.

3. Comments: One Function, One Comment, English Only

4. Use functions to separate different logic. Avoid writing too much logic in a single function.

5. Never use try-catch. Let errors crash.

6. GUI components must split into three files:

  • .jsx: Layout only (no logic, no styles)
  • .js: Logic only (functions, state, business logic)
  • .scss: Styles only (no logic, no JSX)

Never write logic or inline styles in .jsx files.

7. Use the least code to implement functionality.

8. Do not add any console.log statements in production code.

9. Do not create script files unnecessarily. If you can call PowerShell directly, use PowerShell instead of creating a separate script file.

10. If you need to create any new files, you must ask first.

11. Use switch statements instead of multiple if-else chains when checking the same variable against multiple values.

12. Prefer Early Return Over Else Blocks

Prefer early return pattern:

if (condition) { 
    ...
    return;
}

Instead of:

if (condition) {
    ...
} else {
    ...
}

13. No Existence Checks

Do not add if statements to check if directories exist, files exist, or if parsing succeeded. Let errors crash.