-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use with current Visual Studio Code, which is running Node 20.18.1? #1002
Comments
I think you need to use eslint-plugin-svelte v2 with xo or use ESLint directly. Already ESLint v8 is EOL, therefore we don't have a plan to support this. |
The issue with eslint-plugin-svelte v2 is that it doesn’t support Svelte 5 syntax. And even though ESLint 8 is EOL, ESLint 9 is also CommonJS-only and I would expect has the same issue. I discovered that while I can’t change the version of Node that VS Code runs, https://github.com/xojs/vscode-linter-xo has an option So perhaps all that’s necessary is to mention in your documentation that if folks encounter an |
We don't get any issue on VSCode (with Node.js 20.18.1) if we use ESLint directly, and ESLint supports node https://github.com/eslint/eslint/blob/main/package.json#L217 |
Thank you for posting this issue. Our plugin v3 dropped support for legacy configs. |
Before You File a Bug Report Please Confirm You Have Done The Following...
What version of ESLint are you using?
8.57.1
What version of
eslint-plugin-svelte
are you using?3.0.0-next.10
What did you do?
I’m building a SvelteKit app with Svelte 5, using
xo
as my linter. Sincexo
has its own custom config file format, it took some trial and error before I found a configuration that would let me use[email protected]
withxo
, but eventually I did: xojs/xo#773 (comment).My issue is that while this works on the command line with Node 23.6.0, it doesn’t work within Visual Studio Code and with the https://github.com/xojs/vscode-linter-xo extension. I think the issue is that the version of Node within VS Code as of today is 20.18.1, which doesn’t have unflagged support for
require
of ES modules; and as far as I’m aware there’s no way (short of creating my own custom build of VS Code) to change VS Code’s internal Node version or what flags get passed to it. The specific error I get isFailed to load plugin 'svelte' declared in 'BaseConfig': require() of ES Module /private/tmp/app/node_modules/eslint-plugin-svelte/lib/index.js from /private/tmp/app/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported.
Working my way back up the call stack, I think this error is because
eslint-plugin-svelte
is ESM-only; and while@eslint/eslintrc
is dual-published CommonJS/ESM, its parenteslint
is CommonJS-only and therefore the CommonJS version of@eslint/eslintrc
is what gets loaded. In Node 23.6.0, it canrequire
eslint-plugin-svelte
; but in Node 20.18.1, with default Node flags, it can’t.I saw #885; presumably this was intended to drop support for the versions without
require(esm)
support? I think the effect of that PR is that you dropped support for Node versions that couldrequire
ESM files, but some of the older Node versions need the--experimental-require-module
flag to be passed. I can’t seem to find a way to enable that in the internal Node.js instance that VS Code creates to run extensions.What did you expect to happen?
I expect there to be some way to load
eslint-plugin-svelte
in Node 20.18.1 without needing to pass Node runtime flags.What actually happened?
Link to GitHub Repo with Minimal Reproducible Example
https://github.com/GeoffreyBooth/eslint-plugin-svelte-issue
Additional comments
I understand if you don’t support
xo
or the legacyeslint
config file format, but I would think that the issue I’ve described here probably affects regulareslint
and any Visual Studio Codeeslint
plugin that tries to loadeslint-plugin-svelte
.Per electron/electron#44630 and https://www.electronjs.org/docs/latest/tutorial/electron-timelines#nodejs-version-support, Electron should upgrade to Node 22 sometime in the next few months. But per https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require, the feature is still flagged in current latest 22.x releases of Node.
The text was updated successfully, but these errors were encountered: