Skip to content

Commit 14357e3

Browse files
committed
refactor(@angular/cli): remove a tslint:disable:no-global-tslint-disable no-any
Not entirely removed the usage of any but its a step in the right direction.
1 parent 928d05a commit 14357e3

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/angular/cli/models/architect-command.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
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-
9-
// tslint:disable:no-global-tslint-disable no-any
108
import {
119
Architect,
1210
BuildEvent,
1311
BuilderDescription,
1412
TargetSpecifier,
1513
} from '@angular-devkit/architect';
16-
import { JsonObject, experimental, schema, strings } from '@angular-devkit/core';
14+
import { JsonObject, UnknownException, experimental, schema, strings } from '@angular-devkit/core';
1715
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
1816
import { of } from 'rxjs';
1917
import { from } from 'rxjs';
@@ -98,11 +96,24 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
9896
return true;
9997
}
10098

101-
protected mapArchitectOptions(schema: any) {
99+
protected mapArchitectOptions(schema: JsonObject) {
102100
const properties = schema.properties;
101+
if (typeof properties != 'object' || properties === null || Array.isArray(properties)) {
102+
throw new UnknownException('Invalid schema.');
103+
}
103104
const keys = Object.keys(properties);
104105
keys
105-
.map(key => ({ ...properties[key], ...{ name: strings.dasherize(key) } }))
106+
.map(key => {
107+
const value = properties[key];
108+
if (typeof value != 'object') {
109+
throw new UnknownException('Invalid schema.');
110+
}
111+
112+
return {
113+
...value,
114+
name: strings.dasherize(key),
115+
} as any; // tslint:disable-line:no-any
116+
})
106117
.map(opt => {
107118
let type;
108119
const schematicType = opt.type;

0 commit comments

Comments
 (0)