Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions client/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Agents

## TypeScript Best Practices

### Code Style

- Avoid using Typescript escape hatches like `as`, `!`, and `any` type assertions
- Leverage new TypeScript features such as the `satisfies` keyword, optional chaining, nullish coalescing, and template literal types
- Use explicit type annotations for function parameters and return types
- Prefer `const` and `let` over `var`
- Use meaningful variable and function names in camelCase

### Type Safety

- Avoid `any` type; if absolutely necessary, use `unknown` with type guards instead
- Use strict mode: `"strict": true` in tsconfig.json
- Enable `noImplicitAny` in tsconfig.json
- Use discriminated unions for complex types
- Define interfaces for object shapes

### Functions

- Use arrow functions for callbacks
- Specify explicit return types
- Keep functions focused and small
- Use rest parameters instead of `arguments`

### Error Handling

- Use try-catch blocks appropriately
- Define custom error classes extending `Error`
- Always handle promise rejections with `.catch()` or try-catch in async functions

### Imports/Exports

- Use ES6 module syntax
- Group related imports together
- Avoid circular dependencies

### Performance

- Avoid unnecessary re-renders in React components
- Use memoization for expensive computations
47 changes: 25 additions & 22 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
import js from "@eslint/js";
// @ts-check
import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
import globals from "globals";
import react from "eslint-plugin-react";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";

export default [
{ ignores: ["dist"] },
export default defineConfig([
eslint.configs.recommended,
tseslint.configs.strictTypeChecked,
// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3878
reactPlugin.configs.flat.recommended,
// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3878
reactPlugin.configs.flat["jsx-runtime"],
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
{
files: ["**/*.{js,jsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: { jsx: true },
sourceType: "module",
projectService: true,
},
},
settings: { react: { version: "18.3" } },
plugins: {
react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
{
name: "react",
files: ["**/*.{ts,tsx}"],
ignores: ["dist"],
languageOptions: {
globals: globals.browser,
},
settings: { react: { version: "detect" } },
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs["jsx-runtime"].rules,
...reactHooks.configs.recommended.rules,
"react/jsx-no-target-blank": "off",
"react/prop-types": "off",
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/restrict-template-expressions": ["warn", { allowNumber: true }],
},
},
];
]);
4 changes: 2 additions & 2 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand All @@ -7,6 +7,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
Loading