Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

tslint ignores tsconfig.json extends property #2673

Closed
diegovilar opened this issue May 3, 2017 · 7 comments
Closed

tslint ignores tsconfig.json extends property #2673

diegovilar opened this issue May 3, 2017 · 7 comments

Comments

@diegovilar
Copy link

diegovilar commented May 3, 2017

Bug Report

  • TSLint version: 5.1.0
  • TypeScript version: 2.3.2
  • Running TSLint via: CLI

TypeScript code being linted

test/test.ts

export class test {
}

tslint.json

{
  "rules": {
    "class-name": true
  }
}

tsconfig.json

{
  "compilerOptions": {
    "...": "..."
  },
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ]
}

test/tsconfig.json

{
  "extends": "../tsconfig.json",
  "exclude": [
    "../src"
  ]
}

Actual behavior

tslint -p test/tsconfig.json -c tslint.json
(no warnings)

Expected behavior

tslint -p test/tsconfig.json -c tslint.json
WARNING: test/test.ts[1, 14]: Class name must be in pascal case

Details

All tsconfig.json and tslint.json have been simplified above.

My use case is that I have a base tsconfig.json file for my project, which is extended by src/tsconfig.json and test/tsconfig.json (they set different compiler options and exclusions), and I want to be able to lint both directories separately using their respective tsconfig.json as input, but it seems that TSLint doesn't parse test/tsconfig.json as TypeScript does. It doesn't seem to honor its extends property.

If I run tslint -p tsconfig.json -c tslint.json, it lints test/test.ts as expected, since tsconfig.json includes test/**/*.ts, but also lints all TS files in src, which is not the desired behavior. Among other things, that's what test/tsconfig.json prevents by extending tsconfig.json and excluding ../src.

@ajafff
Copy link
Contributor

ajafff commented May 4, 2017

I can't reproduce the error with the provided examples.

I submitted PR #2688 to make sure it works and wont regress.

@ajafff
Copy link
Contributor

ajafff commented May 4, 2017

@diegovilar I don't know if I misread your opening post or if you edited the relevant parts.
Anyways, I can reproduce the error now.

Some research revealed that typescript has a problem with relative paths. Still investigating if this should be fixed in tslint or typescript...
I'll keep you posted

@diegovilar
Copy link
Author

@ajafff What I edited was minor, don't think that changed anything in your understanding.. That's probably on my bad English :P

Anyways, I'm glad you're looking into it. I'll have some spare time tomorrow and will be looking into this too.

Without looking at TSLint implementation, I just assumed that the inclusions defined in tsconfig.json were not being inherited by test/tsconfig.json the way TSLint parsed it because I have come across some libraries that deal with reading tsconfig.json and were not using the TypeScript API to parse it.

@ajafff
Copy link
Contributor

ajafff commented May 5, 2017

After some debugging, there seems to be no easy fix in typescript AFAICT.

The quick fix would be adding projectDirectory = path.resolve(projectDirectory) at https://github.com/palantir/tslint/blob/master/src/linter.ts#L63
Unfortunately that will yield all absolute paths. Maybe that's no problem once #2667 lands. /cc @nchen63

@ajafff
Copy link
Contributor

ajafff commented May 5, 2017

@diegovilar I changed #2688 to fix this problem by using absolute paths. That PR was already merged.

@anler
Copy link

anler commented Jun 14, 2018

I'm still getting this problem in tslint version 5.10.0, tslint complains that 'some file' is not included in project.

@adidahiya
Copy link
Contributor

I think this was fixed with #2688. @anler that issue seems to be different, see #3677

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants