Skip to content

Commit

Permalink
refactor(@angular/cli): add more actionable missing lint target mes…
Browse files Browse the repository at this point in the history
…sage
  • Loading branch information
alan-agius4 committed Mar 16, 2021
1 parent fe5c3e0 commit cc10302
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/angular/cli/commands/deploy-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
import { ArchitectCommand } from '../models/architect-command';
import { Arguments } from '../models/interface';
import { Schema as DeployCommandSchema } from './deploy';

const BuilderMissing = `
Cannot find "deploy" target for the specified project.
You should add a package that implements deployment capabilities for your
Expand Down
22 changes: 17 additions & 5 deletions packages/angular/cli/commands/lint-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,27 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command';
import { ArchitectCommand } from '../models/architect-command';
import { Arguments } from '../models/interface';
import { Schema as LintCommandSchema } from './lint';

const MissingBuilder = `
Cannot find "lint" target for the specified project.
You should add a package that implements linting capabilities.
For example:
ng add @angular-eslint/schematics
`;

export class LintCommand extends ArchitectCommand<LintCommandSchema> {
public readonly target = 'lint';
public readonly multiTarget = true;
readonly target = 'lint';
readonly multiTarget = true;
readonly missingTargetError = MissingBuilder;

public async run(options: ArchitectCommandOptions & Arguments) {
return this.runArchitectTarget(options);
async initialize(options: LintCommandSchema & Arguments): Promise<number | void> {
if (!options.help) {
return super.initialize(options);
}
}
}
23 changes: 18 additions & 5 deletions packages/angular/cli/commands/lint-long.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
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.
The command takes an optional project name, as specified in the `projects` section of the `angular.json` workspace configuration file.
When a project name is not supplied, executes the `lint` builder for the default project.

The default linting tool is [TSLint](https://palantir.github.io/tslint/), and the default configuration is specified in the project's `tslint.json` file.
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).
For example:

**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](https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslint) README.
```json
"projects": {
"my-project": {
...
"architect": {
...
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {}
}
}
}
}
```
7 changes: 3 additions & 4 deletions packages/angular/cli/commands/lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Runs linting tools on Angular app code in a given project folder.",
"$longDescription": "./lint-long.md",

"$aliases": [ "l" ],
"$aliases": ["l"],
"$scope": "in",
"$type": "architect",
"$impl": "./lint-impl#LintCommand",
Expand All @@ -22,15 +22,14 @@
}
},
"configuration": {
"description": "The linting configuration to use.",
"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.",
"type": "string",
"aliases": [
"c"
]
}
},
"required": [
]
"required": []
},
{
"$ref": "./definitions.json#/definitions/base"
Expand Down

0 comments on commit cc10302

Please sign in to comment.