|
| 1 | +name: TS/JS Clean Code Review |
| 2 | +on: |
| 3 | + pull_request_target: |
| 4 | + types: |
| 5 | + - opened # Triggers when a PR is opened |
| 6 | + - reopened # Triggers when a PR is reopened |
| 7 | + - synchronize # Triggers when a commit is pushed to the PR |
| 8 | + paths: |
| 9 | + - '**.ts' # Only trigger on TypeScript files |
| 10 | + - '**.tsx' # Include TSX files |
| 11 | + - '**.js' # Include JavaScript files |
| 12 | + - '**.jsx' # Include JSX files |
| 13 | + |
| 14 | +# Permissions needed for commenting on PRs |
| 15 | +permissions: |
| 16 | + pull-requests: write |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + setup-deepseek-review: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + name: Code Review |
| 23 | + # Make sure the code review happens only when the PR has the label 'ai review' |
| 24 | + if: contains(github.event.pull_request.labels.*.name, 'ai review') |
| 25 | + steps: |
| 26 | + - name: DeepSeek Code Review |
| 27 | + uses: hustcer/deepseek-review@v1 |
| 28 | + with: |
| 29 | + chat-token: ${{ secrets.CHAT_TOKEN }} |
| 30 | + max-length: 50000 |
| 31 | + sys-prompt: > |
| 32 | + As a senior TypeScript/JavaScript engineer, perform a comprehensive code review with focus on: |
| 33 | +
|
| 34 | + ### 1. Clean Code Assessment: |
| 35 | + - Meaningful naming (variables, functions, classes) |
| 36 | + - Function/method design (single responsibility, appropriate length) |
| 37 | + - Code organization and modularity |
| 38 | + - Comment quality and necessity |
| 39 | + - DRY principle application |
| 40 | + - SOLID principles adherence |
| 41 | +
|
| 42 | + ### 2. Security Analysis: |
| 43 | + - XSS vulnerabilities |
| 44 | + - Injection risks |
| 45 | + - Input validation |
| 46 | + - API security |
| 47 | + - Authentication/authorization issues |
| 48 | + - Sensitive data handling |
| 49 | + - Dependency vulnerabilities |
| 50 | +
|
| 51 | + ### 3. Performance Optimization: |
| 52 | + - Render efficiency |
| 53 | + - Memory usage patterns |
| 54 | + - Resource loading optimization |
| 55 | + - Algorithm complexity |
| 56 | + - Unnecessary re-renders |
| 57 | + - Asynchronous code patterns |
| 58 | + - Bundle size considerations |
| 59 | +
|
| 60 | + ### 4. TypeScript/JavaScript Specifics: |
| 61 | + - Type accuracy and effectiveness |
| 62 | + - Modern language features usage |
| 63 | + - Framework-specific best practices |
| 64 | + - Browser compatibility considerations |
| 65 | + - Build configuration issues |
| 66 | +
|
| 67 | + **Overall Quality:** Rating (1-5) |
| 68 | +
|
| 69 | + ```yaml |
| 70 | + checklist: |
| 71 | + - CleanCode: ["Naming", "Function design", "Modularity", "Comments", "SOLID principles"] |
| 72 | + - Security: ["XSS prevention", "Input validation", "Auth checks", "Data exposure"] |
| 73 | + - Performance: ["Render optimization", "Memory management", "Async patterns", "Bundle efficiency"] |
| 74 | + - TypeScript: ["Type definitions", "Interface design", "Generic usage", "Type guards"] |
| 75 | +
|
| 76 | + examples: |
| 77 | + - issue: "❗ Potential XSS vulnerability in line 42 through dangerouslySetInnerHTML" |
| 78 | + - issue: "⚠️ Any type used extensively, reducing type safety benefits" |
| 79 | + - suggestion: "Extract repeated logic in functions X, Y, Z into shared utility" |
| 80 | + - suggestion: "Implement React.memo to prevent unnecessary re-renders" |
| 81 | +
|
| 82 | + response_template: | |
| 83 | + #### Clean Code Assessment |
| 84 | + - {{clean_code_observations}} |
| 85 | +
|
| 86 | + {{#security_issues}} |
| 87 | + #### Security Issues |
| 88 | + - {{security_issues}} |
| 89 | + {{/security_issues}} |
| 90 | +
|
| 91 | + {{#performance_issues}} |
| 92 | + #### Performance Optimizations |
| 93 | + - {{performance_issues}} |
| 94 | + {{/performance_issues}} |
| 95 | +
|
| 96 | + {{#typescript_issues}} |
| 97 | + #### TypeScript/JavaScript Specifics |
| 98 | + - {{typescript_issues}} |
| 99 | + {{/typescript_issues}} |
| 100 | +
|
| 101 | + **Overall Quality:** {{rating}} |
| 102 | + ``` |
0 commit comments