Click here to Skip to main content
14,090,506 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.5K views
1 bookmarked
Posted 24 Sep 2018
Licenced CPOL

Analyze & Fix your Angular 6 code using TSLint

, 24 Sep 2018
Rate this:
Please Sign up or sign in to vote.
Analyze and fix your Angular 6 code using TSLint

As per TSLint Official site https://palantir.github.io/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.

Develop quality code is highly desired hence it's highly recommended that, before code check-in to Source Control, do TSLint check and fix the possible errors.

Angular Applications are already integrated with TSLint, tslint.json file can be found at the root of your project.

TSLint is also defined as dev dependency in package.json.

Analyze & Fix your Angular 6 code using TSLint

TSLint using CLI

Angular CLI has extended support for linting, to scan the code for issues, run the below command.

Ng lint

Analyze & Fix your Angular 6 code using TSLint

You can see a list of errors in the console windows, however, it's difficult to read and fix.

CLI also has support to auto fix the issues (most common), to scan and fix, use the below command.

Ng lint material-app --fix (here material-app is the name of the application)

Analyze & Fix your Angular 6 code using TSLint

Note: There may be few issues left which you need to fix manually.

TSLint using Visual Code

Open VS Code, click on Extensions (Ctrl + Shift + X).

Search TSLint in the search box.

Click on Install, once Installed, restart VS Code to complete the installation.

Analyze & Fix your Angular 6 code using TSLint

In the currently opened file, issues will be highlighted, bring cursor on the issue and press control + dot will prompt for the options as below image.

Fix the current issue or click on "Fix all auto fixable options" will fix all issues.

Analyze & Fix your Angular 6 code using TSLint

In case you want to fix using Command palette, then by pressing Ctrl + Shift + P will open the command palette, select or type "TSLint: Fix all auto-fixable problems" command to fix all issues.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rajneesh Kumar Verma
Architect
India India
Microsoft Certified Solutions Associate - Cloud Platform || MCSD - App Builder || MCSA - Web Applications || Microsoft Community Contributor (MCC)
A fond lover of Microsoft .NET Technologies including ASP.NET MVC, AZURE etc.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Questionwebpack Pin
buckrogerz26-Sep-18 17:24
memberbuckrogerz26-Sep-18 17:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190518.1 | Last Updated 25 Sep 2018
Article Copyright 2018 by Rajneesh Kumar Verma
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid