Skip to content

Conversation

@utact
Copy link

@utact utact commented Dec 14, 2025

Summary

This PR fixes the TypeError: Converting circular structure to JSON error affecting local linting and CI, and completes the migration to ESLint 9's Flat Config format with full TypeScript support.

Problem Analysis

The current eslint.config.mjs uses FlatCompat to extend next/core-web-vitals.
In the current version of eslint-config-next + ESLint 9, FlatCompat creates a circular reference within the internal plugin configuration (specifically related to react-hooks), causing the config validator to crash with a JSON serialization error.

Additionally, the previous configuration relied on the default parser, which could cause parsing errors in TypeScript files (.ts, .tsx).

$ npx eslint .

Oops! Something went wrong! :(

ESLint: 9.39.1

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'flat' -> object with constructor 'Object'
    |     ...
    |     property 'plugins' -> object with constructor 'Object'
    --- property 'react' closes the circle

ConfigData (node_modules/@eslint/eslintrc/lib/config-array-factory.js:676:19)
    at ConfigArrayFactory._loadConfigData (node_modules/@eslint/eslintrc/lib/config-array-factory.js:641:21)

Solution

I have refactored eslint.config.mjs to use a native Flat Config approach (Plugin Composition) instead of FlatCompat.

  1. Removed FlatCompat: Avoids the circular dependency issue entirely by manually composing plugins.
  2. Added typescript-eslint: Integrated tseslint.config() to ensure proper parsing and type-checking for TypeScript files.
  3. Updated Script: Changed "lint": "next lint" to "lint": "eslint ." in package.json (aligned with Next.js 16 breaking changes).
  4. Explicit Dependencies: Added @next/eslint-plugin-next, eslint-plugin-react, etc., to devDependencies to support the new config structure.

Verification

  • Ran npm run lint locally -> Passed (No circular errors, correct linting).
  • Verified that .next and node_modules are correctly ignored.

This change should resolve the linting issues in the CI pipeline as well.

- Fix 'TypeError: Converting circular structure to JSON' by replacing FlatCompat with direct plugin composition.
- Add 'typescript-eslint' to support proper TypeScript parsing in Flat Config.
- Update 'lint' script to 'eslint .' as 'next lint' is deprecated in Next.js 16.
- Explicitly add required ESLint plugins to devDependencies.
@netlify
Copy link

netlify bot commented Dec 14, 2025

👷 Deploy request for opensourcebuilders pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c050e50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant