@mallardbay/cursor-rules 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,10 +25,10 @@ Use theme values consistently across all components:
25
25
  - Use theme typography settings for text styles
26
26
  - Example: `theme.fontSizes.md` instead of `'16px'`
27
27
 
28
- ### Borders
28
+ ### Borders and border radius
29
29
 
30
30
  - Use theme border styles and radius values
31
- - Example: `theme.borders.sm` instead of `'1px solid'`
31
+ - Examples: `theme.borders.sm` instead of `'1px solid'`, `theme.radii.md` instead of using px values
32
32
 
33
33
  ## Component Structure
34
34
 
@@ -73,6 +73,12 @@ Ensure responsive and accessible design:
73
73
  - Optimize component rendering
74
74
  - Avoid unnecessary re-renders
75
75
  - Use React.memo and useMemo when appropriate
76
+ - Avoid defining functions inside components to prevent recreation on each render
77
+ - Move function definitions outside components or use useCallback for event handlers
78
+ - Use useCallback for functions passed as props to child components
79
+ - Use useMemo for expensive computations and complex data transformations
80
+ - Memoize filtered, sorted, or mapped arrays to avoid recalculation on every render
81
+ - Use useMemo for object/array creation that would otherwise be recreated on each render
76
82
 
77
83
  ## File Patterns
78
84
 
@@ -0,0 +1,147 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ # Storybook Performance Standards
6
+
7
+ ## Story Optimization
8
+
9
+ Optimize Storybook stories for better performance and developer experience:
10
+
11
+ ### Story Structure
12
+
13
+ - Use `StoryObj` type for better type safety
14
+ - Implement proper story parameters and controls
15
+ - Group related stories using `storiesOf` or CSF 3.0
16
+ - Use meaningful story names and descriptions
17
+ - Organize stories by component hierarchy (e.g., "Core/Button")
18
+
19
+ ### Story Organization
20
+
21
+ - Group stories by component or feature
22
+ - Use consistent naming conventions for stories
23
+ - Implement proper story hierarchy with nested folders
24
+ - Separate interactive and documentation stories
25
+ - Use helper functions like `renderStorySections` for consistent layouts
26
+ - Create reusable story section builders for component variants
27
+
28
+ ## Rendering Optimization
29
+
30
+ Prevent unnecessary re-renders in stories:
31
+
32
+ - Avoid inline styles in story args
33
+ - Prevent inline object creation in story parameters
34
+ - Use proper key props in story lists
35
+ - Memoize complex story args and callbacks
36
+ - Use `fn()` from `@storybook/test` for mock functions
37
+ - Spread args properly to avoid TypeScript errors
38
+
39
+ ### Story Dependencies
40
+
41
+ - Prefer existing dependencies over new ones
42
+ - Review [package.json](mdc:package.json) before adding new packages
43
+ - Consider bundle size impact of new story dependencies
44
+ - Use tree-shaking friendly imports for story utilities
45
+ - Import storybook helpers from dedicated helper files
46
+
47
+ ## Component Variant Management
48
+
49
+ - Use helper functions like `getStoryComponentVariantsAndColorSchemes` for systematic variant testing
50
+ - Create structured sections for different component states
51
+ - Implement consistent labeling for component variants
52
+ - Use TypeScript to ensure proper component prop spreading
53
+
54
+ ## Performance Best Practices
55
+
56
+ - Use `play` functions for complex interactions
57
+ - Implement proper story loading states
58
+ - Optimize story assets and images
59
+ - Use Storybook's performance monitoring tools
60
+ - Implement proper story caching strategies
61
+ - Avoid inline component creation in render functions
62
+
63
+ ## Story Development
64
+
65
+ - Write stories that cover all component states
66
+ - Use controls for interactive testing
67
+ - Implement proper accessibility testing in stories
68
+ - Use Storybook's built-in performance profiling
69
+ - Create comprehensive variant coverage (primary, secondary, etc.)
70
+ - Use meaningful labels for each component variant
71
+ - Implement proper TypeScript typing for story args
72
+
73
+ ## File Patterns
74
+
75
+ These rules apply to all Storybook story files (`.stories.ts`, `.stories.tsx`, `.stories.js`, `.stories.jsx`) in the project.
76
+
77
+ # Storybook Performance Standards
78
+
79
+ ## Story Optimization
80
+
81
+ Optimize Storybook stories for better performance and developer experience:
82
+
83
+ ### Story Structure
84
+
85
+ - Use `StoryObj` type for better type safety
86
+ - Implement proper story parameters and controls
87
+ - Group related stories using `storiesOf` or CSF 3.0
88
+ - Use meaningful story names and descriptions
89
+ - Organize stories by component hierarchy (e.g., "Core/Button")
90
+
91
+ ### Story Organization
92
+
93
+ - Group stories by component or feature
94
+ - Use consistent naming conventions for stories
95
+ - Implement proper story hierarchy with nested folders
96
+ - Separate interactive and documentation stories
97
+ - Use helper functions like `renderStorySections` for consistent layouts
98
+ - Create reusable story section builders for component variants
99
+
100
+ ## Rendering Optimization
101
+
102
+ Prevent unnecessary re-renders in stories:
103
+
104
+ - Avoid inline styles in story args
105
+ - Prevent inline object creation in story parameters
106
+ - Use proper key props in story lists
107
+ - Memoize complex story args and callbacks
108
+ - Use `fn()` from `@storybook/test` for mock functions
109
+ - Spread args properly to avoid TypeScript errors
110
+
111
+ ### Story Dependencies
112
+
113
+ - Prefer existing dependencies over new ones
114
+ - Review [package.json](mdc:package.json) before adding new packages
115
+ - Consider bundle size impact of new story dependencies
116
+ - Use tree-shaking friendly imports for story utilities
117
+ - Import storybook helpers from dedicated helper files
118
+
119
+ ## Component Variant Management
120
+
121
+ - Use helper functions like `getStoryComponentVariantsAndColorSchemes` for systematic variant testing
122
+ - Create structured sections for different component states
123
+ - Implement consistent labeling for component variants
124
+ - Use TypeScript to ensure proper component prop spreading
125
+
126
+ ## Performance Best Practices
127
+
128
+ - Use `play` functions for complex interactions
129
+ - Implement proper story loading states
130
+ - Optimize story assets and images
131
+ - Use Storybook's performance monitoring tools
132
+ - Implement proper story caching strategies
133
+ - Avoid inline component creation in render functions
134
+
135
+ ## Story Development
136
+
137
+ - Write stories that cover all component states
138
+ - Use controls for interactive testing
139
+ - Implement proper accessibility testing in stories
140
+ - Use Storybook's built-in performance profiling
141
+ - Create comprehensive variant coverage (primary, secondary, etc.)
142
+ - Use meaningful labels for each component variant
143
+ - Implement proper TypeScript typing for story args
144
+
145
+ ## File Patterns
146
+
147
+ These rules apply to all Storybook story files (`.stories.ts`, `.stories.tsx`, `.stories.js`, `.stories.jsx`) in the project.
@@ -1,48 +1,53 @@
1
1
  ---
2
2
  description: Defines structure, naming, reuse, and dependency guidelines to ensure clean, maintainable, and consistent TypeScript code across the project—favoring pragmatism, proven libraries, and shared conventions.
3
- globs:
4
3
  alwaysApply: false
5
4
  ---
5
+
6
6
  # Code Quality Standards
7
7
 
8
8
  ## Code Structure
9
- - Maximum file length: 200 lines
10
- - Maximum function length: 50 lines
11
- - Naming conventions:
12
- - Components: PascalCase
13
- - Functions: camelCase
14
- - Constants: UPPER_SNAKE_CASE
15
- - Types: PascalCase
16
- - Types should be defined at the bottom of files
17
- - PropTypes should be defined before component definitions
18
- - Prefer using alias for importing components. Only use relative for tests or when there's a direct sibling
9
+
10
+ - Maximum file length: 200 lines
11
+ - Maximum function length: 50 lines
12
+ - Naming conventions:
13
+ - Components: PascalCase
14
+ - Functions: camelCase
15
+ - Constants: UPPER_SNAKE_CASE
16
+ - Types: PascalCase
17
+ - Types should be defined at the bottom of files
18
+ - PropTypes should be defined before component definitions
19
+ - Prefer using alias for importing components. Only use relative for tests or when there's a direct sibling
19
20
 
20
21
  ## Code Reuse
21
- - Use shared libraries to avoid duplication
22
- - Primary libraries to use:
23
- - [@mallardbay/lib-react-components](mdc:package.json)
24
- - [@mallardbay/lib-shared-helpers](mdc:package.json)
22
+
23
+ - Use shared libraries to avoid duplication
24
+ - Primary libraries to use:
25
+ - [@mallardbay/lib-react-components](mdc:package.json)
26
+ - [@mallardbay/lib-shared-helpers](mdc:package.json)
25
27
 
26
28
  ## Third party libraries
27
- - Favor battle-tested libraries over custom solutions. If a well-maintained, widely-used library solves the problem cleanly, use it. Reinventing functionality that’s already solid, reliable, and well-documented usually leads to more bugs, more maintenance, and wasted time.
28
- - Prioritize stability and ecosystem fit. Pick libraries that are actively maintained, have strong adoption, and fit well within our existing tech stack. Avoid fringe or unmaintained packages unless there’s a strong reason.
29
- - Suggest existing libraries during code review. If you spot hand-rolled code that could be replaced with a proven library, flag it. Examples:
30
- - Use zod or yup instead of custom input validation
31
- - Use date-fns instead of writing date math from scratch
32
- - Use radash for utility-heavy logic if readability or testability improves
33
- - Use react-hook-form for complex form state handling
34
- - Be pragmatic. Sometimes a simple custom solution is faster and easier than pulling in a heavy dependency—but always weigh short-term gains against long-term cost.
35
- - Make reuse easy. If we do build something custom, design it to be clean, reusable, and well-documented. That way, we’re not creating another wheel, but investing in something worth maintaining.
29
+
30
+ - Favor battle-tested libraries over custom solutions. If a well-maintained, widely-used library solves the problem cleanly, use it. Reinventing functionality that’s already solid, reliable, and well-documented usually leads to more bugs, more maintenance, and wasted time.
31
+ - Prioritize stability and ecosystem fit. Pick libraries that are actively maintained, have strong adoption, and fit well within our existing tech stack. Avoid fringe or unmaintained packages unless there’s a strong reason.
32
+ - Suggest existing libraries during code review. If you spot hand-rolled code that could be replaced with a proven library, flag it. Examples:
33
+ - Use zod or yup instead of custom input validation
34
+ - Use date-fns instead of writing date math from scratch
35
+ - Use radash for utility-heavy logic if readability or testability improves
36
+ - Use react-hook-form for complex form state handling
37
+ - Be pragmatic. Sometimes a simple custom solution is faster and easier than pulling in a heavy dependency—but always weigh short-term gains against long-term cost.
38
+ - Make reuse easy. If we do build something custom, design it to be clean, reusable, and well-documented. That way, we’re not creating another wheel, but investing in something worth maintaining.
36
39
 
37
40
  ## String Constants
38
- - Use constants instead of string literals for:
39
- - Copy text (UI content)
40
- - Test IDs
41
- - Error messages
42
- - URLs
43
- - Source constants from:
44
- - @mallardbay/lib-shared-helpers
45
- - Local constants files
41
+
42
+ - Use constants instead of string literals for:
43
+ - Copy text (UI content). Most projects have a `copy-constants` file
44
+ - Test IDs. Most projects have `TEST_IDS` defined
45
+ - Error messages
46
+ - URLs
47
+ - Source constants from:
48
+ - @mallardbay/lib-shared-helpers
49
+ - Local constants files
46
50
 
47
51
  ## Cursor Rules
48
- - Suggest cursor rules as needed
52
+
53
+ - Suggest cursor rules as needed
@@ -1,40 +1,46 @@
1
1
  ---
2
2
  description: Outlines expectations for pull request size, test coverage, documentation, and review process—promoting focused, well-tested, and maintainable contributions that align with team standards and improve review efficiency.
3
- globs:
4
3
  alwaysApply: false
5
4
  ---
5
+
6
6
  # Code Review Standards
7
7
 
8
8
  ## Pull Request Guidelines
9
9
 
10
10
  ### Size Requirements
11
- - Maximum PR size: 400 lines
12
- - Split large changes into smaller, focused PRs
13
- - Keep changes atomic and focused
14
- - Consider impact on review process
11
+
12
+ - Maximum PR size: 400 lines
13
+ - Split large changes into smaller, focused PRs
14
+ - Keep changes atomic and focused
15
+ - Consider impact on review process
15
16
 
16
17
  ## Testing Requirements
18
+
17
19
  Ensure comprehensive test coverage:
18
20
 
19
21
  ### Test Coverage
20
- - All new code must include tests
21
- - Follow testing standards in [testing.mdc](mdc:.cursor/rules/testing.mdc)
22
- - Include unit tests for new functionality
23
- - Avoid making a ton of changes to existing tests while refactoring
22
+
23
+ - All new code must include tests
24
+ - Follow testing standards in [testing.mdc](mdc:.cursor/rules/testing.mdc)
25
+ - Include unit tests for new functionality
26
+ - Avoid making a ton of changes to existing tests while refactoring
24
27
 
25
28
  ### Code Documentation
26
- - Document complex logic with comments
27
- - Explain non-obvious implementation details
28
- - Document features added and important caveats in README
29
+
30
+ - Document complex logic with comments
31
+ - Explain non-obvious implementation details
32
+ - Document features added and important caveats in README
29
33
 
30
34
  ### Review Process
31
- - Review for code quality
32
- - Check for test coverage
33
- - Verify documentation
34
- - Ensure adherence to project standards
35
+
36
+ - Review for code quality
37
+ - Check for test coverage
38
+ - Verify documentation
39
+ - Ensure adherence to project standards
35
40
 
36
41
  ## Best Practices
37
- - Keep PRs focused and manageable
38
- - Include clear PR descriptions
39
- - Reference related issues/tickets
40
- - Respond to review comments promptly
42
+
43
+ - Keep PRs focused and manageable
44
+ - Include clear PR descriptions
45
+ - Reference related issues/tickets
46
+ - Respond to review comments promptly
@@ -1,41 +1,48 @@
1
1
  ---
2
2
  description: Defines consistent patterns for API and form error handling—focusing on clear user feedback, robust validation, and reliable logging to improve user experience, developer debugging, and overall app resilience.
3
- globs:
4
3
  alwaysApply: false
5
4
  ---
5
+
6
6
  # Error Handling Standards
7
7
 
8
8
  ## API Error Handling
9
+
9
10
  Implement comprehensive API error handling
10
11
 
11
12
  ### Error Types
12
- - Handle network errors
13
- - Handle server errors
14
- - Handle validation errors
15
- - Handle Apollo-specific errors
13
+
14
+ - Handle network errors
15
+ - Handle server errors
16
+ - Handle validation errors
17
+ - Handle Apollo-specific errors
16
18
 
17
19
  ### Error Presentation
18
- - Show error toasts for user feedback
19
- - Use original error messages when appropriate
20
- - Provide clear, actionable error messages
21
- - Log errors for debugging
20
+
21
+ - Show error toasts for user feedback
22
+ - Use original error messages when appropriate
23
+ - Provide clear, actionable error messages
24
+ - Log errors for debugging
22
25
 
23
26
  ## Form Validation
27
+
24
28
  Implement robust form validation
25
- - Validate all user inputs
26
- - Show validation errors clearly
27
- - Handle form submission errors
28
- - Use [@hookform/resolvers](mdc:package.json) for validation
29
+
30
+ - Validate all user inputs
31
+ - Show validation errors clearly
32
+ - Handle form submission errors
33
+ - Use [@hookform/resolvers](mdc:package.json) for validation
29
34
 
30
35
  ### Error Display
31
- - Show validation errors inline
32
- - Provide clear error messages
33
- - Highlight invalid fields
34
- - Prevent form submission with invalid data
36
+
37
+ - Show validation errors inline
38
+ - Provide clear error messages
39
+ - Highlight invalid fields
40
+ - Prevent form submission with invalid data
35
41
 
36
42
  ## Best Practices
37
- - Use try-catch blocks appropriately
38
- - Implement proper error boundaries
39
- - Log errors for debugging
40
- - Provide user-friendly error messages
41
- - Handle edge cases gracefully
43
+
44
+ - Use try-catch blocks appropriately
45
+ - Implement proper error boundaries
46
+ - Log errors for debugging
47
+ - Provide user-friendly error messages
48
+ - Handle edge cases gracefully
@@ -0,0 +1,163 @@
1
+ ---
2
+ description: Core development principles and best practices that always apply—optimized for AI agents to produce clean, maintainable, reviewable code with low cognitive complexity, clear semantics, and incremental changes.
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # General Best Practices
7
+
8
+ These principles apply to all code changes and should guide every implementation decision.
9
+
10
+ ## Core Principles
11
+
12
+ ### DRY (Don't Repeat Yourself)
13
+ - Extract common logic into reusable functions, utilities, or shared modules
14
+ - Leverage existing patterns and utilities before creating new ones
15
+ - When duplicating code, ask: "Can this be abstracted?"
16
+ - Prefer composition and shared utilities over copy-paste solutions
17
+
18
+ ### Leverage Existing Patterns
19
+ - **Always** search the codebase for similar implementations before creating new code
20
+ - Follow established patterns, conventions, and architectural decisions
21
+ - Use existing utilities, helpers, and shared libraries
22
+ - Match the style and structure of related files
23
+ - When patterns exist, use them consistently—don't invent new approaches without justification
24
+
25
+ ### Incremental Changes
26
+ - **Minimize large changes in a single PR or commit**
27
+ - Break large features into smaller, testable increments
28
+ - Make changes that are easy to review and understand
29
+ - Prefer multiple small PRs over one massive change
30
+ - Each change should be independently testable and reviewable
31
+ - If a change touches many files, consider splitting it into logical phases
32
+
33
+ ### Semantic Clarity
34
+ - Use **semantic, self-documenting names** for functions, variables, and types
35
+ - Function names should clearly describe what they do (e.g., `calculateTotalPrice` not `calc`)
36
+ - Variable names should express intent (e.g., `userAccountBalance` not `bal`)
37
+ - Terminology should be consistent across the codebase
38
+ - Avoid abbreviations unless they're widely understood in the domain
39
+ - Names should make code readable without comments
40
+
41
+ ### Cognitive Complexity
42
+ - **Keep cognitive complexity low**—code should be easy to understand at a glance
43
+ - Prefer early returns and guard clauses over deep nesting
44
+ - Break complex logic into smaller, well-named functions
45
+ - Maximum nesting depth: 3 levels
46
+ - Use intermediate variables to clarify intent
47
+ - Extract complex conditionals into named boolean functions
48
+ - Avoid deeply nested ternaries—use if/else or extract to function
49
+
50
+ ### Separation of Concerns
51
+ - **Files**: Each file should have a single, clear responsibility
52
+ - **Functions**: Each function should do one thing well
53
+ - Separate business logic from presentation, data access, and side effects
54
+ - Keep UI components focused on rendering and user interaction
55
+ - Extract business logic into pure functions or services
56
+ - Avoid god objects or functions that do too much
57
+
58
+ ## Code Quality Standards
59
+
60
+ ### Avoid "AI Slop"
61
+ - **Write code that's easy for humans to review**
62
+ - Avoid generating large amounts of code without understanding context
63
+ - Don't create unnecessary abstractions or over-engineered solutions
64
+ - Remove unused code, imports, and dead branches
65
+ - Clean up commented-out code and debugging statements
66
+ - If an approach doesn't work, **clean up failed attempts** before trying another
67
+ - Keep only relevant, working code—remove experimental code that didn't pan out
68
+
69
+ ### Testing and Linting
70
+ - **Lint and test files related to your changes** before completing work
71
+ - Run linters on modified files and fix issues
72
+ - Run tests for affected modules, not the entire test suite unnecessarily
73
+ - For large changes: **use test sharding**—split tests across multiple runs
74
+ - **Do not run all tests in parallel** when dealing with many changes
75
+ - Tests should be **clear, fast, and minimize setup duplication**
76
+ - Use shared test utilities and fixtures to reduce boilerplate
77
+ - Each test should be independent and runnable in isolation
78
+
79
+ ### Code Organization
80
+ - Group related functionality together
81
+ - Keep related code close (cohesion)
82
+ - Minimize dependencies between modules (loose coupling)
83
+ - Use appropriate data structures for the problem
84
+ - Prefer composition over inheritance
85
+ - Make functions pure when possible (no side effects)
86
+ - Handle edge cases explicitly—don't rely on implicit behavior
87
+
88
+ ### Type Safety and Clarity
89
+ - Use TypeScript types effectively—avoid `any` unless necessary
90
+ - Make types explicit and meaningful
91
+ - Use const assertions and readonly where appropriate
92
+ - Prefer `const` over `let`, avoid `var`
93
+ - Use type guards and discriminated unions for type narrowing
94
+
95
+ ### Performance Considerations
96
+ - Consider performance implications, but **avoid premature optimization**
97
+ - Profile before optimizing—optimize bottlenecks, not everything
98
+ - Use appropriate algorithms and data structures
99
+ - Avoid unnecessary re-renders, re-computations, or API calls
100
+ - Cache expensive computations when appropriate
101
+
102
+ ## AI Agent Workflow
103
+
104
+ ### Before Making Changes
105
+ 1. **Create a plan** before making changes directly—outline the approach, identify affected files, and break down the work into steps
106
+ 2. **Read existing code** to understand patterns and context
107
+ 3. **Search the codebase** for similar implementations
108
+ 4. **Check git history** to understand why code exists as it does
109
+ 5. **Identify related files** that might be affected
110
+ 6. **Ask clarifying questions** if requirements are unclear
111
+
112
+ ### During Implementation
113
+ 1. Make **small, incremental changes**
114
+ 2. **Test as you go**—verify each change works before moving on
115
+ 3. **Lint frequently**—don't accumulate lint errors
116
+ 4. **Follow existing patterns**—don't reinvent the wheel
117
+ 5. **Use semantic names**—code should be self-documenting
118
+ 6. **Keep functions focused**—one responsibility per function
119
+ 7. **Extract common logic**—don't duplicate code
120
+
121
+ ### After Making Changes
122
+ 1. **Clean up failed attempts**—remove experimental code
123
+ 2. **Remove unused code**—imports, variables, functions
124
+ 3. **Run linters** on modified files
125
+ 4. **Run relevant tests**—not the entire suite unless necessary
126
+ 5. **Verify the change works** end-to-end
127
+ 6. **Check for side effects**—ensure changes don't break unrelated code
128
+
129
+ ### When Changes Are Large
130
+ 1. **Consider splitting** into multiple smaller PRs
131
+ 2. **Use test sharding**—run tests in batches, not all at once
132
+ 3. **Review incrementally**—make sure each part works before moving on
133
+ 4. **Document the approach**—explain why changes are structured this way
134
+ 5. **Check impact** on related systems and files
135
+
136
+ ## Anti-Patterns to Avoid
137
+
138
+ - ❌ Copy-pasting code instead of extracting to a function
139
+ - ❌ Creating new patterns when existing ones work
140
+ - ❌ Making massive changes in one go
141
+ - ❌ Using vague names like `data`, `temp`, `value`, `thing`
142
+ - ❌ Deeply nested conditionals and loops
143
+ - ❌ Functions that do multiple unrelated things
144
+ - ❌ Leaving commented-out code or debugging statements
145
+ - ❌ Skipping tests or linting "to save time"
146
+ - ❌ Running entire test suite for small changes
147
+ - ❌ Leaving experimental code after failed attempts
148
+ - ❌ Premature optimization without profiling
149
+ - ❌ Using `any` types to avoid type errors
150
+ - ❌ Magic numbers or strings without constants
151
+
152
+ ## Remember
153
+
154
+ **Code is read far more often than it's written.** Write code that:
155
+ - Is easy to understand
156
+ - Is easy to review
157
+ - Is easy to test
158
+ - Is easy to modify
159
+ - Follows established patterns
160
+ - Has clear semantics
161
+ - Minimizes cognitive load
162
+
163
+ When in doubt, prefer clarity and simplicity over cleverness.
@@ -1,38 +1,45 @@
1
1
  ---
2
2
  description: Defines best practices for optimizing React components, rendering efficiency, and dependency management—focusing on minimizing re-renders, reducing bundle size, and enabling smooth user experiences through memoization, lazy loading, and performance-aware development.
3
- globs:
4
3
  alwaysApply: false
5
4
  ---
5
+
6
6
  # Performance Standards
7
7
 
8
8
  ## React Optimization
9
+
9
10
  Optimize React components for better performance:
10
11
 
11
12
  ### Component Optimization
12
- - Use `React.memo` for pure components
13
- - Implement `useCallback` for function props
14
- - Use `useMemo` for expensive computations
15
- - Avoid inline function definitions in render
13
+
14
+ - Use `React.memo` for pure components
15
+ - Implement `useCallback` for function props
16
+ - Use `useMemo` for expensive computations
17
+ - Avoid inline function definitions in render
16
18
 
17
19
  ## Rendering Optimization
20
+
18
21
  Prevent unnecessary re-renders:
19
- - Avoid inline styles in components
20
- - Prevent inline object creation in render
21
- - Use proper key props in lists
22
- - Memoize complex objects and callbacks
22
+
23
+ - Avoid inline styles in components
24
+ - Prevent inline object creation in render
25
+ - Use proper key props in lists
26
+ - Memoize complex objects and callbacks
23
27
 
24
28
  ### Dependencies
25
- - Prefer existing dependencies over new ones
26
- - Review [package.json](mdc:package.json) before adding new packages
27
- - Consider bundle size impact of new dependencies
28
- - Use tree-shaking friendly imports
29
+
30
+ - Prefer existing dependencies over new ones
31
+ - Review [package.json](mdc:package.json) before adding new packages
32
+ - Consider bundle size impact of new dependencies
33
+ - Use tree-shaking friendly imports
29
34
 
30
35
  ## Best Practices
31
- - Implement proper code splitting
32
- - Use lazy loading for routes and large components
33
- - Optimize images and assets
34
- - Monitor performance metrics
35
- - Use React DevTools for performance profiling
36
+
37
+ - Implement proper code splitting
38
+ - Use lazy loading for routes and large components
39
+ - Optimize images and assets
40
+ - Monitor performance metrics
41
+ - Use React DevTools for performance profiling
36
42
 
37
43
  ## File Patterns
44
+
38
45
  These rules apply to all TypeScript and TSX files in the project.
@@ -32,7 +32,8 @@ Avoid e2e tests for UI. Favor unit tests.
32
32
 
33
33
  - Happy path testing
34
34
  - Error case handling
35
- - Edge case coverage
35
+ - Edge case coverage within reason. Optimize for branching logic, and avoid creating nearly identical tests
36
+ - Aim for simplicity
36
37
  - All tests must pass before completion
37
38
 
38
39
  ### Test Quality