@mallardbay/cursor-rules 1.0.5 → 1.0.7
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.
- package/.cursor/backend/rules/backend.mdc +89 -0
- package/.cursor/frontend/rules/ui.mdc +7 -0
- package/README.md +78 -0
- package/bin/setup-cursor.sh +31 -19
- package/package.json +1 -1
- package/.cursor/lib/rules/ui.mdc +0 -63
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Mallard Bay Backend Development Rules
|
|
7
|
+
|
|
8
|
+
## Project Structure
|
|
9
|
+
|
|
10
|
+
- `src/` - Main source code directory
|
|
11
|
+
- `gql/` - GraphQL types, models, and resolvers
|
|
12
|
+
- `helpers/` - Utility functions (e.g., algolia.helpers.ts, entity-algolia.helpers.ts)
|
|
13
|
+
- `config/` - Configuration files and environment variables
|
|
14
|
+
- `database/` - Database related code (Firestore, Algolia)
|
|
15
|
+
- `firebase/` - Firebase functions and triggers
|
|
16
|
+
- `services/` - Business logic services
|
|
17
|
+
- `middleware/` - Express middleware
|
|
18
|
+
|
|
19
|
+
## Environment Setup
|
|
20
|
+
|
|
21
|
+
- Use dotenv-vault for environment management
|
|
22
|
+
- Never commit .env files to git
|
|
23
|
+
- Use different .env files for different environments (dev, test, prod)
|
|
24
|
+
|
|
25
|
+
## Firebase Development
|
|
26
|
+
|
|
27
|
+
- Use Firestore emulator for local development
|
|
28
|
+
- Start emulator: `gcloud emulators firestore start --host-port=127.0.0.1:8080`
|
|
29
|
+
- Use Firebase Functions for serverless operations
|
|
30
|
+
- Keep Firebase functions in `src/firebase/functions/`
|
|
31
|
+
- Use proper error handling in Firebase functions, use `captureException` helper for it
|
|
32
|
+
- Follow Firebase security rules best practices
|
|
33
|
+
|
|
34
|
+
## Algolia Integration
|
|
35
|
+
|
|
36
|
+
- Configure Algolia indices using `bin/db/setup-algolia.ts`
|
|
37
|
+
- Follow Algolia index settings in `src/database/algolia/*-index-settings.ts`
|
|
38
|
+
- Use proper searchable attributes and faceting
|
|
39
|
+
- Keep Algolia indexing logic in `src/helpers/algolia.helpers.ts`
|
|
40
|
+
- Follow Algolia query character limits (ALGOLIA_MAX_QUERY_CHARACTER = 512)
|
|
41
|
+
- Use proper error handling for Algolia operations
|
|
42
|
+
|
|
43
|
+
## Testing
|
|
44
|
+
|
|
45
|
+
- Use Jest as the testing framework
|
|
46
|
+
- Place tests in `__tests__` directories
|
|
47
|
+
- Mock Algolia, and other network requests in tests
|
|
48
|
+
- Use `tests/setupTests.ts` for global test setup
|
|
49
|
+
- Use `tests/teardownTests.ts` for cleanup
|
|
50
|
+
- Use Jest coverage reporting in the CI but not locally
|
|
51
|
+
|
|
52
|
+
## Code Style
|
|
53
|
+
|
|
54
|
+
- Use TypeScript for all new code
|
|
55
|
+
- Follow ESLint rules from `@mallardbay/eslint-config-mallardbay`
|
|
56
|
+
- Follow existing codebase patterns
|
|
57
|
+
- Rely heavily on constants
|
|
58
|
+
- Copy should be in copy constants
|
|
59
|
+
|
|
60
|
+
## GraphQL
|
|
61
|
+
|
|
62
|
+
- Define gql types, resolvers and mutations in `[ENTITY].schema.ts` files
|
|
63
|
+
|
|
64
|
+
## Error Handling
|
|
65
|
+
|
|
66
|
+
- Use proper error types
|
|
67
|
+
- Log errors appropriately
|
|
68
|
+
- Handle edge cases
|
|
69
|
+
- Provide meaningful error messages
|
|
70
|
+
- Use try-catch blocks where appropriate
|
|
71
|
+
- Use Sentry for error tracking, use `captureException` helper for it
|
|
72
|
+
|
|
73
|
+
## Performance
|
|
74
|
+
|
|
75
|
+
- Optimize Firestore queries
|
|
76
|
+
- Use proper indexing (see `firebase/firestore.indexes.json`)
|
|
77
|
+
- Cache when appropriate
|
|
78
|
+
- Monitor performance
|
|
79
|
+
- Setup new queries with pagination
|
|
80
|
+
- Follow Algolia best practices for search
|
|
81
|
+
|
|
82
|
+
## Security
|
|
83
|
+
|
|
84
|
+
- Validate all input
|
|
85
|
+
- Sanitize user data
|
|
86
|
+
- Use proper authentication
|
|
87
|
+
- Follow security best practices
|
|
88
|
+
- Keep dependencies secure
|
|
89
|
+
- Use environment variables for sensitive data
|
|
@@ -61,3 +61,10 @@ Ensure responsive and accessible design:
|
|
|
61
61
|
|
|
62
62
|
## File Patterns
|
|
63
63
|
These rules apply to all TypeScript and TSX files in the project.
|
|
64
|
+
|
|
65
|
+
## Components
|
|
66
|
+
- Keep components small and focused on a single responsibility
|
|
67
|
+
- Use functional components with hooks instead of class components
|
|
68
|
+
- Prefer `export default function ImpersonationBox() {` over `function ImpersonationBox(): React.ReactElement | null {` when defining components
|
|
69
|
+
|
|
70
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Cursor Rules
|
|
2
|
+
|
|
3
|
+
A tool for managing Cursor IDE rules across different environment types with shared base configurations.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This project provides a structured way to manage Cursor IDE rules for different development environments while maintaining a shared base configuration. It supports two main environment types:
|
|
8
|
+
|
|
9
|
+
- `frontend`: Basic frontend development rules
|
|
10
|
+
- `frontend-lib`: Extended rules for frontend library development, inheriting from frontend rules
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @mallardbay/cursor-rules
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
To set up Cursor rules for your project, run:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @mallardbay/cursor-rules <env-type>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Where `<env-type>` can be either:
|
|
27
|
+
|
|
28
|
+
- `frontend`
|
|
29
|
+
- `frontend-lib`
|
|
30
|
+
|
|
31
|
+
### Example
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# For frontend development
|
|
35
|
+
npx @mallardbay/cursor-rules frontend
|
|
36
|
+
|
|
37
|
+
# For frontend library development
|
|
38
|
+
npx @mallardbay/cursor-rules frontend-lib
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Project Structure
|
|
42
|
+
|
|
43
|
+
The rules are organized in the following directory structure:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
.cursor/
|
|
47
|
+
├── shared/
|
|
48
|
+
│ └── rules/ # Shared base rules
|
|
49
|
+
├── frontend/
|
|
50
|
+
│ └── rules/ # Frontend-specific rules
|
|
51
|
+
└── frontend-lib/
|
|
52
|
+
└── rules/ # Frontend library-specific rules
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Rule Inheritance
|
|
56
|
+
|
|
57
|
+
The rules follow an inheritance pattern:
|
|
58
|
+
|
|
59
|
+
- All environments include the shared base rules
|
|
60
|
+
- `frontend-lib` inherits rules from both `frontend` and `frontend-lib` directories
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
### Adding New Rules
|
|
65
|
+
|
|
66
|
+
1. Create `.mdc` files in the appropriate rules directory
|
|
67
|
+
2. Rules will be automatically copied to `.cursor/rules/` when running the setup script
|
|
68
|
+
|
|
69
|
+
### Directory Structure
|
|
70
|
+
|
|
71
|
+
- `bin/setup-cursor.sh`: Main setup script
|
|
72
|
+
- `.cursor/shared/rules/`: Shared base rules
|
|
73
|
+
- `.cursor/frontend/rules/`: Frontend-specific rules
|
|
74
|
+
- `.cursor/frontend-lib/rules/`: Frontend library-specific rules
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
[Add your license information here]
|
package/bin/setup-cursor.sh
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# setup-cursor.sh
|
|
3
|
-
# Robust Cursor rules installer using realpath
|
|
2
|
+
# setup-cursor.sh — frontend & frontend-lib layering with shared base
|
|
4
3
|
|
|
5
4
|
set -e
|
|
6
5
|
|
|
@@ -12,26 +11,39 @@ if [ -z "$ENV_TYPE" ]; then
|
|
|
12
11
|
exit 1
|
|
13
12
|
fi
|
|
14
13
|
|
|
15
|
-
# Resolve the true path of the script, following symlinks
|
|
16
14
|
SCRIPT_PATH="$(realpath "$0")"
|
|
17
15
|
SRC_DIR="$(cd "$(dirname "$SCRIPT_PATH")/.." && pwd)"
|
|
18
|
-
SHARED_DIR="$SRC_DIR/.cursor/shared/rules"
|
|
19
|
-
ENV_DIR="$SRC_DIR/.cursor/$ENV_TYPE/rules"
|
|
20
|
-
|
|
21
|
-
if [ ! -d "$SHARED_DIR" ]; then
|
|
22
|
-
echo "Shared rules directory not found: $SHARED_DIR"
|
|
23
|
-
exit 1
|
|
24
|
-
fi
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
fi
|
|
17
|
+
SHARED_DIR="$SRC_DIR/.cursor/shared/rules"
|
|
18
|
+
FRONTEND_DIR="$SRC_DIR/.cursor/frontend/rules"
|
|
19
|
+
FRONTEND_LIB_DIR="$SRC_DIR/.cursor/frontend-lib/rules"
|
|
30
20
|
|
|
31
21
|
mkdir -p .cursor/rules
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
copy_rules() {
|
|
24
|
+
local DIR="$1"
|
|
25
|
+
if [ -d "$DIR" ]; then
|
|
26
|
+
echo "Copying rules from: $DIR"
|
|
27
|
+
cp "$DIR"/*.mdc .cursor/rules/ 2>/dev/null || true
|
|
28
|
+
fi
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Always include shared rules
|
|
32
|
+
copy_rules "$SHARED_DIR"
|
|
33
|
+
|
|
34
|
+
# Inheritance handling
|
|
35
|
+
case "$ENV_TYPE" in
|
|
36
|
+
frontend)
|
|
37
|
+
copy_rules "$FRONTEND_DIR"
|
|
38
|
+
;;
|
|
39
|
+
frontend-lib)
|
|
40
|
+
copy_rules "$FRONTEND_DIR"
|
|
41
|
+
copy_rules "$FRONTEND_LIB_DIR"
|
|
42
|
+
;;
|
|
43
|
+
*)
|
|
44
|
+
echo "Unknown environment type: $ENV_TYPE"
|
|
45
|
+
exit 1
|
|
46
|
+
;;
|
|
47
|
+
esac
|
|
48
|
+
|
|
49
|
+
echo ".cursor/rules setup complete for '$ENV_TYPE'"
|
package/package.json
CHANGED
package/.cursor/lib/rules/ui.mdc
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Defines best practices for building consistent, maintainable, and responsive UI in Mallard Bay projects
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
# UI Development Standards
|
|
7
|
-
|
|
8
|
-
## Theme Usage
|
|
9
|
-
Use theme values consistently across all components:
|
|
10
|
-
|
|
11
|
-
### Colors
|
|
12
|
-
- Use theme colors instead of hardcoded values
|
|
13
|
-
- Example: `theme.colors.primary` instead of `'#000000'`
|
|
14
|
-
|
|
15
|
-
### Spacing
|
|
16
|
-
- Use theme spacing values for margins and padding
|
|
17
|
-
- Example: `theme.space[4]` instead of `'16px'`
|
|
18
|
-
|
|
19
|
-
### Typography
|
|
20
|
-
- Use theme typography settings for text styles
|
|
21
|
-
- Example: `theme.fontSizes.md` instead of `'16px'`
|
|
22
|
-
|
|
23
|
-
### Borders
|
|
24
|
-
- Use theme border styles and radius values
|
|
25
|
-
- Example: `theme.borders.sm` instead of `'1px solid'`
|
|
26
|
-
|
|
27
|
-
## Component Structure
|
|
28
|
-
Maintain clean and consistent component structure:
|
|
29
|
-
|
|
30
|
-
### Nesting
|
|
31
|
-
- Limit component nesting to maximum depth of 3
|
|
32
|
-
- Keep component hierarchy readable and maintainable
|
|
33
|
-
|
|
34
|
-
### Inline Styles
|
|
35
|
-
- Limit inline styles to maximum of 2 per component
|
|
36
|
-
- Prefer theme-based styling
|
|
37
|
-
|
|
38
|
-
### Component Library
|
|
39
|
-
- Use existing components in @mallardbay/lib-react-components, @mallardbay/lib-react-components is based off Crakra UI v2
|
|
40
|
-
- If no component available in @mallardbay/lib-react-components, create one using Crakra UI and place it under src/components/shared/todo-lib-react-components/ to me moved later
|
|
41
|
-
|
|
42
|
-
## Responsive Design
|
|
43
|
-
Ensure responsive and accessible design:
|
|
44
|
-
|
|
45
|
-
### Breakpoints
|
|
46
|
-
- Use theme breakpoints for responsive design
|
|
47
|
-
- Implement mobile-first approach
|
|
48
|
-
|
|
49
|
-
### Spacing
|
|
50
|
-
- Use responsive spacing values
|
|
51
|
-
- Adapt layouts for different screen sizes
|
|
52
|
-
|
|
53
|
-
### Animations
|
|
54
|
-
- Use theme transition values for animations
|
|
55
|
-
- Keep animations smooth and performant
|
|
56
|
-
|
|
57
|
-
### Rendering
|
|
58
|
-
- Optimize component rendering
|
|
59
|
-
- Avoid unnecessary re-renders
|
|
60
|
-
- Use React.memo and useMemo when appropriate
|
|
61
|
-
|
|
62
|
-
## File Patterns
|
|
63
|
-
These rules apply to all TypeScript and TSX files in the project.
|