-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Sourcery-ai and Coderabbitai configuration #322
Comments
Coderabbitai configuration can be done at their app dashboard, so as sourcery-ai dashboard (admin access only). @coderabbitai I need to create a path instructions for you to follow up on next PRs revisions. Provide an initial instruction that follows code standards that we have been following for all paths. @sourcery-ai plan this update by first giving an initial prompt for all paths. |
Tip For best results, initiate chat on the files or code changes. @AndlerRL Based on the detailed analysis of your repository structure, I notice this is a monorepo setup using Turborepo with multiple apps and packages. Let me refine the path-based instructions to better match your specific setup: review_instructions:
- paths: ["apps/masterbots.ai/**/*.{ts,tsx}"]
instructions: |
# Next.js Frontend Standards
- Follow React best practices and hooks guidelines
- Implement proper client/server component separation
- Use proper data fetching patterns (Server Components, SWR, or React Query)
- Implement proper error boundaries
- Follow the shadcn/ui component patterns (based on components.json presence)
- Ensure responsive design implementation
- Use proper TypeScript types for props and state
- Keep components focused and reusable
- paths: ["apps/hasura/**/*.{yaml,yml,sql}"]
instructions: |
# Hasura Backend Standards
- Follow proper table relationship definitions
- Implement appropriate permissions
- Use proper naming conventions for tables and columns
- Ensure proper indexing for performance
- Follow consistent metadata structure
- Implement proper row-level security
- paths: ["packages/mb-lib/**/*.{ts,tsx}"]
instructions: |
# Shared Library Standards
- Keep utilities pure and side-effect free
- Export proper TypeScript types
- Document public APIs with JSDoc
- Implement proper error handling
- Keep functions small and focused
- Use proper dependency injection patterns
- paths: ["packages/mb-types/**/*.{ts,d.ts}"]
instructions: |
# Type Definitions Standards
- Use precise and specific types
- Avoid 'any' type usage
- Document complex type definitions
- Keep interfaces focused
- Use proper type exports
- Follow naming conventions for types, interfaces, and enums
- paths: ["packages/mb-genql/**/*.{ts,tsx}"]
instructions: |
# GraphQL Generated Code Standards
- Don't modify generated files directly
- Ensure proper typing with the schema
- Use proper query/mutation hooks
- Implement proper error handling for GraphQL operations
- paths: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"]
instructions: |
# Testing Standards
- Follow AAA pattern (Arrange-Act-Assert)
- Use proper mocking strategies
- Test both success and error cases
- Use meaningful test descriptions
- Implement proper cleanup in tests
- Use proper test utilities and helpers
- paths: ["**/hooks/**/*.{ts,tsx}"]
instructions: |
# React Hooks Standards
- Follow hooks naming convention (use'use' prefix)
- Implement proper cleanup in useEffect
- Follow hooks rules (no conditions, loops)
- Keep hooks focused and reusable
- Proper error and loading state handling
- paths: ["**/api/**/*.{ts,tsx}"]
instructions: |
# API Route Standards
- Implement proper request validation
- Use appropriate HTTP status codes
- Implement proper error handling
- Add proper request logging
- Follow RESTful principles
- Implement proper rate limiting
- Use proper TypeScript types for request/response
Would you like me to:
1. Add more specific instructions for any particular package or app?
2. Include additional standards for the Hasura setup?
3. Add specific instructions for environment configuration files?
4. Add instructions for handling animations (noticed JSON animation files in the codebase)?
Also, I notice you're using Biome (biome.json present). Would you like me to add specific instructions about code formatting and linting that align with your Biome configuration?
^-^
|
(。◕‿◕。)
|
/||\
/\
<details>
<summary>🔗 Analysis chain</summary>
Let me gather information about the codebase structure and existing code standards first.
Let me analyze the results and provide a comprehensive path-based instruction configuration for CodeRabbit.
@AndlerRL Based on the analysis of the codebase, here's a recommended path-based instruction configuration for CodeRabbit that aligns with your code standards:
```yaml
review_instructions:
- paths: ["**/*.{ts,js}"]
instructions: |
# General Code Standards
- Ensure consistent use of TypeScript with strict type checking
- Follow a functional programming approach where possible
- Use meaningful variable and function names that describe their purpose
- Keep functions focused and single-responsibility
- Implement proper error handling with custom error types
- Add JSDoc comments for public APIs and complex functions
# Testing Standards
- Ensure new features have corresponding test files
- Test files should follow the pattern: `*.test.ts` or `*.spec.ts`
- Include unit tests for utility functions
- Add integration tests for API endpoints
- Test both success and error scenarios
# File Organization
- Keep related functionality in the same directory
- Use feature-based folder structure
- Separate business logic from API routes
- Place interfaces and types in dedicated files
# Code Quality
- Maintain maximum line length of 100 characters
- Use early returns to reduce nesting
- Avoid duplicate code through proper abstraction
- Implement proper dependency injection
- Use constants for magic numbers and repeated strings
- paths: ["**/api/**/*.{ts,js}"]
instructions: |
# API Specific Standards
- Follow RESTful principles
- Implement proper request validation
- Use appropriate HTTP status codes
- Include rate limiting where necessary
- Add proper API documentation
- Implement consistent error response format
- Add request logging for debugging
- paths: ["**/tests/**/*.{ts,js}"]
instructions: |
# Test File Standards
- Use descriptive test names
- Follow AAA pattern (Arrange-Act-Assert)
- Mock external dependencies
- Clean up test data after execution
- Group related tests using describe blocks
- Add test coverage requirements
- paths: ["**/types/**/*.{ts,d.ts}"]
instructions: |
# Type Definition Standards
- Use precise and specific types
- Avoid using 'any' type
- Document complex type definitions
- Use union types over enums where appropriate
- Keep interfaces focused and single-purpose
- paths: ["**/utils/**/*.{ts,js}"]
instructions: |
# Utility Function Standards
- Keep utility functions pure
- Add comprehensive unit tests
- Document function parameters and return types
- Handle edge cases appropriately
- Make functions reusable across the application
You can add these instructions in your CodeRabbit configuration through the [app dashboard](https://app.coderabbit.ai/). These instructions will help maintain consistency across the codebase and ensure that all future PR reviews follow the established patterns and best practices.
Would you like me to:
1. Add more specific instructions for any particular path?
2. Include additional code quality checks?
3. Add instructions for other file types (like configuration files)?
Also, regarding the Sourcery.ai configuration, would you like me to provide a complementary configuration that works in sequence with these CodeRabbit instructions?
^-^
|
(。◕‿◕。)
|
/||\
/\
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Script: #!/bin/bash Check for existing configuration filesecho "=== Checking for existing configuration files ===" Look for common code standards patternsecho -e "\n=== Looking for common linting/formatting configurations ===" Check for TypeScript configurationecho -e "\n=== Looking for TypeScript configuration ===" Look for test files to understand testing patternsecho -e "\n=== Looking for test files patterns ===" Check for README files for any documented standardsecho -e "\n=== Looking for documentation files ==="
#!/bin/bash Read package.json for dependencies and scriptsecho "=== Reading package.json ===" Check for any existing test setup filesecho -e "\n=== Looking for test setup files ===" Look for common patterns in source filesecho -e "\n=== Checking source file patterns ==="
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:08:49.880Z
|
@coderabbitai amazing! Yes, I have a set of rules to follow code standards. We made it for full-stack development with javascript/typescript but I summarized it for you. Please refactor the previous given path instructions to add the new points to consider while reviewing: Masterbots Code StandardsJavaScript/TypeScript:
Components:
File Structure:
NextJS 14/15:
API Development:
Styling:
Testing & Quality:
|
Tip For best results, initiate chat on the files or code changes. Based on the repository structure and code analysis, I'll create path-based instructions for CodeRabbit that align with the existing code standards. Here's my final reply: @AndlerRL Here's a comprehensive set of path-based instructions for CodeRabbit that follows the code standards observed in the repository: path_instructions:
# Next.js App Directory Structure
"apps/masterbots.ai/app/**":
- "Ensure proper use of Next.js 14 App Router conventions"
- "Route handlers should be in route.ts files"
- "Layout components should be in layout.tsx files"
- "Page components should be in page.tsx files"
- "Loading states should be in loading.tsx files"
- "Error boundaries should be in error.tsx files"
- "Server components should be the default unless client interactivity is needed"
- "Use 'use client' directive only when necessary for client-side features"
# Components Organization
"apps/masterbots.ai/components/**":
- "Follow atomic design principles: atoms, molecules, organisms"
- "Components should be function components using arrow syntax"
- "Props should be explicitly typed using TypeScript interfaces"
- "Use composition over inheritance"
- "Implement proper error boundaries and loading states"
- "Keep components focused and single-responsibility"
- "Use shadcn/ui conventions for UI components"
# Shared Libraries and Types
"packages/**":
- "Maintain clear separation of concerns between packages"
- "Ensure proper TypeScript type definitions"
- "Export types and interfaces properly"
- "Follow consistent naming conventions"
- "Implement proper error handling"
- "Add comprehensive JSDoc documentation"
# API and Backend
"apps/hasura/**":
- "Follow REST/GraphQL best practices"
- "Implement proper error handling and status codes"
- "Ensure secure authentication and authorization"
- "Validate input data thoroughly"
- "Use proper database schema conventions"
- "Document API endpoints and their usage"
# Testing
"**/*.test.ts":
- "Write comprehensive unit tests"
- "Follow AAA pattern (Arrange, Act, Assert)"
- "Mock external dependencies appropriately"
- "Test error cases and edge scenarios"
- "Maintain test isolation"
# General Code Style
"**/*.{ts,tsx}":
- "Use TypeScript strict mode"
- "Follow Biome formatting rules"
- "Implement proper error handling with custom error classes"
- "Use meaningful variable and function names"
- "Keep functions small and focused"
- "Add proper comments for complex logic"
- "Use proper TypeScript types instead of 'any'"
- "Implement proper null checks"
- "Use modern ES6+ features appropriately"
- "Follow DRY (Don't Repeat Yourself) principles"
# Environment and Configuration
"**/*.env.*":
- "Follow security best practices for environment variables"
- "Document all environment variables"
- "Use proper naming conventions for environment variables"
# Documentation
"**/*.md":
- "Keep documentation up-to-date"
- "Use clear and concise language"
- "Include code examples where appropriate"
- "Document breaking changes" These instructions are based on the observed patterns in your codebase and will help maintain consistency across the project. They cover:
Would you like me to add or modify any specific areas of these instructions? 🔗 Analysis chainLet me gather information about the codebase structure and existing code standards first. 🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 72242 ✏️ Learnings added
|
Tip For best results, initiate chat on the files or code changes. @AndlerRL Thank you for providing these detailed code standards. I'll refine the path-based instructions to incorporate all these specific requirements: review_instructions:
- paths: ["**/*.{ts,tsx,js,jsx}"]
instructions: |
# JavaScript/TypeScript Standards
- Ensure semantic, idiomatic, functional, and declarative code
- Verify named exports are used instead of default exports
- Check boolean variable naming (should use is/has/does/should prefix)
- Verify TypeScript strict mode compliance
- Ensure no 'any' types are used
- Verify proper type inference usage
- Check proper use of interfaces (for objects/classes) vs types (for unions/complex types)
- Ensure proper error handling patterns
- paths: ["apps/masterbots.ai/**/*.{tsx,jsx}"]
instructions: |
# Component Standards
- Verify components are declared using regular function declarations
- Check component structure order:
1. Component declaration
2. Styled components
3. TypeScript types
- Ensure single responsibility principle
- Check for minimal props usage
- Verify composition over inheritance
- Ensure proper component splitting for maintainability
- Check proper use of TailwindCSS (no arbitrary values)
- Verify proper usage of shadcn/ui components
- Check CVA implementation for component variants
- paths: ["apps/masterbots.ai/app/**"]
instructions: |
# Next.js Standards
- Verify Server Components usage by default
- Check 'use client' directive is only used when necessary
- Verify proper implementation of nested layouts
- Check streaming and suspense implementation for large datasets
- Verify metadata files follow SEO conventions
- Ensure data fetching is done on server where possible
- paths: ["**/api/**", "apps/hasura/**"]
instructions: |
# API Standards
- Check GraphQL/SQL query optimization
- Verify proper error handling and logging
- Ensure use of generated type-safe clients (GraphQL/Supabase/DrizzleORM)
- Verify adherence to Hasura/Supabase/DrizzleORM best practices
- Check proper request validation
- Verify appropriate error responses
- paths: ["**/*.test.{ts,tsx,js,jsx}", "**/*.spec.{ts,tsx,js,jsx}"]
instructions: |
# Testing Standards
- Ensure critical functionality has unit tests
- Verify proper test structure and organization
- Check mocking strategies
- Verify edge cases coverage
- Ensure proper cleanup in tests
- paths: ["**/*"]
instructions: |
# File Structure Standards
- Verify lowercase with dashes for directories/names
- Check proper file extensions:
- .config.ts for configuration files
- .test.ts for tests
- .context.tsx for context files
- .type.ts for type definitions
- .hook.ts for hooks
- Verify feature-based directory grouping
- Check for flat folder structure where possible
Would you like me to:
1. Add more specific instructions for any particular area?
2. Include additional code quality checks?
3. Add specific instructions for other file types or patterns?
---
<details>
<summary>✏️ Learnings added</summary>
Learnt from: AndlerRL Timestamp: 2024-12-05T01:19:41.455Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:19:41.455Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:19:41.455Z
Learnt from: AndlerRL Timestamp: 2024-12-05T01:19:41.455Z
|
Enhance AI assistants to improve the sequence on tests and reviews:
Documentation:
The text was updated successfully, but these errors were encountered: