|
| 1 | +# VS Code Extension Development Rules |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +This is a VS Code extension for better CSS stacking contexts visualization and analysis. The extension helps developers understand and debug CSS stacking contexts by providing visual indicators, diagnostics, and navigation tools. |
| 6 | + |
| 7 | +## Code Style & Standards |
| 8 | + |
| 9 | +### TypeScript |
| 10 | + |
| 11 | +- Use strict TypeScript configuration |
| 12 | +- Prefer explicit types over `any` |
| 13 | +- Use interfaces for object shapes |
| 14 | +- Use enums for constants |
| 15 | +- Use readonly properties where appropriate |
| 16 | +- Use optional chaining and nullish coalescing |
| 17 | +- Prefer const assertions for literal types |
| 18 | + |
| 19 | +### Naming Conventions |
| 20 | + |
| 21 | +- Use PascalCase for classes, interfaces, and types |
| 22 | +- Use camelCase for variables, functions, and methods |
| 23 | +- Use UPPER_SNAKE_CASE for constants |
| 24 | +- Use descriptive names that explain intent |
| 25 | +- Prefix private methods with underscore if needed |
| 26 | + |
| 27 | +### File Organization |
| 28 | + |
| 29 | +- Keep files focused on single responsibility |
| 30 | +- Use barrel exports (index.ts) for clean imports |
| 31 | +- Group related functionality in directories |
| 32 | +- Separate concerns: providers, commands, helpers, types |
| 33 | + |
| 34 | +### VS Code Extension Patterns |
| 35 | + |
| 36 | +- Use the VS Code extension API properly |
| 37 | +- Implement proper disposal patterns for resources |
| 38 | +- Use event-driven architecture where appropriate |
| 39 | +- Follow VS Code's command and provider patterns |
| 40 | +- Use proper error handling and logging |
| 41 | + |
| 42 | +## Architecture Guidelines |
| 43 | + |
| 44 | +### Providers |
| 45 | + |
| 46 | +- Each provider should have a single responsibility |
| 47 | +- Implement proper dispose methods |
| 48 | +- Use caching where appropriate for performance |
| 49 | +- Handle VS Code lifecycle events properly |
| 50 | + |
| 51 | +### Commands |
| 52 | + |
| 53 | +- Keep commands focused and simple |
| 54 | +- Use proper argument validation |
| 55 | +- Provide meaningful error messages |
| 56 | +- Follow VS Code command patterns |
| 57 | + |
| 58 | +### Helpers |
| 59 | + |
| 60 | +- Create pure functions where possible |
| 61 | +- Use proper error handling |
| 62 | +- Add JSDoc comments for complex functions |
| 63 | +- Keep helper functions small and focused |
| 64 | + |
| 65 | +## Testing |
| 66 | + |
| 67 | +- Write unit tests for all public functions |
| 68 | +- Test edge cases and error conditions |
| 69 | +- Use descriptive test names |
| 70 | +- Mock VS Code API calls in tests |
| 71 | +- Test both success and failure scenarios |
| 72 | + |
| 73 | +## Performance |
| 74 | + |
| 75 | +- Cache expensive operations |
| 76 | +- Use debouncing for user interactions |
| 77 | +- Minimize DOM queries and updates |
| 78 | +- Use efficient data structures |
| 79 | +- Profile performance-critical code |
| 80 | + |
| 81 | +## Error Handling |
| 82 | + |
| 83 | +- Use try-catch blocks appropriately |
| 84 | +- Log errors with context |
| 85 | +- Provide user-friendly error messages |
| 86 | +- Handle VS Code API errors gracefully |
| 87 | +- Use proper error types |
| 88 | + |
| 89 | +## Documentation |
| 90 | + |
| 91 | +- Add JSDoc comments for public APIs |
| 92 | +- Document complex algorithms |
| 93 | +- Keep README up to date |
| 94 | +- Document configuration options |
| 95 | +- Add inline comments for complex logic |
| 96 | + |
| 97 | +## CSS/SCSS Specific |
| 98 | + |
| 99 | +- Follow BEM naming conventions |
| 100 | +- Use CSS custom properties for theming |
| 101 | +- Ensure proper stacking context handling |
| 102 | +- Test in both light and dark themes |
| 103 | +- Use semantic class names |
| 104 | + |
| 105 | +## Git & Version Control |
| 106 | + |
| 107 | +- Write descriptive commit messages |
| 108 | +- Use conventional commits format |
| 109 | +- Keep commits focused and atomic |
| 110 | +- Update CHANGELOG.md for user-facing changes |
| 111 | +- Tag releases appropriately |
| 112 | + |
| 113 | +## Extension Development Best Practices |
| 114 | + |
| 115 | +- Follow VS Code extension guidelines |
| 116 | +- Use proper activation events |
| 117 | +- Implement proper contribution points |
| 118 | +- Handle workspace and file changes |
| 119 | +- Provide meaningful user feedback |
| 120 | +- Support both light and dark themes |
| 121 | +- Test across different VS Code versions |
| 122 | + |
| 123 | +## Code Quality |
| 124 | + |
| 125 | +- Use ESLint for code quality |
| 126 | +- Use Prettier for formatting |
| 127 | +- Fix all linting errors |
| 128 | +- Use meaningful variable names |
| 129 | +- Avoid code duplication |
| 130 | +- Keep functions small and focused |
| 131 | +- Use early returns to reduce nesting |
| 132 | + |
| 133 | +## Security |
| 134 | + |
| 135 | +- Validate all user inputs |
| 136 | +- Sanitize data before display |
| 137 | +- Use proper file path handling |
| 138 | +- Avoid eval() and similar functions |
| 139 | +- Follow VS Code security guidelines |
| 140 | + |
| 141 | +## Accessibility |
| 142 | + |
| 143 | +- Provide keyboard navigation |
| 144 | +- Use semantic HTML where applicable |
| 145 | +- Ensure proper color contrast |
| 146 | +- Add ARIA labels where needed |
| 147 | +- Test with screen readers |
| 148 | + |
| 149 | +## Internationalization |
| 150 | + |
| 151 | +- Use VS Code's localization system |
| 152 | +- Externalize user-facing strings |
| 153 | +- Support multiple languages |
| 154 | +- Use proper date/time formatting |
| 155 | +- Consider cultural differences |
| 156 | + |
| 157 | +## Performance Monitoring |
| 158 | + |
| 159 | +- Monitor extension activation time |
| 160 | +- Track memory usage |
| 161 | +- Profile expensive operations |
| 162 | +- Use VS Code's built-in profiling tools |
| 163 | +- Optimize based on real usage data |
| 164 | + |
| 165 | +- Use VS Code's built-in profiling tools |
| 166 | +- Optimize based on real usage data |
0 commit comments