简体   繁体   English

你怎么能抑制来自npm链接包的tslint警告?

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

I'm working on a package of Angular/TypeScript components while developing in the app using that package. 我在使用该软件包在应用程序中进行开发时正在开发一个Angular / TypeScript组件包。 I've used npm link to set up the shared components. 我使用npm链接来设置共享组件。 On build, it would seem that tslint kicks off a bunch of warnings for the linked package. 在构建时,似乎tslint为链接包启动了一堆警告。

For example in our tslint.json, we have a prefix of " ta ". 例如,在我们的tslint.json中,我们有一个前缀“ ta ”。 In the package it's " fn ". 在包中它是“ fn ”。 Because we're excluding node_modules in our tsconfig, we never had a problem. 因为我们在tsconfig中排除了node_modules,所以我们从未遇到过问题。 But once we npm linked the package, it's now linting the files in our package as well. 但是一旦我们npm链接了包,它现在也在我们的包中打印文件。 Which then triggers a bunch of warnings in the console on build. 然后,它会在构建时在控制台中触发一堆警告。

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

Any suggestions on suppressing tslint warnings from npm linked packages? 有关从npm链接包中抑制tslint警告的任何建议吗?

Here is my current tsconfig.json file in the parent project: 这是我在父项目中的当前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
}

Here is my tslint file: 这是我的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
    }
}

You can use a inline comment to disable the tslint on that line by 您可以使用内联注释来禁用该行上的tslint

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

To exclude a set of files from being linted, add the below line to the tsconfig file 要排除一组文件,请将以下行添加到tsconfig文件中

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

In your case 在你的情况下

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

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

相关问题 尽管软件包报告了相同的版本,但本地 npm package 和 repo 之间怎么能不匹配? - How can you have a mismatch between a local npm package and repo though the packages report same version? 自动修复 TSLint 警告 - Auto fix TSLint Warnings angular2如何更改组件的默认前缀以停止tslint警告 - angular2 how to change the default prefix of component to stop tslint warnings 解析时:codelyzer@0.0.28 npm ERR:已找到。 tslint@6.1.3 npm 错误。 node_modules/tslint npm 错误! 来自根项目的可选 tslint@"6.1.3" - While resolving: codelyzer@0.0.28 npm ERR! Found: tslint@6.1.3 npm ERR! node_modules/tslint npm ERR! optional tslint@"6.1.3" from the root project 如何打包本地NPM软件包 - How to package local NPM packages 如何在angular导入npm个包? - How to import npm packages in angular? rxjs-tslint 与 rxjs-tslint-rules 包 - rxjs-tslint vs rxjs-tslint-rules packages tslint.json问题“不允许输入”。 如何确保配置符合您在tslint.json上设置的设置 - “type is not allowed” tslint.json issue. How to Ensure the configuration meets with what you set up on tslint.json NPM 无法安装/卸载任何软件包 - NPM can't install/uninstall any packages 由于代理设置,jspm install无法从npm和github下载软件包 - jspm install can't download packages from npm and github due to proxy settings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM