简体   繁体   English

如何禁用 TSLint 警告 - 深度导入

[英]How to disable TSLint Warning - deep imports

I am getting this warning when compiling an angular universal app:编译 angular 通用应用程序时收到此警告

Warning: Entry point 'my-module' contains deep imports into '/src/app/mocks/myModule.ts'.警告:入口点“my-module”包含对“/src/app/mocks/myModule.ts”的深度导入。 This is probably not a problem, but may cause the compilation of entry points to be out of order.这可能不是问题,但可能会导致入口点的编译出现乱序。

I have a paths change in tsconfig, which works and is my desired functionality.我在 tsconfig 中有一个路径更改,它有效并且是我想要的功能。 I would like to be able to disable this particular warning.我希望能够禁用此特定警告。 I assume there is some change I can make to tslint.json to allow deep imports all together, or to allow it in this particular case.我假设我可以对tslint.json进行一些更改,以允许一起进行深度导入,或者在这种特殊情况下允许它。

ESlint seems to have nx-enforce-module-boundaries , but I don't think that is applicable to me since this project uses TSLint. ESlint 似乎有nx-enforce-module-boundaries ,但我认为这不适用于我,因为这个项目使用 TSLint。 However, I tried it anyway with no success:但是,无论如何我都尝试过,但没有成功:

{
  "extends": "tslint:recommended",
  "rules": {
    "nx-enforce-module-boundaries": [
      true,
      {
        "allow": [
          ["/src/app/mocks/myModule.ts"]
        ]
      }
    ],
    ...

I can't find anything in TSLint Rules that seem to help me.我在TSLint 规则中找不到任何似乎对我有帮助的东西。 Any ideas?有任何想法吗?

I ended up just using a custom webpack, as I could not figure out how to disable to warning.我最终只使用了自定义 webpack,因为我不知道如何禁用警告。 Webpack has no deep-import warnings: Webpack 没有深度导入警告:

module.exports = {
    plugins: [
        new webpack.NormalModuleReplacementPlugin(/^myModule$/, path.join(__dirname, './src/app/mocks/myModule.mock.server.ts')),
    ]
}

https://github.com/just-jeb/angular-builders/tree/master/packages/custom-webpack https://github.com/just-jeb/angular-builders/tree/master/packages/custom-webpack

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM