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

[Breaking] don't exclude *.d.ts files when using --project #3314

Closed
ajafff opened this issue Oct 12, 2017 · 7 comments
Closed

[Breaking] don't exclude *.d.ts files when using --project #3314

ajafff opened this issue Oct 12, 2017 · 7 comments

Comments

@ajafff
Copy link
Contributor

ajafff commented Oct 12, 2017

Currently when using --project CLI option without explicitly specifying files, TSLint lints all files in the project except *.d.ts files.
I guess it was implemented that way to avoid linting external dependencies from mode_modules.

Unfortunately this also excludes declaration files that are located within the project.

Starting from typescript@2.6.0 we can use an API to determine if a file comes from node_modules (#2827).
That makes excluding *.d.ts files unnecessary. I propose we change that behavior in the next major version.

@mpal9000
Copy link

program.getCompilerOptions().skipLibCheck === true && file.fileName.endsWith(".d.ts")
      || program.isSourceFileFromExternalLibrary(file)
    ? undefined
    : file.fileName

@ajafff
Copy link
Contributor Author

ajafff commented Nov 18, 2017

@mpal9000 I don't thing skipLibCheck is a good indicator for TSLint to ignore declaration files. People mostly use it to ignore type errors in typings of external libraries (or for performance reasons).
Since many TSLint rules are about code style, users might still want to check their own declaration files with TSLint.

Declaration files of dependencies are excluded anyway. To exclude declaration files in your project, you can simply add -e '**/*.d.ts' when executing tslint from command line.

@mpal9000
Copy link

The code above is from linter.ts -> getFileNames(). So you propose to remove the endsWith() check and use the -e cli option or do the filtering manually when using the api? That would be ok.

Does a program configured with skipLibCheck provides the required type information to lint .d.ts files of a "project" (for rules that require type information)?

@ajafff
Copy link
Contributor Author

ajafff commented Nov 18, 2017

Does a program configured with skipLibCheck provides the required type information to lint .d.ts files of a "project" (for rules that require type information)?

The linter simply ignores the flag. It's only relevant for tsc to swallow errors in declaration files.
The declarations from those files and their type information are still available.

Be aware that those declarations might have errors without you noticing. That could confuse the linter, but it will also confuse tsc. You probably already knew that from the typescript docs.

@mpal9000
Copy link

Yes, I'm using skipLibCheck for incremental building. So .d.ts files of a "project" cannot be reliably linted when the compiler option is enabled. Nevertheless I agree that it would be better to allow the user control the .d.ts exclusion separately. Waiting for this change.. Thanks

@adidahiya
Copy link
Contributor

I agree with this breaking change for 6.0

@JoshuaKGoldberg
Copy link
Contributor

💀 It's time! 💀

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. 😱

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint
  • Not Recommended: Fork TSLint locally 🤷‍♂️

👋 It was a pleasure open sourcing with you!

If you believe this message was posted here in error, please comment so we can re-open the issue!

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
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

4 participants