📜  Angular CLI-ng lint命令

📅  最后修改于: 2020-10-27 02:41:52             🧑  作者: Mango


句法

ng lint  [options]
ng l  [options]

ng lint在angular应用程序代码上运行linting工具。它检查指定角度项目的代码质量。它使用TSLint作为默认的整理工具,并使用tslint.json文件中的默认配置。选项是可选参数。

争论

Sr.No. Argument & Syntax Description
1 The name of the project to lint.

选件

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

The linting configuration to use.

Aliases: -c

2 –exclude Files to exclude from linting.
3 –files Files to include in linting.
4 –fix=true|false Fixes linting errors (may overwrite linted files).

Default: false

5 –force=true|false

Succeeds even if there was linting errors.

Default: false

6 –format=format

Output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist).

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 –tslintConfig=tslintConfig The name of the TSLint configuration file.
11 –typeCheck=true|false

Controls the type check for linting.

Default: false

首先转到使用ng build命令更新的角度项目。

按照以下步骤更新Goal.component.html和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 {
   }
}

Goal.component.html

{{title}}

现在运行linting命令。

\>Node\>TutorialsPoint> ng lint
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 newline

Lint errors found in the listed files.

ng lint命令在此处检查了应用程序的代码质量并打印了棉绒状态。

现在,更正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 {
   }
}

现在运行linting命令。

\>Node\>TutorialsPoint> ng lint
Linting "TutorialsPoint"...
All files pass linting.