add CLAUDE.md
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
# property-match — Development Guidelines
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
- **Vite 8** + **React 19** + **TypeScript 6**
|
||||||
|
- **MUI v9** (`@mui/material`) — primary component library
|
||||||
|
- **Tailwind CSS v4** — utility classes via `@tailwindcss/vite` (no `tailwind.config.js`)
|
||||||
|
- **React Router v7** — import from `react-router`, not `react-router-dom`
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
Always reach for an existing MUI component before writing a custom one. Check the [MUI component list](https://mui.com/material-ui/all-components/) first. Only build a custom component when MUI has no equivalent or the required behavior diverges significantly from what MUI provides.
|
||||||
|
|
||||||
|
## Styling
|
||||||
|
|
||||||
|
Use Tailwind utility classes for all layout and styling. Do not write plain CSS rules or add styles to `.css` files. The only CSS file is `src/index.css`, which holds the Tailwind layer imports — do not add project styles there.
|
||||||
|
|
||||||
|
|
||||||
|
## Providers
|
||||||
|
|
||||||
|
All data access and data actions live in `src/provider/`.
|
||||||
|
|
||||||
|
### Naming
|
||||||
|
|
||||||
|
| Rule | Example |
|
||||||
|
|------|---------|
|
||||||
|
| Every provider file/class is suffixed `Provider` | `PropertyProvider`, `UserProvider` |
|
||||||
|
| Every provider backed by mock data is also prefixed `Mockup` | `MockupPropertyProvider`, `MockupUserProvider` |
|
||||||
|
|
||||||
|
### Interface pattern
|
||||||
|
|
||||||
|
Define a TypeScript interface for each provider so the mockup and the real implementation are interchangeable:
|
||||||
|
Every Interface should be prefixed with a capitalized I.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// src/provider/IPropertyProvider.ts
|
||||||
|
export interface PropertyProvider {
|
||||||
|
getAll(): Promise<Property[]>
|
||||||
|
getById(id: string): Promise<Property | null>
|
||||||
|
create(data: CreatePropertyInput): Promise<Property>
|
||||||
|
update(id: string, data: UpdatePropertyInput): Promise<Property>
|
||||||
|
remove(id: string): Promise<void>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Async methods
|
||||||
|
|
||||||
|
Every method in a provider must be `async` and return a `Promise`, even in the mockup. This ensures the real provider can be swapped in without changing any call sites.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// src/provider/MockupPropertyProvider.ts
|
||||||
|
import type { PropertyProvider } from './PropertyProvider'
|
||||||
|
|
||||||
|
const properties: Property[] = [ /* seed data */ ]
|
||||||
|
|
||||||
|
export const MockupPropertyProvider: PropertyProvider = {
|
||||||
|
async getAll() {
|
||||||
|
return [...properties]
|
||||||
|
},
|
||||||
|
async getById(id) {
|
||||||
|
return properties.find(p => p.id === id) ?? null
|
||||||
|
},
|
||||||
|
async create(data) {
|
||||||
|
const next: Property = { id: crypto.randomUUID(), ...data }
|
||||||
|
properties.push(next)
|
||||||
|
return next
|
||||||
|
},
|
||||||
|
async update(id, data) {
|
||||||
|
const idx = properties.findIndex(p => p.id === id)
|
||||||
|
properties[idx] = { ...properties[idx], ...data }
|
||||||
|
return properties[idx]
|
||||||
|
},
|
||||||
|
async remove(id) {
|
||||||
|
const idx = properties.findIndex(p => p.id === id)
|
||||||
|
properties.splice(idx, 1)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Swap to a real implementation by replacing `MockupPropertyProvider` with a provider that calls an API — no other code changes required.
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# React + TypeScript + Vite
|
||||||
|
|
||||||
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||||
|
|
||||||
|
Currently, two official plugins are available:
|
||||||
|
|
||||||
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||||
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||||
|
|
||||||
|
## React Compiler
|
||||||
|
|
||||||
|
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||||
|
|
||||||
|
## Expanding the ESLint configuration
|
||||||
|
|
||||||
|
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
extends: [
|
||||||
|
// Other configs...
|
||||||
|
|
||||||
|
// Remove tseslint.configs.recommended and replace with this
|
||||||
|
tseslint.configs.recommendedTypeChecked,
|
||||||
|
// Alternatively, use this for stricter rules
|
||||||
|
tseslint.configs.strictTypeChecked,
|
||||||
|
// Optionally, add this for stylistic rules
|
||||||
|
tseslint.configs.stylisticTypeChecked,
|
||||||
|
|
||||||
|
// Other configs...
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
// other options...
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// eslint.config.js
|
||||||
|
import reactX from 'eslint-plugin-react-x'
|
||||||
|
import reactDom from 'eslint-plugin-react-dom'
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(['dist']),
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
extends: [
|
||||||
|
// Other configs...
|
||||||
|
// Enable lint rules for React
|
||||||
|
reactX.configs['recommended-typescript'],
|
||||||
|
// Enable lint rules for React DOM
|
||||||
|
reactDom.configs.recommended,
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
// other options...
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
|
```
|
||||||
Generated
+3866
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user