TypeStrong / atom-typescript

The only TypeScript package you will ever need
https://atom.io/packages/atom-typescript
MIT License
1.13k stars 204 forks source link

[Question] Linting on Save #1588

Closed ghivert closed 2 years ago

ghivert commented 3 years ago

Hi !

I'm using atom-typescript on a regular daily basis and the package is really cool. I'm just wondering: as a linter user, I appreciate to have linting of my files only on save, and not on the fly. The linter package provides a settings to support this. Do you think it's possible to have it included in atom-typescript? Maybe I can try to push a PR for this? I just don't know where to start. :)

Thank you very much!

lierdakil commented 3 years ago

You can kind of get the behaviour you're looking for by setting an absurdly high value for "getErr Debounce Timeout" option in Atom-TypeScript settings, like 1e100 which in human terms translates to the better part of forever.

If you want to add a more ergonomic and less arcane toggle, basically this line pulls errors on text change: https://github.com/TypeStrong/atom-typescript/blob/eb36e864c8959cd6caa576b9a81b9d75179bb29a/lib/main/typescriptBuffer.ts#L65

Here it is again in context: https://github.com/TypeStrong/atom-typescript/blob/eb36e864c8959cd6caa576b9a81b9d75179bb29a/lib/main/typescriptBuffer.ts#L61-L66

So, you might add a boolean setting to make this call conditionally. (See https://github.com/TypeStrong/atom-typescript/blob/master/CONTRIBUTING.md#config-schema and https://flight-manual.atom.io/api/v1.57.0/Config/ for more information on adding new settings)

I can't say from the top of my head if tsserver ever pushes errors, but it'd be somewhat complicated to ignore those anyway due to the asynchronous nature of things. But at least with this call disabled, Atom-TypeScript won't pull errors on text change, which is probably enough in most cases.

Bear in mind I'll be out of town for a couple of weeks, and the Internet access in the countryside isn't great, so I probably won't be able to review/merge/release any PRs until mid-July.

Also, oh, hey, ponies. Ponies are fun.

P.S. CI is broken at the moment, so if you make a PR, ignore it.

github-actions[bot] commented 2 years ago

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days