ng lint
針對給定專案目錄下的 Angular 應用程式碼,執行 lint 工具
Runs linting tools on Angular app code in a given project folder.
ng lint <project> [options]
ng l <project> [options]
說明
獲取在工作空間配置檔案 angular.json
的 projects
部分指定的專案名稱。如果未提供專案名稱,它將對所有專案執行。
Takes the name of the project, as specified in the projects
section of the angular.json
workspace configuration file. When a project name is not supplied, it will execute for all projects.
預設的 lint 工具是 TSLint,其預設配置在專案的 tslint.json
檔案中指定。
The default linting tool is TSLint, and the default configuration is specified in the project's tslint.json
file.
注意:TSLint 已經中止開發了,並且在 Angular CLI 中將棄用此功能。下面顯示的選項適用於已棄用的 TSLint 建構器。要選擇社群驅動的 ESLint 建構器,請參閱 angular-eslint 的README。
Note: TSLint has been discontinued and support has been deprecated in the Angular CLI. The options shown below are for the deprecated TSLint builder. To opt-in using the community driven ESLint builder, see angular-eslint README.
引數
引數 | 說明 | Value Type |
---|---|---|
<project> | 要 lint 的專案名。 The name of the project to lint. | string |
選項
選項 | 說明 | Value Type | Default Value |
---|---|---|---|
--configuration | 要使用的 lint 配置。 The linting configuration to use. 別名: -c | string | |
--exclude | 要在 lint 時排除的檔案。 Files to exclude from linting. | array | |
--files | 要在 lint 時包含的檔案。 Files to include in linting. | array | |
--fix | 修復 lint 錯誤(可能會覆蓋被 lint 的檔案)。 Fixes linting errors (may overwrite linted files). | boolean | false |
--force | 即使出現 lint 錯誤也返回成功。 Succeeds even if there was linting errors. | boolean | false |
--format | 輸出格式(prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist)。 Output format (prose, json, stylish, verbose, pmd, msbuild, checkstyle, vso, fileslist). | string | stylish |
--help | 在控制檯顯示關於本命令的幫助資訊。 Shows a help message for this command in the console. | true|false|json|JSON | false |
--silent | 顯示輸出文字。 Show output text. | boolean | false |
--ts-config | TypeScript 配置檔案的名稱。 The name of the TypeScript configuration file. | string | |
--tslint-config | TSLint 配置檔案的名稱。 The name of the TSLint configuration file. | string | |
--type-check | 控制 lint 的型別檢查。 Controls the type check for linting. | boolean | false |