簡體   English   中英

你怎么能抑制來自npm鏈接包的tslint警告?

[英]How can you suppress tslint warnings from npm linked packages?

我在使用該軟件包在應用程序中進行開發時正在開發一個Angular / TypeScript組件包。 我使用npm鏈接來設置共享組件。 在構建時,似乎tslint為鏈接包啟動了一堆警告。

例如,在我們的tslint.json中,我們有一個前綴“ ta ”。 在包中它是“ fn ”。 因為我們在tsconfig中排除了node_modules,所以我們從未遇到過問題。 但是一旦我們npm鏈接了包,它現在也在我們的包中打印文件。 然后,它會在構建時在控制台中觸發一堆警告。

WARNING in ../fn-library/src/popover/popover.component.ts
[10, 15]: The selector of the component "PopoverComponent" should have prefix "ta"

有關從npm鏈接包中抑制tslint警告的任何建議嗎?

這是我在父項目中的當前tsconfig.json文件:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "noEmit": true,
        "noEmitHelpers": true,
        "strictNullChecks": false,
        "importHelpers": true,
        "baseUrl": "./src",
        "paths": [],
        "lib": [
            "dom",
            "es6"
        ],
        "typeRoots": [
            "node_modules/@types"
        ],
        "types": [
            "jasmine",
            "node"
        ]
    },
    "exclude": [
        "node_modules/**/*",
        "dist/**/*"
    ],
    "angularCompilerOptions": {
        "skipMetadataEmit": true
    },
    "compileOnSave": false,
    "buildOnSave": false
}

這是我的tslint文件:

{
    "rulesDirectory": [
        "node_modules/codelyzer"
    ],
    "rules": {
        "directive-selector": [
            true,
            "attribute",
            "ta",
            "camelCase"
        ],
        "component-selector": [
            true,
            "element",
            "ta",
            "kebab-case"
        ],
        "use-input-property-decorator": true,
        "use-output-property-decorator": true,
        "use-host-property-decorator": true,
        "no-attribute-parameter-decorator": true,
        "no-input-rename": true,
        "no-output-rename": true,
        "no-forward-ref": true,
        "use-life-cycle-interface": true,
        "use-pipe-transform-interface": true,
        "pipe-naming": [
            true,
            "camelCase",
            "ta"
        ],
        "component-class-suffix": true,
        "directive-class-suffix": true,
        "import-destructuring-spacing": true
    }
}

您可以使用內聯注釋來禁用該行上的tslint

selector: 'component',// tslint:disable-line

要排除一組文件,請將以下行添加到tsconfig文件中

"tslint.exclude": "**/folder/**/*.ts"

在你的情況下

"tslint.exclude": "**/fn-library/**/*.ts"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM