简体   繁体   English

如何在 Tslint ot tsconfig 中禁用深度导入?

[英]How to disable deep import in Tslint ot tsconfig?

How to disable deep import in tsconfig?如何在 tsconfig 中禁用深度导入?

I want to restrict import deeper that library path: import { * } from '@geo/map-lib';我想更深入地限制导入该库路径: import { * } from '@geo/map-lib';

I have tried this, but it is still allow use it like @geo/map-lib/src/...我已经尝试过了,但它仍然允许像@geo/map-lib/src/...

{
    "extends": "../../tslint.json",
    "rules": {
        "import-blacklist": [true, "@geo/map-lib"],
        "directive-selector": [true, "attribute", "lib", "camelCase"],
        "component-selector": [true, "element", "lib", "kebab-case"]
    }
}

Not sure we share the same goal, but this works for me:不确定我们是否有相同的目标,但这对我有用:

    "import-blacklist": [
      true,
      [
        "rxjs/Rx",
        ".*projects/.*",
        ".*observations-library/.*"
      ]

Result (in WebStorm):结果(在 WebStorm 中): 在此处输入图像描述

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

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