These coding style guidelines are designed to ensure consistency, readability, and maintainability in the [Project Name] codebase. Contributors are encouraged to follow these guidelines when writing code for the project.
- Consistency: Maintain consistency in naming, formatting, and code organization throughout the project.
- Readability: Prioritize code readability. Use meaningful names for variables, functions, and components.
- Comments: Use comments to explain complex logic, especially when it's not immediately obvious.
- Modularity: Keep functions and components focused on a single responsibility.
- Linting: Utilize linting tools to automatically enforce coding style rules.
- Component Names: Use PascalCase for component names (e.g.,
MyComponent
). - File Naming: Use the same name for the component file as the component itself.
- Props: Destructure props in the function signature unless there's a good reason not to.
- JSX Formatting: Format JSX with proper indentation and line breaks for readability.
- Conditional Rendering: Use ternary operators or short-circuiting for simple conditions in JSX.
- Component Organization: Group related components in folders when they have multiple files (e.g.,
MyComponent/MyComponent.tsx
).
- Type Annotations: Utilize TypeScript's static typing features extensively.
- Interfaces and Types: Use interfaces for objects and types for other situations like unions, intersections, and aliases.
- Type Inference: Rely on TypeScript's type inference as much as possible.
- Enums: Use enums for fixed sets of related constants.
- Generics: Use generics to write reusable and type-safe functions and components.
- Database Models: Use descriptive names for Prisma models and fields.
- Queries and Mutations: Name queries and mutations clearly based on their actions and the entities involved.
- Type Safety: Utilize Prisma's generated type-safe queries to prevent runtime errors.
- Authentication Hooks: Use the provided hooks by NextAuth.js for authentication in your components.
- Session Management: Clearly handle session and user data using NextAuth.js APIs.
- Custom Providers: If using custom authentication providers, follow NextAuth.js guidelines for implementation.
We use linting tools to enforce our coding style guidelines. Run npm run lint
to check for any violations.
These guidelines are meant to evolve over time. Feel free to suggest improvements by opening an issue or submitting a pull request.