CRA optional chaining not working even with react-script 3.4.3

361 views Asked by At

Optional chaining is not working in CRA even with react-script 3.4.3 e.g.

modelClass.withId(payload.modelRef.id)?.delete();

throws the following error: Expected an assignment or function call and instead saw an expression no-unused-expressions

Dependencies:

    "@reduxjs/toolkit": "^1.4.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "antd": "^4.6.6",
    "axios": "^0.20.0",
    "js-cookie": "^2.2.1",
    "moment": "^2.29.1",
    "node-sass": "^4.14.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.2.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.3",
    "redux-orm": "^0.16.2",
    "source-map-explorer": "^2.5.0"
  },

I am using Redux template of CRA. Any solution?

1

There are 1 answers

0
Prateek On

You might have missed adding "parser": "babel-eslint" into your package.json file as eslintConfig:

    "eslintConfig": {
        "extends": "react-app",
        "parser": "babel-eslint"
    },