This file contains essential information for agentic coding assistants working on the csv-plot codebase. Follow these guidelines to maintain code quality and consistency.
csv-plot is a React TypeScript application for uploading and visualizing CSV data using various chart types. Built with Vite, it uses Radix UI components, Tailwind CSS for styling, and Nivo charts for data visualization.
npm run dev- Start development server with Vitenpm run preview- Preview production build locally
npm run build- Type-check and build for production (tsc && vite build)npm run type-check- Run TypeScript compiler in check mode (tsc --pretty --noEmit)npm run lint- Run ESLint on all filesnpm run lint:fix- Run ESLint with auto-fixnpm run format- Format all files with Prettiernpm run format:check- Check if files are formatted correctly
Note: This project currently has no test framework configured. When adding tests in the future:
- No test runner is currently set up
- Consider adding Vitest (recommended for Vite projects) or Jest
- Test files should be colocated with components (e.g.,
Component.test.tsx) - Run single test:
npm run test -- Component.test.tsx(once test framework is added)
- TypeScript: Strict mode enabled with comprehensive type checking
- React: Version 19 with new JSX transform (no need for React imports in JSX files)
- Module System: ES modules with
"type": "module"in package.json
src/
├── components/ # Reusable UI components
│ ├── atoms/ # Basic UI elements (Select, Slider, etc.)
│ └── molecules/ # Complex components (charts, etc.)
├── pages/ # Route components
├── context/ # React context providers
├── utils/ # Utility functions
├── @types/ # TypeScript type definitions
└── main.tsx # Application entry point
Naming Conventions:
- Components: PascalCase (
BarChart.tsx,Select.tsx) - Utilities: camelCase (
classNames.ts,arrayToKeyValuePairs.ts) - Types/Interfaces: PascalCase with descriptive names (
TraceType,TraceContextType) - Props: PascalCase interface named
PropsorComponentNameProps - Constants: SCREAMING_SNAKE_CASE
- Functions: camelCase
Import Order:
- React imports:
import * as React from "react" - External libraries (alphabetical)
- Internal imports (alphabetical, with path aliases)
Path Aliases:
@/*→src/(configured in tsconfig.json and vite.config.ts)@ui/*→src/ui/(placeholder for future UI library)
Examples:
import * as React from "react"
import { ResponsiveBar } from "@nivo/bar"
import { Label } from "@radix-ui/react-label"
import { classNames } from "@/utils/classNames"
import Select from "@/components/atoms/Select"Strict Type Checking:
- All TypeScript strict options enabled
- Avoid
anytypes; use proper type definitions - Interface over type aliases for object shapes
- Use union types for variant props
Type Definition Patterns:
// Interface for component props
interface Props {
data: any[] // Avoid any when possible
keys: string[]
indexBy: string
margin?: { top: number; bottom: number; left: number; right: number }
}
// Type for context
export interface TraceContextType {
traces: TraceType[]
setValues: (values: TraceType[]) => void
}
// Generic types for reusable components
interface SelectOption<T = string> {
label: string
value: T
disabled?: boolean
}Component Structure:
- Functional components with TypeScript
- Props destructuring in component signature
- Default props using default parameters
- Export default for components
Hooks Usage:
- React hooks follow standard patterns
- Custom hooks for shared logic
- Context providers for global state
Example Component:
interface Props {
value: string
onValueChange: (value: string) => void
placeholder: string
label?: string
}
const Select: React.FC<Props> = ({
value,
onValueChange,
label,
placeholder,
}) => (
// Component implementation
)
export default SelectTailwind CSS:
- Utility-first approach with Tailwind CSS v4
- Custom color scheme using neutral colors
- Responsive design with mobile-first approach
- Consistent spacing using Tailwind's spacing scale
Class Name Patterns:
- Use
classNameprop for styling - Conditional classes with
classNamesutility - Avoid inline styles; use Tailwind classes
- Follow BEM-like naming for custom classes
Accessibility:
- Full JSX a11y ESLint rules enabled
- ARIA labels and roles where appropriate
- Semantic HTML elements
- Keyboard navigation support
Current Patterns:
- TypeScript strict mode catches most type errors
- ESLint promise rules enforce proper async handling
- No centralized error handling system yet
Best Practices:
- Use try/catch for async operations
- Provide user-friendly error messages
- Log errors appropriately (console.error for development)
- Handle loading states for async operations
ESLint Configuration:
- React recommended rules
- TypeScript recommended rules
- JSX accessibility (jsx-a11y)
- Promise handling rules
- Better Tailwind CSS rules
- Prettier integration
Prettier Configuration:
{
"endOfLine": "auto",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"plugins": ["prettier-plugin-tailwindcss"]
}EditorConfig:
- UTF-8 encoding
- 2-space indentation
- LF line endings
- Final newline required
Pre-commit Hooks:
- Husky with lint-staged
- Runs ESLint on staged
.{js,jsx,ts,tsx}files - Prevents commits with linting errors
Branch Strategy:
- Main branch:
master - Feature branches for development
- Pull requests required
Commit Messages:
- Follow conventional commit format when possible
- Clear, descriptive messages
- Reference issues/tickets when applicable
Required Tools:
- Node.js 24.12.0 (managed by Volta)
- npm or bun (bun preferred for faster installs)
- VS Code with recommended extensions
VS Code Extensions:
- TypeScript and JavaScript Language Features
- ESLint
- Prettier
- Tailwind CSS IntelliSense
Environment Setup:
- Install dependencies:
bun install - Start development:
bun run dev - Run quality checks:
bun run lint && bun run type-check
Bundle Optimization:
- Vite for fast development and optimized builds
- Tree shaking enabled
- Code splitting for routes (when implemented)
React Performance:
- Use React.memo for expensive components
- Optimize re-renders with proper dependency arrays
- Virtualize large lists (when needed)
- Lazy load heavy components
Code Security:
- No secrets in code (use environment variables)
- Sanitize user inputs (especially CSV parsing with papaparse)
- Follow React security best practices
- Regular dependency updates
Testing Framework: When adding tests, consider:
- Vitest for Vite integration
- React Testing Library for component testing
- Test coverage reporting
Code Organization:
- Consider adding a
src/uidirectory for shared UI components - Implement proper error boundaries
- Add loading states and skeletons
- Consider state management (Zustand/Redux) for complex state
Format code: npm run format
Check types: npm run type-check
Lint and fix: npm run lint:fix
Build project: npm run build
Import React: import * as React from "react"
Component props: interface Props { ... }
Path alias: import { ... } from "@/*"
Always run npm run lint && npm run type-check before committing changes.
/Users/nirnejak/Code/jscode/csv-plot/AGENTS.md