Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make ESLint understand the new import assertion syntax without adding Babel?

Since the import assertion syntax (e.g. assert {type: 'json'}) is mandatory in the latest Node.js versions, I'm looking for a way to be able to write this new syntax, but I don't want to add Babel just to be able to use the Babel ESLint parser which understands it.

Could this be added by a different ESLint plugin?

like image 388
dennis Avatar asked Jan 25 '26 15:01

dennis


1 Answers

You have to use the babel eslint parser for that

npm i -D @babel/eslint-parser @babel/plugin-syntax-import-assertions

then in .eslintrc

  "parser": "@babel/eslint-parser",
  "parserOptions": {
    "requireConfigFile": false,
    "babelOptions": {
      "plugins": [
        "@babel/plugin-syntax-import-assertions"
      ]
    }
  },
like image 198
Sceat Avatar answered Jan 28 '26 04:01

Sceat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!