Skip to content

Commit f2feb5b

Browse files
committed
internal: Move github rules to cursor rules
1 parent a51c04d commit f2feb5b

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

.cursorrules renamed to .cursor/rules/general-instructions.mdc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
alwaysApply: true
3+
---
4+
15
# Reactive Data Client
26

37
Yarn monorepo for normalized reactive state management.
@@ -50,7 +54,7 @@ Yarn monorepo for normalized reactive state management.
5054
- Internal/private APIs (prefixed with `_`, not exported, or marked `@internal`)
5155
- Implementation-only changes
5256

53-
Update docs **in the same commit/PR** as code changes. For writing guidelines, see `.cursor/rules/packages-documentation.mdc`.
57+
Update docs **in the same commit/PR** as code changes. For writing guidelines, see @.cursor/rules/packages-documentation.mdc
5458

5559
## Common Mistakes to Avoid
5660

.github/instructions/manager.instructions.md renamed to .cursor/rules/manager.mdc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
2-
applyTo: '**/*.ts'
2+
description: Guidelines for implementing @data-client/react Managers which handle global side effects
3+
globs:
4+
- '**/*.ts'
5+
alwaysApply: false
36
---
47
# Guide: Using `@data-client/react` Managers for global side effects
58

69
[Managers](https://dataclient.io/docs/api/Manager) are singletons that handle global side-effects. Kind of like useEffect() for the central data store.
710
They interface with the store using [Controller](https://dataclient.io/docs/api/Controller), and [redux middleware](https://redux.js.org/tutorials/fundamentals/part-4-store#middleware) is run in response to [actions](https://dataclient.io/docs/api/Actions).
811

9-
Use [Manager API docs](docs/core/api/Manager.md) to validate usage.
12+
Use @docs/core/api/Manager.md to validate usage.
1013

11-
Always use `actionTypes` when comparing action.type. Refer to [Action API docs](docs/core/api/Actions.md)
14+
Always use `actionTypes` when comparing action.type. Refer to @docs/core/api/Actions.md
1215
for list of actions and their payloads.
1316

1417
## Dispatching actions
@@ -131,4 +134,4 @@ ReactDOM.createRoot(document.body).render(
131134
<App />
132135
</DataProvider>,
133136
);
134-
```
137+
```

.cursor/rules/packages-documentation.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ alwaysApply: false
44
---
55
# Package Documentation Writing Guidelines
66

7-
This guide covers how to write and format documentation for public library interfaces. For information on **when** documentation updates are required, see `.cursorrules`.
7+
This guide covers how to write and format documentation for public library interfaces. For information on **when** documentation updates are required, see @.cursor/rules/general-usage.mdc
88

99
## Documentation Structure
1010

.github/instructions/react.instructions.md renamed to .cursor/rules/react.mdc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
2-
applyTo: '**/*.tsx'
2+
description: Usage patterns for @data-client/react hooks and components
3+
globs:
4+
- '**/*.tsx'
5+
alwaysApply: false
36
---
4-
57
## Rendering
68

79
```ts
@@ -18,7 +20,7 @@ const todo = useCache(TodoResource.get, { id: 5 });
1820
const todo = useQuery(Todo, { id: 5 });
1921
```
2022

21-
For API definitions (like TodoResource), refer to the [@data-client/rest guide](.github/instructions/rest.instructions.md).
23+
For API definitions (like TodoResource), see @.cursor/rules/rest.mdc
2224

2325
## Mutations
2426

@@ -107,7 +109,7 @@ const todosByUser = useQuery(groupTodoByUser);
107109
Custom [Managers](https://dataclient.io/docs/api/Manager) allow for global side effect handling.
108110
This is useful for webosckets, SSE, logging, etc.
109111

110-
For more detailed usage, refer to the [Manager Guide](.github/instructions/manager.instructions.md).
112+
For more detailed usage, see @.cursor/rules/manager.mdc
111113

112114
## Best Practices & Notes
113115

@@ -123,4 +125,4 @@ For more detailed usage, refer to the [Manager Guide](.github/instructions/manag
123125
- [useSuspense](https://dataclient.io/docs/api/useSuspense)
124126
- [Controller](https://dataclient.io/docs/api/Controller)
125127

126-
**ALWAYS follow these patterns and refer to the official docs for edge cases. Prioritize code generation that is idiomatic, type-safe, and leverages automatic normalization/caching via schema definitions.**
128+
**ALWAYS follow these patterns and refer to the official docs for edge cases. Prioritize code generation that is idiomatic, type-safe, and leverages automatic normalization/caching via schema definitions.**

.github/instructions/rest.instructions.md renamed to .cursor/rules/rest.mdc

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
2-
applyTo: '**/*.ts*'
2+
description: Modeling resources endpoints and schemas with @data-client/rest
3+
globs:
4+
- '**/*.ts'
5+
- '**/*.tsx'
6+
alwaysApply: false
37
---
48
# Guide: Using `@data-client/rest` for Resource Modeling
59

@@ -34,6 +38,19 @@ to represent the data expected.
3438
### Programmatic
3539

3640
- [new schema.Query(Queryable)](https://dataclient.io/rest/api/Query) - memoized programmatic selectors
41+
```ts
42+
const queryRemainingTodos = new schema.Query(
43+
TodoResource.getList.schema,
44+
entries => entries.filter(todo => !todo.completed).length,
45+
);
46+
```
47+
48+
```ts
49+
const groupTodoByUser = new schema.Query(
50+
TodoResource.getList.schema,
51+
todos => Object.groupBy(todos, todo => todo.userId),
52+
);
53+
```
3754

3855
---
3956

@@ -121,23 +138,7 @@ const deleteTodo = id => ctrl.fetch(TodoResource.delete, { id });
121138
const getNextPage = (page) => ctrl.fetch(TodoResource.getList.getPage, { userId: 1, page })
122139
```
123140

124-
#### Programmatic queries
125-
126-
```ts
127-
const queryRemainingTodos = new schema.Query(
128-
TodoResource.getList.schema,
129-
entries => entries.filter(todo => !todo.completed).length,
130-
);
131-
```
132-
133-
```ts
134-
const groupTodoByUser = new schema.Query(
135-
TodoResource.getList.schema,
136-
todos => Object.groupBy(todos, todo => todo.userId),
137-
);
138-
```
139-
140-
For more detailed usage, refer to the [@data-client/react guide](.github/instructions/react.instructions.md).
141+
For more detailed usage, see @.cursor/rules/react.mdc
141142

142143
---
143144

@@ -241,4 +242,4 @@ export const IssueResource = resource({
241242
- [Schema Guide](https://dataclient.io/rest/api/schema#schema-overview)
242243
- [Relational Data Guide](https://dataclient.io/rest/guides/relational-data)
243244

244-
**ALWAYS follow these patterns and refer to the official docs for edge cases. Prioritize code generation that is idiomatic, type-safe, and leverages automatic normalization/caching via schema definitions.**
245+
**ALWAYS follow these patterns and refer to the official docs for edge cases. Prioritize code generation that is idiomatic, type-safe, and leverages automatic normalization/caching via schema definitions.**

0 commit comments

Comments
 (0)