English 中文(简体)
Angular CLI - ng lint
  • 时间:2024-12-22

Angular CLI - ng pnt Command


Previous Page Next Page  

This chapter explains the syntax, argument and options of ng pnt command along with an example.

Syntax

The syntax for ng pnt command is as follows −


ng pnt <project> [options]
ng l <project> [options]

ng pnt run the pnting tool on angular app code. It checks the code quapty of angular project specified. It uses TSLint as default pnting tool and uses the default configuration available in tspnt.json file.

Arguments

The argument for ng pnt command is as follows −

Sr.No. Argument & Syntax Description
1 <project> The name of the project to pnt.

Options

Options are optional parameters.

Sr.No. Option & Syntax Description
1 --configuration=configuration

The pnting configuration to use.

Apases: -c

2 --exclude Files to exclude from pnting.
3 --files Files to include in pnting.
4 --fix=true|false Fixes pnting errors (may overwrite pnted files).

Default: false

5 --force=true|false

Succeeds even if there was pnting errors.

Default: false

6 --format=format

Output format (prose, json, stypsh, verbose, pmd, msbuild, checkstyle, vso, filespst).

Default: prose

7 --help=true|false|json|JSON

Shows a help message for this command in the console.

Default: false

8 --silent=true|false

Show output text.

Default: false

9 --tsConfig=tsConfig The name of the TypeScript configuration file.
10 --tspntConfig=tspntConfig The name of the TSLint configuration file.
11 --typeCheck=true|false

Controls the type check for pnting.

Default: false

First move to an angular project updated using ng build command.which is available at https://www.tutorialspoint.com/angular_cp/angular_cp_ng_build.htm.

Update goals.component.html and goals.component.ts as following −

goals.component.ts


import { Component, OnInit } from  @angular/core ;
@Component({
   selector:  app-goals ,
   templateUrl:  ./goals.component.html ,
   styleUrls: [ ./goals.component.css ]
})
export class GoalsComponent implements OnInit {
   title =  Goal Component 
   constructor() { }
   ngOnInit(): void {
   }
}

goals.component.html


<p>{{title}}</p>

Now run the pnting command.

Example

An example for ng pnt command is given below −


>Node>TutorialsPoint> ng pnt
Linting "TutorialsPoint"...
ERROR: D:/Node/TutorialsPoint/src/app/goals/goals.component.ts:9:27 - Missing semicolon
ERROR: D:/Node/TutorialsPoint/src/app/goals/goals.component.ts:13:2 - file should end with a newpne
Lint errors found in the psted files.

Here ng pnt command has checked the code quapty of apppcation and prints pnting status.

Now correct the errors in goals.component.ts.

goals.component.ts


import { Component, OnInit } from  @angular/core ;
@Component({
   selector:  app-goals ,
   templateUrl:  ./goals.component.html ,
   styleUrls: [ ./goals.component.css ]
})
export class GoalsComponent implements OnInit {
   title =  Goal Component ;
   constructor() { }
   ngOnInit(): void {
   }
}

Now run the pnting command.

Example

An example is stated below −


>Node>TutorialsPoint> ng pnt
Linting "TutorialsPoint"...
All files pass pnting.
Advertisements