Static code analysis is an essential part of the development life cycle (SDLC) for every platform. It brings numerous benefits to our lives, such as ensuring code readability, maintaining uniform styling across the team, and preventing unnecessary conflicts.
Before automating the process, we must understand what ESLint and TSLint are and why we use them.
What is ESLint?
Additionally, ESLint is integrated into most text editors, and you can execute it as part of your continuous integration pipeline.
What is TSLint?
TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.
However, TSLint is currently deprecated, and the recommended alternative is to migrate to Angular ESLint (even though TSLint is still usable).
How Can We Do?
It’s really easy and straightforward. You need to follow the instructions below. The example provided is for TSLint, but it can also be used for ESLint. However, you must update the “Program” field accordingly.
- Open Intellij Webstorm
- On the menu navigate to File > Settings
- Find and open Tools > File Watchers
- Click the Plus(+) button
You can use all information in the screenshot by modifying the “Program” fields to use the local path of TSLint. Additionally, if your “tslint.json” file is not located in the root folder of the project, you need to set it correctly in the “Arguments” field.
I suggest you to use ESLint or migrate to it but if you want to continue to use TSLint, you can find an example tslint.json here.