Reputation: 3805
I am using Intellij for doing angular project. I am getting a lot of tslint errors while writing the code.Is there any way to fix all the these lint errors in by using a command in intellij ?
Upvotes: 5
Views: 14196
Reputation: 111
The previous answers probably only refer to Webstorm, as Filewatchers are not available in the current IntelliJ Ultimate edition (2020.2).
However, whenever you have your own tslint.json
, for example when generating an Angular Project from cli, you can tell IntelliJ to use the specified code styles. To do this, open the tslint.json file (root of angular project) and you should see a prompting-bar at the top of your screen. Accept the prompt "Apply code style from TSLint?"
With the applied code style you can use your accustomed shortcuts (e.g. Ctrl+Alt+L) whenever you want to reformat a file / directory.
I found this solution (including the picture) on the Jetbrains forums https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000047844-Angular-and-Tslint-for-code-reformat
Upvotes: 1
Reputation: 841
You can create File Watcher in Settings > Tools by the following configuration:
On save (Ctrl + s), your current file will be fixed.
Upvotes: 7
Reputation: 196
Preferences => File Watchers => + ( create new )
Just remember to select the file type correct (its ok to create multiple watchers to handle other file types)
Upvotes: 0
Reputation: 97
If you want to run tslint against all files you would need to add it as an external tool.
A good write up from 2016 explains the process: https://blog.jetbrains.com/webstorm/2016/08/using-external-tools/
Or you can always run it from the command line as Sajeetharan mentioned.
Upvotes: 0
Reputation: 222712
One of the quick way to fix all the tslint errors would be to install visual studio code.
It will have the auto-fix option to fix option to fix all the issues
Event intellij
has the option to do the same
Alt-Enter
on the highlighted problem and select either TSLint: fix current problem to fix only this particular issue or TSLint: fix current file to apply the fixes when possible to the whole file.
Upvotes: 4