Skip to content

Extending eslint-plugin-svelte/recommended throws a Converting circular structure to JSON error #773

Open
@GeoffreyBooth

Description

Using "extends": "plugin:eslint-plugin-svelte/recommended" with [email protected] throws a Converting circular structure to JSON error. Perhaps something related to legacy vs flat config?

Steps to reproduce

Create a new blank SvelteKit app and answer the prompts as shown:

npx sv create app
┌  Welcome to the Svelte CLI! (v0.6.10)
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with Typescript?
│  No
│
◆  Project created
│
◇  What would you like to add to your project? (use arrow keys / space bar)
│  none
│
◇  Which package manager do you want to install dependencies with?
│  npm

Now add xo:

cd app
npm install xo --save-dev
npm init xo
npx xo # Runs successfully, and reports 9 lint errors

So far so good, but we aren’t linting Svelte files yet. Let’s add eslint-plugin-svelte@next (the @next is for Svelte 5 support) and configure xo to use it:

npm install --save-dev eslint-plugin-svelte@next
touch .xo-config.json

Edit the newly created .xo-config.json to include the following, adapted from https://github.com/sveltejs/eslint-plugin-svelte#configuration:

{
	"extensions": ["svelte"],
	"plugins": ["svelte"],
	"overrides": [
		{
			"files": "**/*.svelte",
			"extends": "plugin:eslint-plugin-svelte/recommended",
			"processor": "svelte/svelte",
			"envs": ["browser"]
		}
	]
}

Now npx xo returns:

/private/tmp/app/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156
                const formattedValue = JSON.stringify(error.data);
                                            ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'plugins' -> object with constructor 'Object'
    |     property 'svelte' -> object with constructor 'Module'
    |     ...
    |     property 'base' -> object with constructor 'Array'
    --- index 0 closes the circle
Referenced from: BaseConfig

Removing the "extends": "plugin:eslint-plugin-svelte/recommended" line makes the error go away, but linting of Svelte files breaks.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions