Eslint fails to parse and red-highlights optional chaining (?.) and nullish coalescing (??) operators

后端 未结 4 758
离开以前
离开以前 2021-02-05 05:26

I am looking for the relevant eslint rules for

  • @babel/plugin-proposal-optional-chaining
  • @babel/plugin-proposal-nullish-coalescing-operator

4条回答
  •  不思量自难忘°
    2021-02-05 06:17

    You have to use this plugin: https://github.com/babel/eslint-plugin-babel

    You can then disable the original eslint-rule and enable the babel version of it, which will then show no false errors. Your eslint-config could then look like this:

    {
      parser: "babel-eslint",
      rules: {
        "no-unused-expressions": 0,
        "babel/no-unused-expressions": 1
      },
      plugins: ["babel"]
    }
    

提交回复
热议问题