chore: write new Cursor rules for React and Redux

This commit is contained in:
nicomiguelino
2025-06-08 10:55:48 -07:00
parent 7c11389159
commit 58db5b1fcf
3 changed files with 42 additions and 7 deletions

View File

@@ -1,10 +1,16 @@
---
description:
globs:
description:
globs:
alwaysApply: true
---
- CoffeeScript is used for front-end code, which gets transpiled to JavaScript.
- See [anthias.coffee](mdc:static/js/anthias.coffee) and [settings.coffee](mdc:static/js/settings.coffee) for details.
- Backbone.js is used as the front-end framework.
- CoffeeScript and Backbone.js will be deprecated in favor of modern frameworks
that are more stable and still maintained.
- Anthias uses JavaScript and React for the front-end framework.
- We use Prettier for formatting and ESLint for linting. Check `README.md` for docs
on how to run them.
- Make sure that generated code conforms to the project's coding standards.
- Reorganize imports to follow the project's coding standards. Order imports
alphabetically and group imports by type. Imports must be declared in the
following order:
- Built-in imports
- Third-party imports
- Imports from other files in the project
- Separate import groups with blank lines.

15
.cursor/rules/react.mdc Normal file
View File

@@ -0,0 +1,15 @@
---
description:
globs:
alwaysApply: true
---
# React
- Make use of functional components instead of class-based components.
- Use `useState` for managing state instead of `this.state`.
- Use `useEffect` for managing side effects instead of `componentDidMount`,
`componentDidUpdate`, and `componentWillUnmount`.
- Do not explicitly import React from `react`, as it is already being taken care
of by the `new webpack.ProvidePlugin({ React: 'react' })` plugin in
`webpack.common.js`.
- Avoid props drilling by using Redux for state management.

14
.cursor/rules/redux.mdc Normal file
View File

@@ -0,0 +1,14 @@
---
description:
globs:
alwaysApply: true
---
# Redux
- Redux is used for state management.
- Use `createSlice` to create new slices.
- Use `createAsyncThunk` to create new async thunks.
- Resort to storing new states in the Redux in cases where you need to share
data between components that are not directly related.
- Asset-related states (e.g., asset creation, asset update, etc.) must be stored
in the Redux store.