Skip to content

Commit cc10302

Browse files
committed
refactor(@angular/cli): add more actionable missing lint target message
1 parent fe5c3e0 commit cc10302

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

packages/angular/cli/commands/deploy-impl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
8+
import { ArchitectCommand } from '../models/architect-command';
99
import { Arguments } from '../models/interface';
1010
import { Schema as DeployCommandSchema } from './deploy';
1111

1212
const BuilderMissing = `
13-
1413
Cannot find "deploy" target for the specified project.
1514
1615
You should add a package that implements deployment capabilities for your

packages/angular/cli/commands/lint-impl.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
8+
import { ArchitectCommand } from '../models/architect-command';
99
import { Arguments } from '../models/interface';
1010
import { Schema as LintCommandSchema } from './lint';
1111

12+
const MissingBuilder = `
13+
Cannot find "lint" target for the specified project.
14+
15+
You should add a package that implements linting capabilities.
16+
17+
For example:
18+
ng add @angular-eslint/schematics
19+
`;
20+
1221
export class LintCommand extends ArchitectCommand<LintCommandSchema> {
13-
public readonly target = 'lint';
14-
public readonly multiTarget = true;
22+
readonly target = 'lint';
23+
readonly multiTarget = true;
24+
readonly missingTargetError = MissingBuilder;
1525

16-
public async run(options: ArchitectCommandOptions & Arguments) {
17-
return this.runArchitectTarget(options);
26+
async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
27+
if (!options.help) {
28+
return super.initialize(options);
29+
}
1830
}
1931
}
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
Takes the name of the project, as specified in the `projects` section of the `angular.json` workspace configuration file.
2-
When a project name is not supplied, it will execute for all projects.
1+
The command takes an optional project name, as specified in the `projects` section of the `angular.json` workspace configuration file.
2+
When a project name is not supplied, executes the `lint` builder for the default project.
33

4-
The default linting tool is [TSLint](https://palantir.github.io/tslint/), and the default configuration is specified in the project's `tslint.json` file.
4+
To use the `ng lint` command, use `ng add` to add a package that implements linting capabilities. Adding the package automatically updates your workspace configuration, adding a lint [CLI builder](guide/cli-builder).
5+
For example:
56

6-
**Note**: TSLint has been discontinued and support has been deprecated in the Angular CLI. The options shown below are for the deprecated TSLint builder.
7-
To opt-in using the community driven ESLint builder, see [angular-eslint](https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslint) README.
7+
```json
8+
"projects": {
9+
"my-project": {
10+
...
11+
"architect": {
12+
...
13+
"lint": {
14+
"builder": "@angular-eslint/builder:lint",
15+
"options": {}
16+
}
17+
}
18+
}
19+
}
20+
```

packages/angular/cli/commands/lint.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Runs linting tools on Angular app code in a given project folder.",
55
"$longDescription": "./lint-long.md",
66

7-
"$aliases": [ "l" ],
7+
"$aliases": ["l"],
88
"$scope": "in",
99
"$type": "architect",
1010
"$impl": "./lint-impl#LintCommand",
@@ -22,15 +22,14 @@
2222
}
2323
},
2424
"configuration": {
25-
"description": "The linting configuration to use.",
25+
"description": "One or more named builder configurations as a comma-separated list as specified in the \"configurations\" section of angular.json.\nThe builder uses the named configurations to run the given target.\nFor more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.",
2626
"type": "string",
2727
"aliases": [
2828
"c"
2929
]
3030
}
3131
},
32-
"required": [
33-
]
32+
"required": []
3433
},
3534
{
3635
"$ref": "./definitions.json#/definitions/base"

0 commit comments

Comments
 (0)