microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.69k stars 323 forks source link

bug: import attributes is not supported #1848

Closed motss closed 1 week ago

motss commented 2 weeks ago

Background

The extension stops working due to the following error:

SyntaxError: Unexpected token 'with'
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:473:14)
    at async link (node:internal/modules/esm/module_job:68:21)
(node:7938) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
(Use `Code Helper (Plugin) --trace-warnings ...` to show where the warning was created)
(node:7938) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time

I suspect this was probably due to the current VS Code 1.89.1 does not support import attributes.

VS Code information

Version: 1.89.1
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:14:32.757Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.89.1 Chrome/120.0.6099.291 Electron/28.2.8 Safari/537.36
dbaeumer commented 1 week ago

I guess it the the node version that doesn't support this that ships by default with VS Code.

However you can point to a locally installed node version using the eslint.runtime setting. If you point to a latest node version will it work for you?

motss commented 1 week ago

TIL eslint.runtime

@dbaeumer Thanks for the suggestion and it works.