-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional support for TypeScript files (closes #42) #74
Conversation
Hi @mrmckeb, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
1 similar comment
Hi @mrmckeb, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
I'd be very interested to see if you have any feedback on this too, thanks! |
@mrmckeb, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
@@ -48,6 +57,7 @@ export function activate(context: ExtensionContext) { | |||
|
|||
context.subscriptions.push( | |||
new SettingMonitor(client, 'eslint.enable').start(), | |||
new SettingMonitor(client, 'eslint.enableTypeScript').start(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find documentation on SettingMonitor
, but this seems to actually disable/enable the extension. Is there a way to restart it upon a setting change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, I might need to either manage configuration updates in the server itself (connection.onDidChangeConfiguration
) and remove this line, or create a new client here on each change. I'd be interested to get your thoughts on what's best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my overall comments which provides some suggestions to this problem. We should not do this in the server. The cool think about the settings monitor is that it shuts down the server if enable=false which saves a process.
@mrmckeb thanks for providing the PR. I was on vacation and I will look into this beginning of next week. |
No problem @dbaeumer, I think it needs some work still - so I'm looking forward to getting some thoughts on it. |
Hi @dbaeumer, have you had a chance to take a look at this yet? I'd like to contribute, but would also like a little direction / feedback before submitting final code. |
@mrmckeb I actually looked at it beginning of this week but I couldn't find a good answer yet how to support best mixed workspaces (a workspace containing TS and JS files) which is nicely supported with the latest TS release. Instead of keeping my thoughts for myself I should have dumped them here without having a solution. Here is the main difficulty I see: in a workspace with JS and TS files we still need to support to disable eslint on TS files. With the current PR this will not work (it will shutdown ESLint for JS files as well). So what needs to be done is:
I am actually leaning towards 2.) |
@@ -9,6 +9,15 @@ import { workspace, window, commands, Disposable, ExtensionContext } from 'vscod | |||
import { LanguageClient, LanguageClientOptions, SettingMonitor, RequestType, TransportKind, TextEdit, Protocol2Code } from 'vscode-languageclient'; | |||
|
|||
export function activate(context: ExtensionContext) { | |||
let supportedDocuments = ['javascript', 'javascriptreact']; | |||
let supportedFileExtensions = ['c.js', 'c.yaml', 'c.yml', 'c', 'c.json']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is not necessary. The eslint config files stay the same regardless whether the linter lints JS or TS files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it was late and I think I misinterpreted this as the supported files for linting, not configuration. Removed.
Added more comments to the 'Files changed' |
Hi @dbaeumer, Thanks for your time on this. I've had a look at this tonight, updated a few things as per your notes, and have a few thoughts - I was looking at the documentation for extensions and came across the following, and wondered if we could use that to update (or restart) the extension on the fly?
The event handler could listen to the event (which unfortunately doesn't include details of what changed), and then check to see if any of the changes affect this extension, and then perform an action if required. I'm not sure if the LanguageClient can be updated, or if it would need to be replaced (and a restart needed). I'd be interested in your thoughts on this. I too would like a solution that doesn't require a restart of VSCode. |
@mrmckeb yes, to listen to configuration changes and to manage the LanguageClient is what I was trying to suggest is my comment. This is what the SettingsMonitor does as well (https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/main.ts) |
Great, thanks for the @dbaeumer - you were clear enough, I just didn't have the context perhaps. I'll tidy this up over the next few days and let you know when it's ready for review again. If you have any other feedback in the meantime, please let me know. |
Hi @dbaeumer, I've added a first attempt at a custom implementation of the SettingMonitor, that hopefully meets the needs of this extension - and may be something we can publish/share. Let me know what you think of it. The extension now seems to be hitting the mark in terms of functionality. The only part I'm not happy about is that it's a little slow when changing supported languages, as the client is being recreated. |
Hi @mrmckeb Thanks for the updated PR. Reading your comment and looking at the code I think we should extend the LanguageClient to get more dynamic in terms of document selectors it handles. Shutting down and restarting if the range of documents changes is not very cool. Would you be willing to look into this as well. The LanguageClient is here: https://github.com/Microsoft/vscode-languageserver-node Then a small note on naming: to keep things consistent the settings should be named like this:
|
Sorry I was away last weekend and haven't had a chance to get back to this until now. I'm looking at |
Hi @dbaeumer, I wanted to give you a quick update - I'm still struggling to find time for this. I'm hoping I'll have time next weekend. I still want to contribute, I've just had a few things take priority over the last month or so. |
@mrmckeb don't worry. Please note that I will be out on vacation in July. So I can earliest get back to you with comment in August. |
I've also been playing around with typescript-eslint-parser and would love to be able to see lint warnings in vscode. Looking forward to getting this in! |
Looping back to this now that a few weeks have passed. In that time, I am proud to say I have been made a member of the ESLint team, so I would really love to help get this across the line in any way I can. I just want to make sure I am clear on what needs to be done. @dbaeumer am I right in saying the work on the language server is what is currently blocking this PR microsoft/vscode-languageserver-node#44 (comment)? |
Hi @JamesHenry, thanks for following this up... it's been on my radar for a long time - but unfortunately I ended up on a very large project (working literally every weekend for over two months) and then went on a much-deserved vacation... so needless to say, I've not touched this - and I do feel a bad about that. You're right, the language server needs some work, the only way to avoid that is to force the user to restart VSCode upon any changes to their linting settings - which is a little dirty. I found a few hacky ways to work around that, but the only real solution is to rework the language server a little so that it can update when needed. This was my first attempt at working on either of these repositories, so @dbaeumer is definitely the expert here. Again, I'm very sorry that I haven't been able to follow through on this. |
@mrmckeb @JamesHenry to make this a nice experience we need to do some work on the language server client. I started that work in the branch but haven't continue on it. I will add it back to my list. |
Thanks so much for getting back to me @mrmckeb and @dbaeumer! @mrmckeb it happens! No need to feel guilty. @dbaeumer Thank you, and is there still some thinking to be done around what that might look like? Or is it just a matter of finding the time to implement a specific plan? I am very happy to help in any way I can if it is the latter, but I naturally lack the context necessary to take on the former right now |
+1. spent an hour trying to figure out why eslinter was not working with my typescript files... now I know. |
@mrmckeb I am currently working on making the language server protocol more dynamic. This should allow implementing this very easy. Will ping when this is done. |
That's great @dbaeumer. I'll finish this off the moment you give the go-ahead. Thanks for kicking this back off. |
Awesome, thanks so much guys! I am really excited about this |
hi @dbaeumer, any news? |
Is there anything I can do to keep this moving @dbaeumer? We have now reached 1.0.0 with the official typescript-eslint-parser (with some known caveats), and this is now a pretty major blocker for VSCode users. How is the work from last month (#74 (comment)) progressing? Would extra contributors help? Many thanks! |
@JamesHenry thanks for asking. I will finished the work on the LSP in the next day to support adding additional file types to lint on the fly which makes implementing this in ESLint very very easy. May be I will take it as an example. |
That's fantastic news, I can't wait to try it out! :) |
Yay! Initial test successful :) Thanks so much! I will continue to use it in more substantial projects and report any issues on #42 |
@JamesHenry Do you have instructions on how you got this working? I am new to vscode. Edit: I have it installed just not sure how to run the extension. |
Thanks @dbaeumer, this is great. I'll check it out! |
@trainerbill I simply followed the steps outlined by @dbaeumer here #42 (comment) |
@mrmckeb If you're looking for complete config files for typescript eslint'ing, the following is mine. Extension: ESLint [project root]/package.json: (you'll have to run
[project root]/.eslintrc:
[project root]/.vscode/settings.json
User settings:
|
No description provided.