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

Debug tslint error #2704

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

Debug tslint error #2704

mxl opened this issue May 7, 2017 · 3 comments

Comments

@mxl
Copy link
Contributor

mxl commented May 7, 2017

Bug Report

  • TSLint version: 5.2.0
  • TypeScript version: 2.3.2

Currently if an error is thrown while applying tslint rule it's logged as warning and only error message is included in log. This complicates debugging such cases. For example see #2696 where tslint printing the following log line:

Warning: Cannot read property 'kind' of undefined

without any details like stacktrace.

I suggest to add debug or verbose option that will enable output of stacktrace.
If that's ok I can submit a PR.

I'm not alone http://stackoverflow.com/q/43577136/746347

@ajafff
Copy link
Contributor

ajafff commented May 7, 2017

TypedRule used to throw an exception when tslint was not run with --project --type-check. That caused some trouble when using the same tslint.json in CLI and for example in vscode-tslint.
To fix this everything was wrapped in try-catch.

Reverting/changing that behavior was also on my agenda, because I think it causes more trouble than it's actually worth.

There are several options:

  • Remove the try-catch, replace the throw in TypedRule#apply with showWarningOnce('...'); return [];
    • still outputs a warning when not type checking
    • bugs in rules will crash the process
      • you notice that something when wrong
      • you get the whole stack trace
      • otherwise editor plugins might just swallow the warning
      • easier debugging by pausing at the uncaught exception
  • log the whole stack trace by default
  • add an option --debug or --verbose as described above and ...
    • throw
    • log the whole stack trace

Thoughts? @nchen63 @adidahiya @andy-hanson

@andy-hanson
Copy link
Contributor

👍 for printing the whole stack trace. It's pretty cryptic otherwise, since there's no indication that the message is being printed because of an exception.

@ajafff
Copy link
Contributor

ajafff commented May 12, 2017

@andy-hanson printing the stack trace by default doesn't play well will the exception thrown in TypedRule. Instead of throwing there, it should just call showWarningOnce and return.

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