忽略来自特定 eslint 插件的特定文件

Ignore specific file from specific eslint plugin

我正在使用 eslint-plugin-tsdoc 效果很好,除了我不需要 linting 的文件,例如,任何使用 apidoc 而不是 tsdoc 的 api 路由评论风格。

这会在 运行 任何 linting 时导致错误。无论如何,我可以忽略 eslint-plugin-tsdoc 的文件吗?我不想通过 eslint 完全忽略该文件,因为我仍然需要检查打字稿。

您可以在 .eslintrc 文件中使用覆盖 属性。 Using configuration files to disable for a group of files

因为eslint-plugin-tsdoc只有一个规则tsdoc/syntax

您需要将其添加到您的 .eslintrc 文件中。

{
  "rules": {...},
  "overrides": [
    {
      "files": ["*.test.ts", "/src/demo.ts"],
      "rules": {
        "tsdoc/syntax": "off"
      }
    }
  ]
}

因此在上面的示例中,它将禁用所有以 .test.ts 结尾的文件和文件 /src/demo.ts 的规则,并对其余文件应用此规则。