Tslint: File list is ignored when using `--type-check` in CLI

Created on 5 Oct 2016  路  6Comments  路  Source: palantir/tslint

Bug Report

  • TSLint version: 3.15.1
  • TypeScript version: 2.0.3
  • Running TSLint via: CLI

    TypeScript code being linted

  1. Create file src/foo.ts and src/bar.ts and create a tsconfig.json which compiles src/.
  2. Creating a lint issue in both files (e.g., set semicolon rule to always then omit a semicolon, but this can be any lint issue).

    Actual behavior

  3. Run tslint --project tsconfig.json src/foo.ts

    • As expected, it will only show issue in src/foo.ts
  4. Run tslint --project tsconfig.json --type-check src/foo.ts

    • It will show issues from in files.

      Expected behavior


tslint should only show issues in src/foo.ts, if that is what is specified

Not A Bug

Most helpful comment

Recent versions of tslint no longer ignore the specified files and excludes when using --project --type-check. Only errors from type checking are not filtered, because the whole project need to be checked at once.

Since --type-check is no longer necessary to use rule that require type information, I think this issue can be closed.

All 6 comments

It appears from tslint-cli.ts that the files argument is ignored when --type-check is provided.

Based on the current code, I'd like to see a message saying that the files input is being ignored, or (ideally) it should filter the TypeScript program input to only compile the specified files.

I suspect this can be fixed by filtering parsed.fileNames from MultiLinter#createProgram to only include the specified files, if any are specified

Alternatively ts.getPreEmitDiagnostics() accepts an optional SourceFile parameter, which will keep the complexity limited to tslint-cli

This issue is important because --type-check requires --project to be set. I would like to be able to specify files to lint even while using type-checked lint rules.
I also noticed that --project seems to exclude .d.ts files from linting.

+1
I have to use --type-check --project for some rules. This causes my file options to be ignored, therefore my node_modules folder is being parsed. At the very least, indicate that the file option is ignored when using --type-check. This behavior is very annoying.

Recent versions of tslint no longer ignore the specified files and excludes when using --project --type-check. Only errors from type checking are not filtered, because the whole project need to be checked at once.

Since --type-check is no longer necessary to use rule that require type information, I think this issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings