I'm working on a package of Angular/TypeScript components while developing in the app using that package. I've used npm link to set up the shared components. On build, it would seem that tslint kicks off a bunch of warnings for the linked package.
For example in our tslint.json, we have a prefix of "ta
". In the package it's "fn
". Because we're excluding node_modules in our tsconfig, we never had a problem. But once we npm linked the package, it's now linting the files in our package as well. 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?
Here is my current tsconfig.json file in the parent project:
{
"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:
{
"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
}
}
Place the cursor at an error or a warning reported by TSLint and press Alt+Enter . Select the quick-fix for the rule that you want to disable and press Right .
In addition to global configuration, you may also enable/disable linting for a subset of lint rules within a file with the following comment rule flags: /* tslint:disable */ - Disable all rules for the rest of the file. /* tslint:enable */ - Enable all rules for the rest of the file.
TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.
You can use a inline comment to disable the tslint on that line by
selector: 'component',// tslint:disable-line
To exclude a set of files from being linted, add the below line to the tsconfig file
"tslint.exclude": "**/folder/**/*.ts"
In your case
"tslint.exclude": "**/fn-library/**/*.ts"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With