microevals 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- config/judge_system_prompt.yaml +113 -0
- evals/nextjs/001-server-component.yaml +28 -0
- evals/nextjs/002-client-component.yaml +26 -0
- evals/nextjs/003-cookies.yaml +28 -0
- evals/nextjs/010-route-handlers.yaml +30 -0
- evals/nextjs/013-pathname-server.yaml +29 -0
- evals/nextjs/014-server-routing.yaml +28 -0
- evals/nextjs/018-use-router.yaml +28 -0
- evals/nextjs/020_no_use_effect.yaml +30 -0
- evals/nextjs/021-avoid-fetch-in-effect.yaml +28 -0
- evals/nextjs/022_prefer_server_actions.yaml +29 -0
- evals/nextjs/023_avoid_getserversideprops.yaml +27 -0
- evals/nextjs/024_avoid_redundant_usestate.yaml +29 -0
- evals/nextjs/025_no_async_client_components.yaml +29 -0
- evals/nextjs/026_no_serial_await.yaml +26 -0
- evals/nextjs/027-prefer-next-image.yaml +30 -0
- evals/nextjs/027_no_hooks_in_server_components.yaml +29 -0
- evals/nextjs/028-prefer-next-font.yaml +30 -0
- evals/nextjs/028_cookies_headers_context.yaml +29 -0
- evals/nextjs/029_no_catch_redirect.yaml +31 -0
- evals/nextjs/030_app_router_migration.yaml +30 -0
- evals/nextjs/031_no_non_serializable_props.yaml +31 -0
- evals/react/001_missing_useeffect_dependencies.yaml +29 -0
- evals/react/002_incorrect_event_handler.yaml +28 -0
- evals/react/003_missing_return_in_map.yaml +28 -0
- evals/react/004_async_useeffect.yaml +32 -0
- evals/react/005_direct_state_mutation.yaml +30 -0
- evals/react/006_index_as_key.yaml +31 -0
- evals/react/zustand_store_usage.yaml +25 -0
- evals/shadcn/001_cn_utility_function.yaml +31 -0
- evals/shadcn/002_css_variables.yaml +32 -0
- evals/shadcn/003_component_dependencies.yaml +33 -0
- evals/shadcn/004_path_aliases.yaml +32 -0
- evals/shadcn/005_client_directive.yaml +31 -0
- evals/shadcn/006_tailwind_config.yaml +36 -0
- evals/shadcn/007_components_json_config.yaml +35 -0
- evals/supabase/001_client_setup.yaml +47 -0
- evals/supabase/002_auth_context_setup.yaml +43 -0
- evals/supabase/003_auth_flow_implementation.yaml +46 -0
- evals/supabase/004_auth_flow_testing_WIP.yaml +52 -0
- evals/supabase/005_auth_google_oauth.yaml +55 -0
- evals/supabase/007_storage_client_setup.yaml +43 -0
- evals/supabase/008_storage_nextjs_config.yaml +45 -0
- evals/supabase/009_storage_image_upload.yaml +49 -0
- evals/supabase/010_security_rls_enabled.yaml +42 -0
- evals/supabase/011_security_rls_policies.yaml +43 -0
- evals/supabase/012_security_no_service_key_exposed.yaml +49 -0
- evals/supabase/013_database_read_data.yaml +44 -0
- evals/supabase/014_database_create_data.yaml +44 -0
- evals/supabase/015_database_update_data.yaml +47 -0
- evals/supabase/016_database_delete_data.yaml +47 -0
- evals/supabase/017_database_user_scoped_query.yaml +52 -0
- evals/tailwind/001_tailwind_v4_config.yaml +22 -0
- evals/tailwind/002_content_paths.yaml +27 -0
- evals/tailwind/003_no_dynamic_class_construction.yaml +28 -0
- evals/tailwind/tailwind_postcss_config.yaml +24 -0
- evals/typescript/001_unsafe_type_assertions.yaml +39 -0
- evals/typescript/002_missing_null_checks.yaml +33 -0
- evals/vercel/001_vercel_deployment.yaml +19 -0
- evals/vercel/002_environment_variables_handling.yaml +23 -0
- evals/vercel/003_seo_metadata.yaml +33 -0
- microevals/__init__.py +34 -0
- microevals/eval_registry.py +222 -0
- microevals/eval_runner.py +533 -0
- microevals/utils.py +490 -0
- microevals-0.1.0.dist-info/METADATA +575 -0
- microevals-0.1.0.dist-info/RECORD +71 -0
- microevals-0.1.0.dist-info/WHEEL +5 -0
- microevals-0.1.0.dist-info/entry_points.txt +2 -0
- microevals-0.1.0.dist-info/licenses/LICENSE +21 -0
- microevals-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# System prompt for code evaluation judge
|
|
2
|
+
|
|
3
|
+
judge_prompt:
|
|
4
|
+
instruction_template: |
|
|
5
|
+
ROLE: You are an objective code evaluation judge.
|
|
6
|
+
|
|
7
|
+
Your sole responsibility is to evaluate code against specific criteria provided below.
|
|
8
|
+
You are NOT a code reviewer, bug finder, or general critic.
|
|
9
|
+
You ONLY assess whether the code meets the exact criteria specified.
|
|
10
|
+
|
|
11
|
+
Think of yourself as a judge in a competition who scores based on a rubric.
|
|
12
|
+
Your judgment must be fair, consistent, and based solely on the criteria given.
|
|
13
|
+
|
|
14
|
+
CRITICAL INSTRUCTIONS:
|
|
15
|
+
1. DO NOT MODIFY ANY CODE FILES. Only read and analyze them.
|
|
16
|
+
2. ONLY evaluate the SPECIFIC criteria below. DO NOT report other issues.
|
|
17
|
+
3. Even if you find critical bugs or problems, IGNORE them unless they match the criteria below.
|
|
18
|
+
4. Your ONLY job is to evaluate what is asked, nothing else.
|
|
19
|
+
|
|
20
|
+
EVALUATION CRITERIA TO CHECK:
|
|
21
|
+
{criteria}
|
|
22
|
+
|
|
23
|
+
{inputs_section}
|
|
24
|
+
|
|
25
|
+
SCORING RULES:
|
|
26
|
+
- Score 1.0: All criteria met successfully (PASS)
|
|
27
|
+
* The code implements what the criteria asks for
|
|
28
|
+
* No anti-patterns described in criteria are present
|
|
29
|
+
* All "must have" requirements are satisfied
|
|
30
|
+
|
|
31
|
+
- Score 0.0: Criteria not met or anti-pattern found (FAIL)
|
|
32
|
+
* The code does NOT implement what criteria asks for
|
|
33
|
+
* Anti-patterns described in criteria ARE present
|
|
34
|
+
* Any "must have" requirement is missing
|
|
35
|
+
|
|
36
|
+
- Score -1.0: Criteria NOT APPLICABLE (pattern/feature not present in codebase)
|
|
37
|
+
* Use this when the feature/pattern being evaluated doesn't exist in the codebase at all
|
|
38
|
+
* For example: evaluating Next.js patterns in a pure React app
|
|
39
|
+
* Or: evaluating authentication when no auth system exists
|
|
40
|
+
|
|
41
|
+
IMPORTANT SCORING GUIDANCE:
|
|
42
|
+
- Be strict but fair
|
|
43
|
+
- If criteria lists multiple requirements, ALL must be met for 1.0
|
|
44
|
+
- If even ONE anti-pattern is found, score is 0.0
|
|
45
|
+
- When in doubt between 0.0 and -1.0: if the code attempts the pattern (even badly), score 0.0; if pattern doesn't exist at all, score -1.0
|
|
46
|
+
|
|
47
|
+
REQUIRED OUTPUT:
|
|
48
|
+
You MUST use the write tool to create a file named "eval_result.json" in the current directory.
|
|
49
|
+
|
|
50
|
+
The JSON file must contain exactly these fields:
|
|
51
|
+
{{
|
|
52
|
+
"passed": true/false,
|
|
53
|
+
"score": 1.0 | 0.0 | -1.0,
|
|
54
|
+
"summary": "Brief explanation of what you found",
|
|
55
|
+
"evidence": ["Specific findings with line numbers"],
|
|
56
|
+
"issues": ["List of issues found or empty array"]
|
|
57
|
+
}}
|
|
58
|
+
|
|
59
|
+
CRITICAL: Use the write tool to create eval_result.json - do not just output JSON to console.
|
|
60
|
+
|
|
61
|
+
batch_judge_prompt:
|
|
62
|
+
instruction_template: |
|
|
63
|
+
ROLE: You are an objective code evaluation judge conducting BATCH evaluations.
|
|
64
|
+
|
|
65
|
+
Your sole responsibility is to evaluate code against MULTIPLE criteria provided below.
|
|
66
|
+
You are NOT a code reviewer, bug finder, or general critic.
|
|
67
|
+
You ONLY assess whether the code meets each exact criteria specified.
|
|
68
|
+
|
|
69
|
+
CRITICAL INSTRUCTIONS:
|
|
70
|
+
1. DO NOT MODIFY ANY CODE FILES. Only read and analyze them.
|
|
71
|
+
2. Run ALL {eval_count} evaluations listed below.
|
|
72
|
+
3. Complete EVERY evaluation, even if some fail or error.
|
|
73
|
+
4. Save EACH result to its specified filename.
|
|
74
|
+
5. Use the SAME scoring rules for each evaluation.
|
|
75
|
+
|
|
76
|
+
SCORING RULES (apply to EVERY evaluation):
|
|
77
|
+
- Score 1.0: All criteria met successfully (PASS)
|
|
78
|
+
* The code implements what the criteria asks for
|
|
79
|
+
* No anti-patterns described in criteria are present
|
|
80
|
+
* All "must have" requirements are satisfied
|
|
81
|
+
|
|
82
|
+
- Score 0.0: Criteria not met or anti-pattern found (FAIL)
|
|
83
|
+
* The code does NOT implement what criteria asks for
|
|
84
|
+
* Anti-patterns described in criteria ARE present
|
|
85
|
+
* Any "must have" requirement is missing
|
|
86
|
+
|
|
87
|
+
- Score -1.0: Criteria NOT APPLICABLE (pattern/feature not present in codebase)
|
|
88
|
+
* Use this when the feature/pattern being evaluated doesn't exist in the codebase at all
|
|
89
|
+
* For example: evaluating Next.js patterns in a pure React app
|
|
90
|
+
* Or: evaluating authentication when no auth system exists
|
|
91
|
+
|
|
92
|
+
IMPORTANT SCORING GUIDANCE:
|
|
93
|
+
- Be strict but fair for each evaluation
|
|
94
|
+
- If criteria lists multiple requirements, ALL must be met for 1.0
|
|
95
|
+
- If even ONE anti-pattern is found, score is 0.0
|
|
96
|
+
- When in doubt between 0.0 and -1.0: if the code attempts the pattern (even badly), score 0.0; if pattern doesn't exist at all, score -1.0
|
|
97
|
+
|
|
98
|
+
EVALUATIONS TO RUN:
|
|
99
|
+
{batch_criteria}
|
|
100
|
+
|
|
101
|
+
REQUIRED OUTPUT FOR EACH EVALUATION:
|
|
102
|
+
You MUST use the write tool to create a separate JSON file for EACH evaluation using the exact filename specified.
|
|
103
|
+
|
|
104
|
+
Each JSON file must contain exactly these fields:
|
|
105
|
+
{{
|
|
106
|
+
"passed": true/false,
|
|
107
|
+
"score": 1.0 | 0.0 | -1.0,
|
|
108
|
+
"summary": "Brief explanation of what you found",
|
|
109
|
+
"evidence": ["Specific findings with line numbers"],
|
|
110
|
+
"issues": ["List of issues found or empty array"]
|
|
111
|
+
}}
|
|
112
|
+
|
|
113
|
+
CRITICAL: Create a SEPARATE file for each evaluation. Do not combine results into one file.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
eval_id: nextjs_server_component_001
|
|
2
|
+
name: "Server Component Data Fetching"
|
|
3
|
+
description: "Validates proper async server component implementation for data fetching"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if server components properly fetch data.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases with data fetching.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Look for page components (page.tsx/jsx files) or server components that fetch data.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Server component uses 'use client' directive just to use useState/useEffect for data fetching
|
|
16
|
+
- Async function fetch but missing 'await' on fetch() or response.json()
|
|
17
|
+
- Component should be async but isn't declared as async
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Page/server component is async function
|
|
21
|
+
- Uses 'await fetch()' and 'await response.json()'
|
|
22
|
+
- No 'use client' directive for data fetching components
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): Server components properly fetch data with async/await, no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (using 'use client' for data fetching, missing await, non-async)
|
|
27
|
+
- Score -1.0 (N/A): No Next.js App Router OR no server components doing data fetching
|
|
28
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
eval_id: nextjs_client_component_002
|
|
2
|
+
name: "Client Component with State"
|
|
3
|
+
description: "Validates proper client component implementation with React state management"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if components using React hooks have the 'use client' directive.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases using React hooks.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find any files that import and use React hooks (useState, useEffect, useReducer, etc.)
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- File uses useState, useEffect, or other React hooks but is missing 'use client' directive at top
|
|
16
|
+
- Component in app/ directory uses hooks without 'use client'
|
|
17
|
+
|
|
18
|
+
CORRECT PATTERN (mark as passed):
|
|
19
|
+
- All components using hooks have 'use client' at the top of the file
|
|
20
|
+
- Or they properly import client components that handle the hooks
|
|
21
|
+
|
|
22
|
+
SCORING:
|
|
23
|
+
- Score 1.0 (PASS): All components using React hooks have 'use client' directive, no anti-patterns found
|
|
24
|
+
- Score 0.0 (FAIL): Components use React hooks without 'use client' directive
|
|
25
|
+
- Score -1.0 (N/A): No Next.js App Router OR no components use React hooks OR using Pages Router
|
|
26
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
eval_id: nextjs_server_actions_cookies_003
|
|
2
|
+
name: "Server Actions Cookie Management"
|
|
3
|
+
description: "Validates server actions properly handle cookies using Next.js APIs"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if cookie management uses the correct APIs.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases that set/read cookies.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find any code that sets or reads cookies. Check where and how cookies are used.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Server actions or server components use document.cookie (browser API)
|
|
16
|
+
- Setting cookies without importing cookies() from 'next/headers'
|
|
17
|
+
- Using cookies() in client components (has 'use client')
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Server actions use 'use server' and cookies() from 'next/headers'
|
|
21
|
+
- Server components import { cookies } from 'next/headers'
|
|
22
|
+
- Client-side uses fetch/server actions to set cookies server-side
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): Cookie management uses correct Next.js APIs (cookies() from 'next/headers'), no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (using document.cookie in server context, cookies() in client components, etc.)
|
|
27
|
+
- Score -1.0 (N/A): No Next.js App Router OR no cookie management in codebase OR using Pages Router only
|
|
28
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
eval_id: nextjs_route_handlers_010
|
|
2
|
+
name: "Route Handlers API Routes"
|
|
3
|
+
description: "Validates proper Next.js App Router route handler implementation"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if API routes use correct Next.js App Router patterns.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases with API routes.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find route.ts/route.js files in the app/ directory (API routes).
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- route.ts file uses Pages Router API (export default function handler(req, res))
|
|
16
|
+
- Using Node.js req/res objects instead of Next.js Request/Response
|
|
17
|
+
- API route not named route.ts/route.js
|
|
18
|
+
- Missing Response.json() for JSON responses
|
|
19
|
+
|
|
20
|
+
CORRECT PATTERN (mark as passed):
|
|
21
|
+
- Files named route.ts in app/api/[endpoint]/ structure
|
|
22
|
+
- Exports named functions: GET, POST, PUT, DELETE, etc.
|
|
23
|
+
- Uses Next.js Request/Response: new Response(), Response.json()
|
|
24
|
+
- Async functions when doing async operations
|
|
25
|
+
|
|
26
|
+
SCORING:
|
|
27
|
+
- Score 1.0 (PASS): API routes use correct App Router patterns (route.ts files with named exports GET/POST/etc.), no anti-patterns found
|
|
28
|
+
- Score 0.0 (FAIL): Anti-patterns found (Pages Router patterns in App Router, wrong file names, missing Response.json(), etc.)
|
|
29
|
+
- Score -1.0 (N/A): No API routes in codebase OR using Pages Router only OR no Next.js App Router
|
|
30
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_pathname_server_013
|
|
2
|
+
name: "Dynamic Route Parameters in Server Components"
|
|
3
|
+
description: "Validates using params prop in dynamic route server components"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if dynamic routes properly use params.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router with dynamic routes.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find dynamic route folders (app/[id], app/posts/[slug], etc.) and check their page.tsx files.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Dynamic route page component tries to use useRouter() or useParams() in server component
|
|
16
|
+
- Server component doesn't accept params prop but needs route parameters
|
|
17
|
+
- Component is marked 'use client' just to access route params
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Server component accepts params prop: async function Page({ params })
|
|
21
|
+
- Uses params.id or params.slug etc. to fetch data
|
|
22
|
+
- Component is async and awaits data fetching
|
|
23
|
+
- No 'use client' needed just for route params
|
|
24
|
+
|
|
25
|
+
SCORING:
|
|
26
|
+
- Score 1.0 (PASS): Dynamic route server components properly use params prop, no anti-patterns found
|
|
27
|
+
- Score 0.0 (FAIL): Anti-patterns found (using useRouter/useParams in server components, missing params prop, 'use client' just for route params)
|
|
28
|
+
- Score -1.0 (N/A): No dynamic routes in codebase OR using Pages Router only OR no Next.js App Router
|
|
29
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
eval_id: nextjs_server_routing_014
|
|
2
|
+
name: "Server-Side Routing and Redirects"
|
|
3
|
+
description: "Validates proper server-side redirect() usage vs client-side navigation"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if redirects are done correctly based on context.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to redirects in Next.js App Router.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find redirect() calls and check if they're used in the right context (server vs client).
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Server component (no 'use client') tries to use useRouter().push() for redirects
|
|
16
|
+
- Using window.location.href in server components or server actions
|
|
17
|
+
- Auth redirects done client-side when user data is only available server-side
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Server-side redirects use redirect() from 'next/navigation' in server components
|
|
21
|
+
- Client-side navigation uses useRouter().push() in 'use client' components
|
|
22
|
+
- Auth checks done server-side with redirect() if unauthorized
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): Redirects use correct APIs based on context (redirect() in server, useRouter in client), no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (useRouter in server components, window.location in server, client-side auth redirects with server data)
|
|
27
|
+
- Score -1.0 (N/A): No redirects in codebase OR no Next.js App Router OR using Pages Router
|
|
28
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
eval_id: nextjs_use_router_018
|
|
2
|
+
name: "useRouter Programmatic Navigation"
|
|
3
|
+
description: "Validates proper useRouter import from next/navigation (App Router)"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if useRouter is imported from the correct package.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases using programmatic navigation.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find any imports of useRouter hook.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Importing useRouter from 'next/router' in App Router app/ directory
|
|
16
|
+
- Using window.location.href = '...' for Next.js navigation
|
|
17
|
+
- Missing 'use client' in file that uses useRouter
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Imports useRouter from 'next/navigation' (App Router)
|
|
21
|
+
- File has 'use client' directive
|
|
22
|
+
- Uses router.push(), router.back(), router.refresh() correctly
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): useRouter imported from 'next/navigation' with 'use client' directive, no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (importing from 'next/router' in App Router, window.location, missing 'use client')
|
|
27
|
+
- Score -1.0 (N/A): No programmatic navigation OR using Pages Router only OR only using Link components
|
|
28
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
eval_id: nextjs_no_use_effect_020
|
|
2
|
+
name: "Avoid Unnecessary useEffect"
|
|
3
|
+
description: "Checks for unnecessary useEffect usage that can be replaced with direct code execution"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
Detect unnecessary useEffect hooks that can be replaced with direct code execution.
|
|
8
|
+
|
|
9
|
+
ANTI-PATTERNS:
|
|
10
|
+
- useEffect for browser/navigator detection (can be done directly in component body)
|
|
11
|
+
- useEffect for setting derived state (should compute during render)
|
|
12
|
+
- useEffect with empty deps for one-time calculations (can be done at module level or during render)
|
|
13
|
+
- useEffect just to call a function once (can call directly in component)
|
|
14
|
+
|
|
15
|
+
WHY IT'S WRONG:
|
|
16
|
+
- Adds unnecessary complexity and indirection
|
|
17
|
+
- Can cause extra re-renders
|
|
18
|
+
- Makes code harder to understand and maintain
|
|
19
|
+
- May cause timing issues (effect runs after paint)
|
|
20
|
+
|
|
21
|
+
CORRECT APPROACH:
|
|
22
|
+
- Compute values directly in component body
|
|
23
|
+
- Use useMemo for expensive derived computations
|
|
24
|
+
- Call functions directly if they don't need side effects
|
|
25
|
+
- Only use useEffect for actual side effects (subscriptions, DOM manipulation, etc.)
|
|
26
|
+
|
|
27
|
+
SCORING:
|
|
28
|
+
- Score 1.0 (PASS): No unnecessary useEffect found - all effects are for legitimate side effects
|
|
29
|
+
- Score 0.0 (FAIL): Unnecessary useEffect detected - code that doesn't need side effects
|
|
30
|
+
- Score -1.0 (N/A): No React/Next.js code found in project
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
eval_id: nextjs_avoid_fetch_in_effect_021
|
|
2
|
+
name: "Avoid Fetch in useEffect"
|
|
3
|
+
description: "Detects unnecessary client-side data fetching that should be server-side"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if data fetching is done server-side when possible.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js App Router codebases with data fetching.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find components that fetch data on mount. Check if they could be server components instead.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Page component has 'use client' and uses useEffect(() => { fetch(...) }, []) for initial data
|
|
16
|
+
- Component marked 'use client' solely to use useState/useEffect for non-interactive data fetching
|
|
17
|
+
- Loading data that doesn't depend on user interaction or client-side state
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Page components are async server components that await fetch()
|
|
21
|
+
- Client components only fetch data in response to user interaction
|
|
22
|
+
- useEffect fetch is for real-time updates, polling, or client-specific needs
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): Data fetching done server-side when possible, client-side fetch only for valid reasons (user interaction, real-time), no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (useEffect fetch for initial data that should be server-side, 'use client' solely for non-interactive data)
|
|
27
|
+
- Score -1.0 (N/A): No data fetching OR all client-side fetching is legitimate OR using Pages Router
|
|
28
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_prefer_server_actions_022
|
|
2
|
+
name: "Prefer Server Actions Over API Routes"
|
|
3
|
+
description: "Checks if forms use server actions instead of client-side fetch to API routes"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
Check if forms use server actions instead of client-side fetch to API routes.
|
|
8
|
+
|
|
9
|
+
ANTI-PATTERN:
|
|
10
|
+
- Forms with onSubmit + fetch/axios calls to API routes
|
|
11
|
+
- Creating API routes just for simple form mutations
|
|
12
|
+
- Client-side data fetching for form submissions
|
|
13
|
+
|
|
14
|
+
BEST PRACTICE (Next.js 13+ App Router):
|
|
15
|
+
- Forms with action={serverAction} prop
|
|
16
|
+
- 'use server' directive in server action functions
|
|
17
|
+
- Direct FormData usage in server actions
|
|
18
|
+
- No intermediate API route needed
|
|
19
|
+
|
|
20
|
+
WHY IT'S BETTER:
|
|
21
|
+
- Simpler code - no API route + fetch boilerplate
|
|
22
|
+
- Better performance - direct server execution
|
|
23
|
+
- Type safety - server actions are type-safe
|
|
24
|
+
- Progressive enhancement - works without JavaScript
|
|
25
|
+
|
|
26
|
+
SCORING:
|
|
27
|
+
- Score 1.0 (PASS): Forms use server actions (or no forms exist but should score 1.0 if using App Router best practices)
|
|
28
|
+
- Score 0.0 (FAIL): Forms use old pattern (onSubmit + fetch to API routes)
|
|
29
|
+
- Score -1.0 (N/A): No forms found, or using Pages Router (where API routes are appropriate)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
eval_id: nextjs_avoid_getserversideprops_023
|
|
2
|
+
name: "Avoid Pages Router Patterns (getServerSideProps)"
|
|
3
|
+
description: "Detects old Pages Router patterns like getServerSideProps in App Router apps"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
Detect old Pages Router patterns (getServerSideProps, getStaticProps, getInitialProps).
|
|
8
|
+
|
|
9
|
+
OLD PATTERNS (Pages Router - deprecated in App Router):
|
|
10
|
+
- export function getServerSideProps
|
|
11
|
+
- export function getStaticProps
|
|
12
|
+
- export function getInitialProps
|
|
13
|
+
|
|
14
|
+
WHY IT'S WRONG:
|
|
15
|
+
- These functions only work in Pages Router (pages/ directory)
|
|
16
|
+
- App Router uses server components and async functions instead
|
|
17
|
+
- Mixing routers causes confusion and errors
|
|
18
|
+
|
|
19
|
+
CORRECT APPROACH (App Router):
|
|
20
|
+
- Use server components for data fetching
|
|
21
|
+
- Use async/await directly in components
|
|
22
|
+
- Use server actions for mutations
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): No Pages Router patterns found - using App Router correctly
|
|
26
|
+
- Score 0.0 (FAIL): Old Pages Router patterns detected (getServerSideProps, getStaticProps, getInitialProps)
|
|
27
|
+
- Score -1.0 (N/A): Using Pages Router exclusively (pages/ directory exists, app/ doesn't)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_avoid_redundant_usestate_024
|
|
2
|
+
name: "Avoid Redundant useState"
|
|
3
|
+
description: "Checks for unnecessary useState for derived values that can be computed directly"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
Detect useState storing derived values that could be computed directly.
|
|
8
|
+
|
|
9
|
+
ANTI-PATTERN:
|
|
10
|
+
- useState for values completely derived from other state
|
|
11
|
+
- useEffect updating state based on other state changes
|
|
12
|
+
- Example: `const [showResult, setShowResult] = useState(false)` that mirrors `selected !== null`
|
|
13
|
+
- Example: total price from items array (should compute, not store)
|
|
14
|
+
|
|
15
|
+
WHY IT'S WRONG:
|
|
16
|
+
- Unnecessary complexity and state management overhead
|
|
17
|
+
- Can lead to synchronization bugs if derived state gets out of sync
|
|
18
|
+
- Extra re-renders when both states update
|
|
19
|
+
- Harder to maintain and understand
|
|
20
|
+
|
|
21
|
+
CORRECT APPROACH:
|
|
22
|
+
- Compute derived values directly: `const showResult = selected !== null`
|
|
23
|
+
- Use useMemo for expensive computations
|
|
24
|
+
- Keep state minimal and derive everything else
|
|
25
|
+
|
|
26
|
+
SCORING:
|
|
27
|
+
- Score 1.0 (PASS): No redundant useState found - all state is minimal and necessary
|
|
28
|
+
- Score 0.0 (FAIL): Redundant useState detected - state storing derived values
|
|
29
|
+
- Score -1.0 (N/A): No React/Next.js code found in project
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_no_async_client_components_025
|
|
2
|
+
name: "No Async Client Components"
|
|
3
|
+
description: "Catches async client components which cause runtime errors"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Look for a specific runtime error pattern.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This catches a common mistake that causes immediate runtime errors.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find any file that has BOTH 'use client' directive AND an async component function.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed - THIS IS A BUG):
|
|
15
|
+
- File has 'use client' at the top
|
|
16
|
+
- AND exports an async function component: export default async function MyComponent()
|
|
17
|
+
- This causes error: "Client components cannot be async"
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Client components ('use client') are NOT async
|
|
21
|
+
- Async components do NOT have 'use client' (they're server components)
|
|
22
|
+
|
|
23
|
+
SCORING:
|
|
24
|
+
- Score 1.0 (PASS): No async client components found, all async components are server components, no anti-patterns found
|
|
25
|
+
- Score 0.0 (FAIL): Anti-pattern found - file has 'use client' AND async component function (THIS IS A BUG that breaks the app)
|
|
26
|
+
- Score -1.0 (N/A): No Next.js App Router OR no async component functions in codebase
|
|
27
|
+
|
|
28
|
+
NOTE: This is a critical error. If found, this breaks the app immediately.
|
|
29
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
eval_id: nextjs_no_serial_await_026
|
|
2
|
+
name: "Avoid Serial Await (Use Parallel Fetching)"
|
|
3
|
+
description: "Checks for serial await pattern that should be parallelized with Promise.all"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
Detect serial await for independent requests (should use Promise.all).
|
|
8
|
+
|
|
9
|
+
ANTI-PATTERN:
|
|
10
|
+
- const data1 = await fetch1();
|
|
11
|
+
- const data2 = await fetch2(); // Independent of data1 - should be parallel!
|
|
12
|
+
- Serial awaiting when requests don't depend on each other
|
|
13
|
+
|
|
14
|
+
WHY IT'S WRONG:
|
|
15
|
+
- Wastes time - second request waits unnecessarily for first to complete
|
|
16
|
+
- Poor performance - doubles the total wait time
|
|
17
|
+
- Example: 2 serial 1s requests = 2s total, parallel = 1s total
|
|
18
|
+
|
|
19
|
+
CORRECT APPROACH:
|
|
20
|
+
- const [data1, data2] = await Promise.all([fetch1(), fetch2()])
|
|
21
|
+
- Only use serial await when requests are dependent
|
|
22
|
+
|
|
23
|
+
SCORING:
|
|
24
|
+
- Score 1.0 (PASS): No serial await for independent requests - using Promise.all appropriately
|
|
25
|
+
- Score 0.0 (FAIL): Serial await detected for independent requests
|
|
26
|
+
- Score -1.0 (N/A): No multiple async operations found, or all serial awaits are legitimately dependent
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
eval_id: nextjs_prefer_next_image_027
|
|
2
|
+
name: "Prefer Next.js Image Component"
|
|
3
|
+
description: "Validates using Next.js Image instead of img tags for image optimization"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if images are using Next.js optimization.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js projects displaying images.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find <img> tags or Image components in the codebase.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Using <img> tags instead of Next.js Image component
|
|
16
|
+
- Hardcoded image paths without optimization
|
|
17
|
+
- Missing required props (width, height, alt) on Image component
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Import Image from 'next/image'
|
|
21
|
+
- Use <Image src="..." alt="..." width={X} height={Y} />
|
|
22
|
+
- All images have proper alt text for accessibility
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): All images use Next.js Image component with proper props, no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (using <img> tags, missing required props on Image, no alt text)
|
|
27
|
+
- Score -1.0 (N/A): No images displayed OR images are only SVGs OR not using Next.js
|
|
28
|
+
|
|
29
|
+
NOTE: This is an optimization, not a bug. <img> works but misses Next.js optimizations.
|
|
30
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_no_hooks_in_server_components_027
|
|
2
|
+
name: "No React Hooks in Server Components"
|
|
3
|
+
description: "Catches React hooks used without 'use client' - causes runtime error"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Look for hooks used in server components.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This catches a very common mistake that causes runtime errors.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find files that use React hooks (useState, useEffect, useReducer, useContext, etc.) but DON'T have 'use client' directive.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed - THIS IS A BUG):
|
|
15
|
+
- File in app/ directory uses useState, useEffect, etc.
|
|
16
|
+
- File is missing 'use client' at the top
|
|
17
|
+
- Error: "You're importing a component that needs useState. This only works in a Client Component"
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- All files using hooks have 'use client' directive
|
|
21
|
+
- Server components don't use hooks
|
|
22
|
+
|
|
23
|
+
SCORING:
|
|
24
|
+
- Score 1.0 (PASS): All files using React hooks have 'use client' directive, no anti-patterns found
|
|
25
|
+
- Score 0.0 (FAIL): Anti-pattern found - React hooks used without 'use client' directive (THIS IS A BUG that breaks the app)
|
|
26
|
+
- Score -1.0 (N/A): No Next.js App Router OR using Pages Router OR no React hooks used in codebase
|
|
27
|
+
|
|
28
|
+
NOTE: This is one of the most common Next.js App Router mistakes.
|
|
29
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
eval_id: nextjs_prefer_next_font_028
|
|
2
|
+
name: "Prefer Next.js Font Optimization"
|
|
3
|
+
description: "Validates using next/font instead of external font CDN or CSS imports"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Evaluate if custom fonts are using Next.js optimization.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This eval applies to Next.js projects using custom fonts.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find font loading patterns - check HTML head, CSS @import, or next/font imports.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed):
|
|
15
|
+
- Google Fonts loaded via CDN link in HTML: <link href="https://fonts.googleapis.com/...">
|
|
16
|
+
- @import url('https://fonts.googleapis.com/...') in CSS
|
|
17
|
+
- External stylesheet for fonts instead of next/font
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- Import fonts from next/font/google: import { Inter } from 'next/font/google'
|
|
21
|
+
- Configure with options: const inter = Inter({ subsets: ['latin'] })
|
|
22
|
+
- Apply className: <body className={inter.className}>
|
|
23
|
+
|
|
24
|
+
SCORING:
|
|
25
|
+
- Score 1.0 (PASS): Custom fonts use next/font optimization, no anti-patterns found
|
|
26
|
+
- Score 0.0 (FAIL): Anti-patterns found (loading fonts via CDN links, @import in CSS, external stylesheets)
|
|
27
|
+
- Score -1.0 (N/A): No custom fonts used OR not using Next.js OR no Next.js App Router
|
|
28
|
+
|
|
29
|
+
NOTE: This is an optimization, not a bug. CDN fonts work but are slower.
|
|
30
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
eval_id: nextjs_cookies_headers_context_028
|
|
2
|
+
name: "Cookies/Headers Only in Server Context"
|
|
3
|
+
description: "Catches cookies() or headers() used in client components - causes runtime error"
|
|
4
|
+
category: nextjs
|
|
5
|
+
|
|
6
|
+
criteria: |
|
|
7
|
+
You have access to the entire codebase. Look for cookies() or headers() in wrong contexts.
|
|
8
|
+
|
|
9
|
+
CONTEXT: This catches a mistake that causes runtime errors.
|
|
10
|
+
|
|
11
|
+
WHAT TO LOOK FOR:
|
|
12
|
+
Find imports of cookies or headers from 'next/headers' and check where they're used.
|
|
13
|
+
|
|
14
|
+
ANTI-PATTERN (mark as failed - THIS IS A BUG):
|
|
15
|
+
- File has 'use client' directive AND uses cookies() or headers()
|
|
16
|
+
- Error: "cookies() only works in Server Components"
|
|
17
|
+
- These APIs only work in server components, server actions, and route handlers
|
|
18
|
+
|
|
19
|
+
CORRECT PATTERN (mark as passed):
|
|
20
|
+
- cookies() and headers() only used in files WITHOUT 'use client'
|
|
21
|
+
- Used in server components, server actions (use server), or route.ts files
|
|
22
|
+
|
|
23
|
+
SCORING:
|
|
24
|
+
- Score 1.0 (PASS): cookies() and headers() only used in server context (no 'use client'), no anti-patterns found
|
|
25
|
+
- Score 0.0 (FAIL): Anti-pattern found - cookies() or headers() used in client components with 'use client' (THIS IS A BUG)
|
|
26
|
+
- Score -1.0 (N/A): No usage of cookies() or headers() from 'next/headers' OR no Next.js App Router
|
|
27
|
+
|
|
28
|
+
NOTE: If you need cookies in client component, pass them as props from server component.
|
|
29
|
+
|