runem / lit-analyzer

Monorepository for tools that analyze lit-html templates
MIT License
318 stars 36 forks source link

[ts-lit-plugin] compatibility with webstorm #124

Closed FelixSchuSi closed 4 years ago

FelixSchuSi commented 4 years ago

Yesterday I found out that v. 1.2.0 of ts-lit-plugin broke compatibility with webstorm. Which is a bummer since most of my co-workers use webstorm. While everything else works as expected, the codefixes dont show up.

I have traced this down to the patch of "getSupportedCodeFixes" here. As pointed out by @runem here, we need to tell the language service which rules can generate codefixes by patching the "getSupportedCodeFixes" on the tsmodule. While calling "getSupportedCodeFixes" on the tsModule works, the patch itself doesnt have the desired effect in webstorm.

Before we used unique codes for the rules in lit-analyzer (ranging from 1 to 23), diagnostics of every rule were reported with the code 2322. Using the code 2322 means that we do not have to patch the "getSupportedCodeFixes" function, since 2322 is one of many typescript internal error codes that are allowed to create codefixes.

I have played around with this quite a bit and I couldnt get the patch to work in webstorm. The only workaround I could find was using rules that collide with typescripts internal error codes so that the patch becomes obsolete. I will file a PR with this workaround soon.

I really hope we can keep compatibility with webstorm so that my co-workers and every other webstorm user can continue to use this plugin.

runem commented 4 years ago

Thanks for reporting and fixing this issue :tada:

And thanks for your great in-depth description of the issue and the fix :+1: