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?
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.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too