Tslint: TSLint doesn't always work on a file without any "import"

Created on 16 Dec 2017  路  1Comment  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.8.0
  • __TypeScript version__: 2.6.1
  • __Running TSLint via__: (pick one) CLI

TSLint is not always working when the .ts file to lint doesn't have any import statements.

Here's a project to reproduce the issue.

Not A Bug

Most helpful comment

For posterity:

TSLint is not always working when the .ts file to lint doesn't have any import statements...

Here's an example of two files with the same error. They are using let where const must be used since the "prefer-const" rule is set to true. The one with an import will properly display the error, the other won't output anything!

This is working as intended. If you don't have an import or export in a file, it's not a module but is considered global. Since TSLint cannot know if some other file uses variables in global scope, prefer-const ignores variables defined at the top level of global scripts.

>All comments

For posterity:

TSLint is not always working when the .ts file to lint doesn't have any import statements...

Here's an example of two files with the same error. They are using let where const must be used since the "prefer-const" rule is set to true. The one with an import will properly display the error, the other won't output anything!

This is working as intended. If you don't have an import or export in a file, it's not a module but is considered global. Since TSLint cannot know if some other file uses variables in global scope, prefer-const ignores variables defined at the top level of global scripts.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SwintDC picture SwintDC  路  3Comments

dashmug picture dashmug  路  3Comments

ypresto picture ypresto  路  3Comments

ghost picture ghost  路  3Comments

mrand01 picture mrand01  路  3Comments