我正在使用该软件包在应用程序中进行开发时处理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
}
}
答案 0 :(得分:7)
您可以使用内联注释通过
禁用该行上的tslint<select name="stateName">
<option value=""></option>
<?php $states = $location->getStates($countryCode);
foreach ($states as $state) {
echo '<option value="' . $state->id . '">' . $state->name . '</option>';
}
?>
</select>
要排除一组文件,请将以下行添加到tsconfig文件
selector: 'component',// tslint:disable-line
在你的情况下
"tslint.exclude": "**/folder/**/*.ts"