首页 > 解决方案 > vscode 没有显示 linting 警告

问题描述

我制作了一个打字稿反应应用程序,我想使用我的 eslintrc 文件在 vs 代码中对我的文件进行 lint,但警告没有出现在 ide 中。

我的 eslintrc:

{
    "extends": ["react-app"],
    "rules": {
      "space-infix-ops": ["warn", { "int32Hint": false }],
      "semi": ["warn", "never"],
      "quotes": ["warn", "single"],
      "jsx-quotes": ["warn", "prefer-single"],
      "no-trailing-spaces": ["warn"],
      "comma-dangle": ["warn", "never"],
      "space-before-function-paren": ["warn", "never"],
      "space-before-blocks": "warn",
      "keyword-spacing": ["warn", { "after": true, "before": true, 
        "overrides": { 
          "if": { "after": false },
          "else": { "after": true },
          "switch": { "after": false },
          "case": {"after": true },
          "for": { "after": false }
          }
        }
      ],
      "key-spacing": [ "warn", { "afterColon": true }],
      "no-multi-spaces": ["warn"],
      "no-console": ["warn"]
    }
  }

我的settings.json:

{
    "editor.fontSize": 15,
    "eslint.enable": true,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        { "language": "typescript", "autoFix": true },
        { "language": "typescriptreact", "autoFix": true }
    ],
}

输出选项卡:

[Info  - 6:07:05 PM] ESLint server stopped.
[Info  - 6:07:05 PM] ESLint server running in node v8.9.3
[Info  - 6:07:05 PM] ESLint server is running.
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token {
(node:622) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 10): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 11): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 13): SyntaxError: Unexpected token {
(node:622) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 14): SyntaxError: Unexpected token {

我确实安装了 eslint 扩展。

我在本地为项目安装了 eslintnpm install eslint --save-dev

我已经用谷歌搜索并查看了其他人的问题,但似乎无法让它为我工作。任何正确方向的帮助将不胜感激。

谢谢

标签: javascriptreactjseslint

解决方案


检查Output屏幕下半部分的选项卡。从下拉列表中选择 ESLint。或者在 Windows 上使用快捷方式:++ ctrl。所有 ESLint 服务器输出都被绘制在那里。shiftU


推荐阅读