| description | Guidelines for writing JavaScript/TypeScript code that is simple, readable, and maintainable. Focus on structure, organization, naming conventions, and performance. |
|---|---|
| applyTo | **/*.{js,jsx,ts,tsx,svelte,vue,cjs,mjs} |
- Use JavaScript with ES2022 features and Node.js (22+) ESM modules
- Use Node.js built-in modules and avoid external dependencies where possible
- Ask the user if you require any additional dependencies before adding them
- Always use async/await for asynchronous code
- Keep the code simple, readable, and maintainable
- Use descriptive variable and function names
- Do not add comments unless absolutely necessary, the code should be self-explanatory
- Never use
null, always useundefinedfor optional values - Prefer functions over classes
- Use arrow functions for callbacks
- Use
constfor variables that are not reassigned, andletfor those that are - Use template literals for strings that require interpolation
- Use destructuring for objects and arrays where appropriate
- Use
for...ofloops for iterating over arrays andfor...inloops for iterating over objects - Use semicolons at the end of statements
- Prefer single quotes for strings
- Use function-based components
- Use arrow functions for callbacks
- Organize code by feature/module
- Write clear, concise JSDoc/TSDoc comments
- Use Vitest for testing
- Write tests for all new features and bug fixes
- Ensure tests cover edge cases and error handling
- NEVER change the original code to make it easier to test, instead, write tests that cover the original code as it is