7
votes

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
    }
}
1
place the block inside /* tslint:disable */Aravind
I would suggest what @Aravind is suggesting, but your parent project tslint should not be linting files in node_modules I'm curious how do you lint the parent project? can you post the config file as well as how you trigger it?Ahmed Musallam
@Aravind The problem is I want linting to take place within the separate project seperately. Like I said, this worked fine when the package was install via npm. But it starts kicking out errors when the package in npm linked.Steve Schrab
@AhmedMusallam I added the tsconfig to the question.Steve Schrab
@SteveSchrab what version of tslint do you use? and how do you run it? do you use the tslint-cli? do you use a different utility?Ahmed Musallam

1 Answers

8
votes

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"