Tslint: no-implicit-dependencies should consider `paths` compiler option

Created on 31 Jul 2018  路  2Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.11.0
  • __TypeScript version__: 2.9.2
  • __Running TSLint via__: CLI

TypeScript code being linted

import foo from "bar/foo";

with tslint.json configuration:

{
    "defaultSeverity": "error",
    "rules": {
        "no-implicit-dependencies": [true, "dev"]
    }
}

Actual behavior

ERROR: /Users/elena/Projects/demo/ts/main.ts[1, 17]: Module 'bar' is not listed as dependency in package.json

tsconfig

{
  "compilerOptions": {
    "module": "commonjs", 
    "lib": ["es2017"],
    "strict": true,

    "baseUrl": "./",
    "paths": {
      "bar/*":["src/bar/*"]
    },   
  }
}

Expected behavior

Rule should be able to look into tsconfig and check if imported module matches one of the paths mapping. I think it can be parametrised behaviour.

Rule Enhancement

Most helpful comment

It's not a duplicate, it should automatically white-list everything that is listed in tsconfig paths

All 2 comments

Seems to be a duplicate of https://github.com/palantir/tslint/issues/3483 Refer to solution in that thread.

It's not a duplicate, it should automatically white-list everything that is listed in tsconfig paths

Was this page helpful?
0 / 5 - 0 ratings