【问题标题】:like in VS Code highlighting never used exports?就像在 VS Code 中突出显示从未使用过的导出?
【发布时间】:2023-02-08 17:37:49
【问题描述】:

我在 webShtom 中看到一位同事突出显示未使用的导出,如何在 VS Code 中启用它?

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    屏幕截图几乎显示了您需要的内容:ESLint + TypeScript ESLint plugin + the no-unused-vars lint rule

    最小的 .eslintrc.json 配置文件可能看起来类似于:

    {
        "root": true,
        "extends": [
            "eslint:recommended",
            "plugin:@typescript-eslint/recommended"
        ],
        "parser": "@typescript-eslint/parser",
        "parserOptions": {
        },
        "plugins": [
            "@typescript-eslint"
        ],
        "rules": {
            "@typescript-eslint/no-unused-vars": ["warn"],
        }
    }
    

    请注意,TypeScript 本身支持通过 its noUnusedLocals tsconfig setting 为未使用的局部变量发出警告/错误。

    【讨论】:

      猜你喜欢
      • 2020-03-16
      • 1970-01-01
      • 1970-01-01
      • 2018-02-14
      • 2017-09-04
      • 1970-01-01
      • 1970-01-01
      • 2021-05-13
      • 2021-11-07
      相关资源
      最近更新 更多