#20237·eslint

Bug: Converting circular structure to JSON when showing config error

Author: jcubicCreated Oct 22, 2025Updated Sep 27, 2026
Labelsbugrepro:needed

Environment

Node version: v24.7.0 npm version: 11.6.1 Local ESLint version: 9.36.0 Global ESLint version: none Operating System: Fedora 42 GNU/Linux

What parser are you using?

Default (Espree)

What did you do?

Got this error after upgrade to Next 16. The error in Next config triggers a crash in ESLint error handling, while attempting to show the error.

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

Error came from error handler:

javascript
            if (error.keyword === "type") {
              const formattedField = error.dataPath.slice(1);
              const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
              const formattedValue = JSON.stringify(error.data);

              return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
            }

My config:

javascript
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
  baseDirectory: __dirname
});

const eslintConfig = [
  ...compat.extends('next/core-web-vitals', 'next/typescript'),
  {
    rules: {
      '@typescript-eslint/no-empty-object-type': 'off',
      '@typescript-eslint/no-unused-vars': ['warn', { caughtErrors: 'none' }]
    }
  },
  {
    ignores: [
      'node_modules/**',
      '.next/**',
      'out/**',
      'build/**',
      'coverage/**',
      'next-env.d.ts',
      'prisma/generated/**',
      'prisma/migrations/**',
      'migration.js'
    ]
  }
];

export default eslintConfig;

This is the output of the error.data:

[
  {
    name: 'next',
    files: [ '**/*.{js,jsx,mjs,ts,tsx,mts,cts}' ],
    plugins: {
      react: [Object],
      'react-hooks': [Object],
      import: [Object],
      'jsx-a11y': [Object: null prototype],
      '@next/next': [Object]
    },
    languageOptions: { parser: [Object], parserOptions: [Object], globals: [Object] },
    settings: {
      react: [Object],
      'import/parsers': [Object],
      'import/resolver': [Object]
    },
    rules: {
      'react/display-name': 2,
      'react/jsx-key': 2,
      'react/jsx-no-comment-textnodes': 2,
      'react/jsx-no-duplicate-props': 2,
      'react/jsx-no-target-blank': 'off',
      'react/jsx-no-undef': 2,
      'react/jsx-uses-react': 2,
      'react/jsx-uses-vars': 2,
      'react/no-children-prop': 2,
      'react/no-danger-with-children': 2,
      'react/no-deprecated': 2,
      'react/no-direct-mutation-state': 2,
      'react/no-find-dom-node': 2,
      'react/no-is-mounted': 2,
      'react/no-render-return-value': 2,
      'react/no-string-refs': 2,
      'react/no-unescaped-entities': 2,
      'react/no-unknown-property': 'off',
      'react/no-unsafe': 0,
      'react/prop-types': 'off',
      'react/react-in-jsx-scope': 'off',
      'react/require-render-return': 2,
      'react-hooks/rules-of-hooks': 'error',
      'react-hooks/exhaustive-deps': 'warn',
      'react-hooks/static-components': 'error',
      'react-hooks/use-memo': 'error',
      'react-hooks/component-hook-factories': 'error',
      'react-hooks/preserve-manual-memoization': 'error',
      'react-hooks/incompatible-library': 'warn',
      'react-hooks/immutability': 'error',
      'react-hooks/globals': 'error',
      'react-hooks/refs': 'error',
      'react-hooks/set-state-in-effect': 'error',
      'react-hooks/error-boundaries': 'error',
      'react-hooks/purity': 'error',
      'react-hooks/set-state-in-render': 'error',
      'react-hooks/unsupported-syntax': 'warn',
      'react-hooks/config': 'error',
      'react-hooks/gating': 'error',
      '@next/next/google-font-display': 'warn',
      '@next/next/google-font-preconnect': 'warn',
      '@next/next/next-script-for-ga': 'warn',
      '@next/next/no-async-client-component': 'warn',
      '@next/next/no-before-interactive-script-outside-document': 'warn',
      '@next/next/no-css-tags': 'warn',
      '@next/next/no-head-element': 'warn',
      '@next/next/no-html-link-for-pages': 'warn',
      '@next/next/no-img-element': 'warn',
      '@next/next/no-page-custom-font': 'warn',
      '@next/next/no-styled-jsx-in-document': 'warn',
      '@next/next/no-sync-scripts': 'warn',
      '@next/next/no-title-in-document-head': 'warn',
      '@next/next/no-typos': 'warn',
      '@next/next/no-unwanted-polyfillio': 'warn',
      '@next/next/inline-script-id': 'error',
      '@next/next/no-assign-module-variable': 'error',
      '@next/next/no-document-import-in-page': 'error',
      '@next/next/no-duplicate-head': 'error',
      '@next/next/no-head-import-in-document': 'error',
      '@next/next/no-script-component-in-head': 'error',
      'import/no-anonymous-default-export': 'warn',
      'jsx-a11y/alt-text': [Array],
      'jsx-a11y/aria-props': 'warn',
      'jsx-a11y/aria-proptypes': 'warn',
      'jsx-a11y/aria-unsupported-elements': 'warn',
      'jsx-a11y/role-has-required-aria-props': 'warn',
      'jsx-a11y/role-supports-aria-props': 'warn'
    }
  },
  {
    name: 'next/typescript',
    files: [ '**/*.ts', '**/*.tsx' ],
    plugins: { '@typescript-eslint': [Object] },
    languageOptions: { parser: [Object], parserOptions: [Object] }
  },
  { ignores: [ '.next/**', 'out/**', 'build/**', 'next-env.d.ts' ] },
  {
    name: 'next/core-web-vitals',
    plugins: { '@next/next': [Object] },
    rules: {
      '@next/next/google-font-display': 'warn',
      '@next/next/google-font-preconnect': 'warn',
      '@next/next/next-script-for-ga': 'warn',
      '@next/next/no-async-client-component': 'warn',
      '@next/next/no-before-interactive-script-outside-document': 'warn',
      '@next/next/no-css-tags': 'warn',
      '@next/next/no-head-element': 'warn',
      '@next/next/no-html-link-for-pages': 'error',
      '@next/next/no-img-element': 'warn',
      '@next/next/no-page-custom-font': 'warn',
      '@next/next/no-styled-jsx-in-document': 'warn',
      '@next/next/no-sync-scripts': 'error',
      '@next/next/no-title-in-document-head': 'warn',
      '@next/next/no-typos': 'warn',
      '@next/next/no-unwanted-polyfillio': 'warn',
      '@next/next/inline-script-id': 'error',
      '@next/next/no-assign-module-variable': 'error',
      '@next/next/no-document-import-in-page': 'error',
      '@next/next/no-duplicate-head': 'error',
      '@next/next/no-head-import-in-document': 'error',
      '@next/next/no-script-component-in-head': 'error'
    }
  }
]

the error:

{
  keyword: 'type',
  dataPath: '',
  schemaPath: '#/type',
  params: { type: 'object' },
  message: 'should be object',
  schema: 'object',
  parentSchema: {
    type: 'object',
    properties: {
      root: [Object],
      ignorePatterns: [Object],
      '$schema': [Object],
      env: [Object],
      extends: [Object],
      globals: [Object],
      overrides: [Object],
      parser: [Object],
      parserOptions: [Object],
      plugins: [Object],
      processor: [Object],
      rules: [Object],
      settings: [Object],
      noInlineConfig: [Object],
      reportUnusedDisableDirectives: [Object],
      ecmaFeatures: [Object]
    },
    additionalProperties: false
  },
  data: [ ... ]
}

There seems to be two errors something is not compatible, and ESLint should not serialize the config if it has cycles.

What did you expect to happen?

I expect an error message if the config is wrong

What actually happened?

Got crash on circular config

Link to Minimal Reproducible Example

https://github.com/jcubic/10xDevs/tree/eslint

This is not minimal, but only config file and package.json are relevant, you can ignore the rest:

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

I can create a fix, but I'm not sure what is the best approach or what you would like to do in case of this error in config.