1

即使使用 react-script 3.4.3,可选链接在 CRA 中也不起作用,例如

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

引发以下错误: Expected an assignment or function call and instead saw an expression no-unused-expressions

依赖项:

    "@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"
  },

我正在使用 CRA 的 Redux 模板。有什么解决办法吗?

4

1 回答 1

1

您可能错过了将"parser": "babel-eslint"package.json 作为 eslintConfig 添加到文件中:

    "eslintConfig": {
        "extends": "react-app",
        "parser": "babel-eslint"
    },
    
于 2020-10-20T09:25:07.957 回答