【问题标题】:How to define exceptions for nx-lint?如何定义 nx-lint 的异常?
【发布时间】:2020-04-30 14:49:27
【问题描述】:

我有一个自述文件,其中包含文件夹的文档、包含的库以及如何使用它们。

自述文件不是任何库的一部分,因此 nx-lint 会抛出此错误:

 NX   ERROR  The following file(s) do not belong to any projects:   
    - libs/global/README.md

我们怎样才能抑制这个错误?

注意事项:

  • 我不想将文件移动到 lib - 文件就在它现在所在的位置。
  • 我不想在自述文件中添加可见的内容
  • 理想情况下,我们只抑制此文件的特定错误

我尝试在顶级 tslint.json 中使用 exclude,如下所示:

{
   "exclude": [
      "libs/global/*.md"
    ],

【问题讨论】:

    标签: lint nrwl-nx


    【解决方案1】:

    您可以使用项目根目录中的文件.nxignore 来解决此问题:

    $ yarn lint
    yarn run v1.22.4
    $ nx workspace-lint && nx lint
    
    >  NX   ERROR  The following file(s) do not belong to any projects:
    
      - libs/global/README.md
    
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
    $ echo libs/global/README.md >> .nxignore
    
    $ yarn lint
    yarn run v1.22.4
    $ nx workspace-lint && nx lint
    
    Linting "server"...
    
    All files pass linting.
    
    ✨  Done in 2.45s.
    

    【讨论】:

    • @Danziger 尝试将 nx 更新到最新版本 - 有一个带有 nxignore 的 issue#3453 已在 10.0.13 中修复
    • @TmTron 我已经在使用最新版本,但我的问题来自不同的地方:我有一个同名的库和一个应用程序,所以workspace.json 中有一个条目.通过重命名其中一个并添加缺少的条目来修复它。
    猜你喜欢
    • 2020-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多