BetaViberTest is in active development — expect breaking changes.
Overview
DocsRulesCircular Dependencies
#004highArchitecture & Structure

Circular Dependencies

Detects circular import chains between modules via DFS graph traversal.

Rule ID:circular-deps

Examples#

BadCircular import chain: A → B → A
// auth.ts
import { getUserRole } from './permissions';
export function isAuthenticated(token: string) {
  const role = getUserRole(token);
  return role !== 'guest';
}

// permissions.ts
import { isAuthenticated } from './auth';  // CIRCULAR!
export function getUserRole(token: string) {
  if (!isAuthenticated(token)) return 'guest';
  return decodeToken(token).role;
}
GoodExtract shared logic to break the cycle
// token.ts — shared, no imports from auth or permissions
export function decodeToken(token: string) {
  return JSON.parse(atob(token.split('.')[1]));
}

// auth.ts
import { decodeToken } from './token';
export function isAuthenticated(token: string) {
  return decodeToken(token).role !== 'guest';
}

// permissions.ts
import { decodeToken } from './token';
export function getUserRole(token: string) {
  return decodeToken(token).role;
}

What It Detects#

highCircular import chain detected (A -> B -> C -> A)
Circular dependency: A -> B -> C -> A

Fix: Break the cycle by extracting shared code to a third module.

Configuration#

This rule is enabled by default. To disable it:

.vibertestrc.jsonjson
{
  "rules": {
    "circular-deps": {
      "enabled": false
    }
  }
}