runem / lit-analyzer

Monorepository for tools that analyze lit-html templates
MIT License
319 stars 38 forks source link

tsconfig.json not working #82

Closed jumpman255 closed 4 years ago

jumpman255 commented 4 years ago

I'm trying to setup lit-analyser using the provided documentation but can't get it to work. I have made a reproducible demo here: https://github.com/cardi3m/lit-analyser-test. When I run lit-analyzer --debug, the "Lit Analyzer Configuration" stays empty. If I remove the rules, I can see all the default values but strict is still turned off.

I also found out that configuration page is out of date since warn has been replaced by warning.

abdonrd commented 4 years ago

I have the same issue: if I setup the TS plugin from the tsconfig.json, nothing happens.

If I use the lit-analyzer CLI, it works.

Darkle commented 4 years ago

Same here

abdonrd commented 4 years ago

Friendly ping to @runem 😄

runem commented 4 years ago

Sorry, this has been long overdue :-) Good news! I have now fixed the problem. I expect to release it with v1.2 or maybe v1.11.12 if I get to complete some more tasks on master before v1.2 :tada:

I had to fix a couple problems to fix this bug.

  1. The tsconfig.json file wasn't resolved by using Typescripts functionality, so it didn't traverse up the directories to find it. It also didn't support comments in JSON, because I used JSON.parse.
  2. As soon as a partial LitAnalyzer config was found inside a tsconfig.json file, an entire config was constructed overwriting eventual rules specified from the CLI.
  3. Options from the CLI and options from the tsconfig.json weren't merged properly. Now options from CLI takes precedence over options from "tsconfig.json", and they are merged as you would expect.
abdonrd commented 4 years ago

Great, thanks again @runem! 👏

abdonrd commented 4 years ago

@runem can we expect the new release soon? Thanks in advance!

abdonrd commented 4 years ago

@runem I just tried the new v1.2.0 version, but it doesn't work for me...

You can check it here: https://github.com/IBM/pwa-lit-template/pull/59

runem commented 4 years ago

I'm sorry to hear that, I'll take a look at it now!

It might have something to do with this commit i made today, because vscode is behaving differently, not calling onConfigurationChanged with the expected configuration.

abdonrd commented 4 years ago

@runem ook, thanks Rune! 👏

runem commented 4 years ago

Just to make sure I'll outline my thoughts here, because I think I'm misunderstanding the problem :-)

So as I understood this issue, it was due to rules in tsconfig.json not being picked up correctly when running either lit-plugin, ts-lit-plugin or lit-analyzer. This was the problem I mentioned being fixed, and I can't seem to reproduce the bug with the current version of the tools.

But reading https://github.com/IBM/pwa-lit-template/pull/59 it looks like you are using tsc to run type checking with ts-lit-plugin. However, unfortunately this isn't yet supported by Typescript. Right now, TS-plugins are only run in a language service run by the IDE, but are a lot of people requesting support for extending what plugins can do (the concept is called "Compiler Plugins") that can emit diagnostics when running tsc. The Typescript maintainers seem to support this feature, so I wouldn't be surprised if we see some progress on this matter soon. Of course, I will keep a close eye on compiler plugins, so you can expect me to add support for it in ts-lit-plugin as soon as they support it.

I'm sorry if I misunderstood your issue :sunny:

abdonrd commented 4 years ago

Ooh, okey! Thanks for the explication! I also misunderstood how it should work!