Skip to content

Commit d1a988d

Browse files
committed
cursor rules
1 parent 71d43ee commit d1a988d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
description: Dependency injection for cleaner testing
3+
globs:
4+
---
5+
Make sure classes have their side-effecting functionality passed in as a parameter so that mocking these results is easier when testing.

.cursor/rules/params.mdc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
description: How to express parameters
3+
globs:
4+
---
5+
For constructors and functions with more than 2 parameters, instead of positional parameters, use a `…Params` object as the parameter so it's clearer what is happening at the function/constructor callsite.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
description: Using functional over imperative style
3+
globs:
4+
---
5+
Strongly prefer using functional style over imperative. That includes but is not limited to:
6+
7+
1. Prefer Immutability: instead of modifying state, create new structures with changes
8+
2. Guarantee Function Purity:
9+
• Guideline: Analyze function bodies to ensure outputs depend solely on inputs; warn when external state is read or modified.
10+
3. Promote Modular, Composable Design:
11+
• Guideline: Encourage the decomposition of tasks into small, reusable functions and support refactoring into higher-order functions and function composition (e.g., using combinators like map, filter, and reduce).
12+
4. Support Declarative Constructs:
13+
• Guideline: Recommend replacing imperative loops with declarative data transformation constructs and pattern matching when available.
14+
5. Integrate Robust Error Handling:
15+
• Guideline: Suggest the use of algebraic data types (e.g., Option, Either, Result) and monadic error patterns to handle exceptional conditions explicitly.
16+
7. Leverage the Type System:
17+
• Guideline: Utilize static type checking and inference to enforce contracts; highlight type mismatches that might indicate unintended side effects.
18+
8. Encourage Concurrency-Ready Patterns:
19+
• Guideline: Identify stateless functions and immutable data as candidates for safe concurrent execution; recommend parallel processing libraries when appropriate.

0 commit comments

Comments
 (0)