BetaViberTest is in active development — expect breaking changes.
Overview
#002highArchitecture & Structure
God File
Detects files with too many responsibilities — the "does everything" file.
Rule ID:
god-fileExamples#
Badutils.ts — 15 exports, mixed concerns
// utils.ts — the "everything" file
export function formatDate(d: Date) { /* ... */ }
export function formatCurrency(n: number) { /* ... */ }
export function validateEmail(s: string) { /* ... */ }
export function validatePhone(s: string) { /* ... */ }
export function fetchUser(id: string) { /* ... */ }
export function fetchProducts() { /* ... */ }
export function calculateTax(amount: number) { /* ... */ }
export function calculateDiscount(price: number) { /* ... */ }
export function sendEmail(to: string, body: string) { /* ... */ }
export function sendSMS(to: string, msg: string) { /* ... */ }
export function parseCSV(data: string) { /* ... */ }
export function generatePDF(html: string) { /* ... */ }
export const API_URL = "https://api.example.com";
export const TAX_RATE = 0.19;
export type User = { id: string; name: string; };GoodSplit by responsibility
// lib/formatters.ts
export function formatDate(d: Date) { /* ... */ }
export function formatCurrency(n: number) { /* ... */ }
// lib/validators.ts
export function validateEmail(s: string) { /* ... */ }
export function validatePhone(s: string) { /* ... */ }
// services/user-service.ts
export function fetchUser(id: string) { /* ... */ }
// services/product-service.ts
export function fetchProducts() { /* ... */ }
// lib/pricing.ts
export function calculateTax(amount: number) { /* ... */ }
export function calculateDiscount(price: number) { /* ... */ }What It Detects#
highFile has >10 exports, mixed concerns, and high import fan-in (2+ signals)
God file detected: too many exports, mixed concerns, high fan-in
Fix: Split by responsibility using the Single Responsibility Principle. Each module should do one thing well.
Exclusions#
The following are automatically excluded from this rule:
- Test files
- Barrel/index files
- .d.ts files
Configuration#
This rule is enabled by default. To disable it:
.vibertestrc.jsonjson
{
"rules": {
"god-file": {
"enabled": false
}
}
}Learn more: refactoring.guru/smells/large-class