AI Prompt: Forma3D.Connect — Phase 5l: ESLint Test Setup Cleanup¶
Purpose: This prompt instructs an AI to remove ESLint disable comments from test setup files and configure proper ESLint rules for test files
Estimated Effort: 2-4 hours
Prerequisites: Phase 5k completed (Configuration)
Output: Clean ESLint configuration for test files, no disable comments
Status: 🟡 PENDING
🎯 Mission¶
You are continuing development of Forma3D.Connect, building on the Phase 5k foundation. Your task is to implement Phase 5l: ESLint Test Setup Cleanup — specifically addressing TD-010 (ESLint Disable Comments in Test Setup) from the technical debt register.
Why This Matters:
Test setup files contain eslint-disable directives which:
- Hide Real Issues: Broad disables can mask legitimate problems
- Inconsistent Standards: Test code held to different (lower) standards
- Maintenance Burden: Need to remember which rules are disabled where
Phase 5l delivers:
- Proper ESLint configuration for test files
- Removal of all
eslint-disablecomments - Correct TypeScript declarations without rule violations
📋 Context: Technical Debt Item¶
TD-010: ESLint Disable Comments in Test Setup¶
| Attribute | Value |
|---|---|
| Type | Code Debt |
| Priority | Medium |
| Location | apps/api-e2e/src/support/global-*.ts |
| Interest Rate | Low-Medium |
| Principal (Effort) | 2-4 hours |
Current Problem¶
/* eslint-disable */
// eslint-disable-next-line no-var
declare var __TEARDOWN_MESSAGE__: string;
🛠️ Implementation Phases¶
Phase 1: Analyze Current ESLint Configuration (30 minutes)¶
Priority: Critical | Impact: High | Dependencies: None
1. Review Existing ESLint Config¶
Check the root ESLint configuration and any test-specific overrides:
# Find all ESLint config files
find . -name ".eslintrc*" -o -name "eslint.config.*"
# Find all eslint-disable comments
rg "eslint-disable" --type ts
2. Identify Violations¶
Document each eslint-disable usage and the specific rule being bypassed:
| File | Line | Rule | Reason |
|---|---|---|---|
global-setup.ts |
1 | All rules | Legacy setup |
global-teardown.ts |
3 | no-var |
Global declaration |
Phase 2: Create Test-Specific ESLint Configuration (1 hour)¶
Priority: High | Impact: High | Dependencies: Phase 1
1. Create E2E ESLint Override¶
Update or create apps/api-e2e/.eslintrc.json:
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["apps/api-e2e/tsconfig.json"]
},
"rules": {
"@typescript-eslint/no-namespace": "off"
}
},
{
"files": ["src/support/global-*.ts"],
"rules": {
"no-var": "off",
"@typescript-eslint/no-explicit-any": "warn"
}
}
]
}
2. Global Declarations Pattern¶
Replace eslint-disable with proper TypeScript declarations:
Before (global-setup.ts):
/* eslint-disable */
// eslint-disable-next-line no-var
declare var __TEARDOWN_MESSAGE__: string;
After (global-setup.ts):
// Global test state - configured in eslintrc for test setup files
declare var __TEARDOWN_MESSAGE__: string;
export default async function globalSetup() {
// Setup logic
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n';
}
3. TypeScript Global Type Augmentation (Alternative)¶
Create apps/api-e2e/src/support/global.d.ts:
/**
* Global test state declarations
* These are set in global-setup.ts and read in global-teardown.ts
*/
declare global {
// eslint configuration in .eslintrc.json allows var in this file
var __TEARDOWN_MESSAGE__: string;
}
export {};
Then import in setup files:
import './global.d.ts';
Phase 3: Update Test Setup Files (1 hour)¶
Priority: High | Impact: Medium | Dependencies: Phase 2
1. Update global-setup.ts¶
import { execSync } from 'child_process';
/**
* Nx E2E global setup
* Runs once before all tests
*/
export default async function globalSetup() {
console.log('\nSetting up E2E test environment...\n');
// Set teardown message for global-teardown.ts
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down E2E test environment...\n';
// Additional setup logic...
}
2. Update global-teardown.ts¶
/**
* Nx E2E global teardown
* Runs once after all tests
*/
export default async function globalTeardown() {
// Access the message set in global-setup.ts
const message = globalThis.__TEARDOWN_MESSAGE__ || 'Teardown complete';
console.log(message);
// Cleanup logic...
}
Phase 4: Verify No ESLint Disables Remain (30 minutes)¶
Priority: Medium | Impact: Low | Dependencies: Phase 3
1. Search for Remaining Disables¶
# Should return only expected results (if any in node_modules or generated files)
rg "eslint-disable" apps/ libs/ --type ts
# Exclude expected locations
rg "eslint-disable" apps/ libs/ --type ts --glob "!**/node_modules/**" --glob "!**/dist/**"
2. Run ESLint¶
# Full lint check
pnpm nx lint api-e2e
# Fix auto-fixable issues
pnpm nx lint api-e2e --fix
📁 Files to Create/Modify¶
Modified Files¶
apps/api-e2e/.eslintrc.json
apps/api-e2e/src/support/global-setup.ts
apps/api-e2e/src/support/global-teardown.ts
Optional New Files¶
apps/api-e2e/src/support/global.d.ts
✅ Validation Checklist¶
- No
eslint-disablecomments in test setup files - ESLint rules properly configured for test files
- Global declarations work without violations
-
pnpm nx lint api-e2epasses -
pnpm nx test api-e2epasses - All E2E tests still function correctly
Final Verification¶
# Lint passes
pnpm nx lint api-e2e
# Tests pass
pnpm nx e2e api-e2e
# No eslint-disable in source files
rg "eslint-disable" apps/api-e2e/src --type ts
END OF PROMPT
This prompt resolves TD-010 from the technical debt register by removing ESLint disable comments and configuring proper rules for test files.