---
title: ESLint FlatCompat + eslint-config-next v16 — Circular Reference Crash
source: daily/2026-05-10.md
updated: 2026-05-10
tags: [eslint, next.js, config, flat-config]
---

# ESLint FlatCompat + eslint-config-next v16 — Circular Reference Crash

## The Problem

Wrapping `eslint-config-next` with `FlatCompat` from `@eslint/eslintrc` causes a `"circular reference"` crash in ESLint's flat config system.

```
Error: Circular reference detected
    at FlatCompat.extends (...)
```

This blocks the pre-commit hook (or any direct ESLint run) completely.

## Root Cause

`eslint-config-next` v16+ already exports native flat config. When `FlatCompat` attempts to wrap it, the config tries to extend itself via the compatibility layer, creating a circular dependency.

## Fix

Remove `FlatCompat` entirely. Import `eslint-config-next` directly:

```js
// eslint.config.mjs — WRONG (pre v16 pattern)
import { FlatCompat } from '@eslint/eslintrc'
const compat = new FlatCompat({ baseDirectory: import.meta.dirname })
export default [
  ...compat.extends('next/core-web-vitals'),
]

// eslint.config.mjs — CORRECT (v16+)
import nextConfig from 'eslint-config-next'
export default [
  ...nextConfig,
  // project-specific overrides
]
```

## Key Points

- `eslint-config-next` v16 ships flat config natively — `FlatCompat` is not only unnecessary but harmful
- The crash manifests as `"circular reference"` with no indication that the config itself is the culprit
- `next lint` is also removed in Next.js 16 — run `npx eslint .` directly
- Pre-commit ESLint hooks will block all commits until the config is fixed; check ESLint independently before stashing

## Diagnostic Signal

```
TypeError: Cannot read properties of undefined (reading 'circular')
```
or simply `"circular reference"` in the ESLint output when running against a Next.js 16 project.
