Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I TSLint on save in WebStorm?

How can I fix my .ts files everytime I save a file in WebStorm?

I know that I can run tslint --fix after saving. I also know that I can ⌥⏎ + on the current error in the file and that error will be resolved. But I am used to a different styleguide and it would save me a lot of time to have these style lint errors to be auto fixed:

tslint error

I cannot find the relevant settings in WebStorm:

WebStorm settings

I would also be completely willing to use a different cli tool to achieve auto tslinting on save.

like image 624
Tom Avatar asked Jul 30 '17 09:07

Tom


People also ask

How do I use TSLint in WebStorm?

WebStorm lets you automatically fix some of the issues reported by TSLint. To fix a specific error, place the cursor at the highlighted code, press Alt+Enter , and then select TSLint: fix current error from the list. To fix all the issues detected in the file, choose TSLint: fix current file.

How do I disable TSLint to a file?

In addition to global configuration, you may also enable/disable linting for a subset of lint rules within a file with the following comment rule flags: /* tslint:disable */ - Disable all rules for the rest of the file. /* tslint:enable */ - Enable all rules for the rest of the file.


Video Answer


1 Answers

On-save actions are not currently supported by the platform, as files are auto-saved by the IDE - see https://youtrack.jetbrains.com/issue/IDEABKL-6722. If you need to run tslint --fix on Save All, set it up as a file watcher, and disable immediate synchronization for this watcher, so that it's triggered on explicit Save/changing focus. See the simplest configuration below... You need changing the Program field according to your local settings

enter image description here

like image 56
lena Avatar answered Sep 18 '22 12:09

lena