1

我有很多 ESLint 警告,我注意到我的 VSCode 没有在我的代码中显示它们。它仅在我的反应应用程序的控制台日志中可见。我在 VSCode 中检查了 ESLint 的输出,它说:

[信息 - 下午 2:43:19] package.json » eslint-config-react-app 中的 ESLint 配置无效:- 属性“覆盖”是错误的类型(预期的数组,但得到了{"files":["**/*.ts","**/*.tsx"],"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":2018,"sourceType":"module","ecmaFeatures":{"jsx":true},"warnOnUnsupportedTypeScriptVersion":true},"plugins":["@typescript-eslint"],"rules":{"default-case":"off","no-dupe-class-members":"off","@typescript-eslint/no-angle-bracket-type-assertion":"warn","no-array-constructor":"off","@typescript-eslint/no-array-constructor":"warn","@typescript-eslint/no-namespace":"error","no-unused-vars":"off","@typescript-eslint/no-unused-vars":["warn",{"args":"none","ignoreRestSiblings":true}],"no-useless-constructor":"off","@typescript-eslint/no-useless-constructor":"warn"}})。引用自:C:\Users\(my-name)\(my-app)\package.json

{
    "name": "(my-app-name)",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@azure/cognitiveservices-qnamaker": "^3.1.0",
        "@azure/ms-rest-azure-js": "^2.0.1",
        "@microsoft/microsoft-graph-client": "^2.0.0",
        "@types/jest": "^25.2.1",
        "@types/node": "^13.13.4",
        "@types/react": "^16.9.34",
        "@types/react-bootstrap-typeahead": "^3.4.5",
        "@types/react-dom": "^16.9.7",
        "@types/reactstrap": "^8.4.2",
        "adaptivecards": "^1.2.3",
        "axios": "^0.19.2",
        "bootstrap": "^4.1.3",
        "date-fns": "^2.12.0",
        "dotenv": "^8.2.0",
        "fusioncharts": "^3.15.1",
        "jquery": "^3.5.0",
        "luis-node-sdk": "^1.0.0",
        "merge": "^1.2.1",
        "msal": "^1.3.0",
        "ncp": "^2.0.0",
        "oidc-client": "^1.10.1",
        "promise.allsettled": "^1.0.2",
        "react": "^16.13.1",
        "react-app-polyfill": "^1.0.6",
        "react-bootstrap": "^1.0.1",
        "react-bootstrap-table": "^4.3.1",
        "react-bootstrap-typeahead": "^3.4.7",
        "react-datepicker": "^2.14.1",
        "react-dom": "^16.13.1",
        "react-fusioncharts": "^3.1.2",
        "react-router-bootstrap": "^0.24.4",
        "react-router-dom": "^5.1.2",
        "react-scripts": "^3.4.1",
        "reactstrap": "^8.4.1",
        "rimraf": "^2.6.2"
    },
    "devDependencies": {
        "@microsoft/microsoft-graph-types": "^1.12.0",
        "@types/promise.allsettled": "^1.0.3",
        "ajv": "^6.12.2",
        "cross-env": "^5.2.0",
        "eslint-config-react-app": "^4.0.1",
        "eslint-plugin-flowtype": "^2.0.0",
        "eslint-plugin-import": "^2.20.2",
        "eslint-plugin-jsx-a11y": "^6.2.1",
        "eslint-plugin-react": "^7.19.0",
        "typescript": "^3.8.3"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "scripts": {
        "start": "rimraf ./build && react-scripts start",
        "test": "cross-env CI=true react-scripts test --env=jsdom",
        "eject": "react-scripts eject",
        "lint": "eslint ./src/",
        "build": "react-scripts build",
        "publish-qa": "node tasks/publish-qa.js",
        "publish-production": "node tasks/publish-prod.js"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ]
    },
    "homepage": "."
}
4

1 回答 1

-1

我通过从 eslint 6.7.2 升级到 6.8.0 解决了这个问题

所以,本质上npm install eslint --save

从包含你的 package.json 文件的目录中运行它,看看它是如何运行的。

于 2020-07-07T00:49:05.307 回答