Skip to content

Commit d202480

Browse files
clydinhansl
authored andcommitted
build: update/cleanup tslint rules & fix errors
1 parent a9e25ff commit d202480

File tree

30 files changed

+55
-87
lines changed

30 files changed

+55
-87
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import {
2020
tags,
2121
} from '@angular-devkit/core';
2222
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
23-
import { of } from 'rxjs';
24-
import { from } from 'rxjs';
23+
import { from, of } from 'rxjs';
2524
import { concatMap, map, tap, toArray } from 'rxjs/operators';
2625
import { Command, Option } from './command';
2726
import { WorkspaceLoader } from './workspace-loader';

packages/angular/cli/models/json-schema.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ export async function convertSchemaToOptions(schema: string): Promise<Option[]>
1616
}
1717

1818
function getOptions(schemaText: string, onlyRootProperties = true): Promise<Option[]> {
19-
// TODO: refactor promise to an observable then use `.toPromise()`
20-
return new Promise((resolve, reject) => {
19+
// TODO: Use devkit core's visitJsonSchema
20+
return new Promise((resolve) => {
2121
const fullSchema = parseJson(schemaText);
22+
if (!isJsonObject(fullSchema)) {
23+
return Promise.resolve([]);
24+
}
2225
const traverseOptions = {};
2326
const options: Option[] = [];
2427
function postCallback(schema: JsonObject,
2528
jsonPointer: string,
26-
rootSchema: string,
27-
parentJsonPointer: string,
29+
_rootSchema: string,
30+
_parentJsonPointer: string,
2831
parentKeyword: string,
29-
parentSchema: string,
32+
_parentSchema: string,
3033
property: string) {
3134
if (parentKeyword === 'properties') {
3235
let includeOption = true;
@@ -43,15 +46,15 @@ function getOptions(schemaText: string, onlyRootProperties = true): Promise<Opti
4346
}
4447
let $default: OptionSmartDefault | undefined = undefined;
4548
if (schema.$default !== null && isJsonObject(schema.$default)) {
46-
$default = <OptionSmartDefault> schema.$default;
49+
$default = schema.$default as OptionSmartDefault;
4750
}
4851
let required = false;
4952
if (typeof schema.required === 'boolean') {
5053
required = schema.required;
5154
}
5255
let aliases: string[] | undefined = undefined;
5356
if (typeof schema.aliases === 'object' && Array.isArray(schema.aliases)) {
54-
aliases = <string[]> schema.aliases;
57+
aliases = schema.aliases as string[];
5558
}
5659
let format: string | undefined = undefined;
5760
if (typeof schema.format === 'string') {
@@ -86,7 +89,7 @@ function getOptions(schemaText: string, onlyRootProperties = true): Promise<Opti
8689

8790
const callbacks = { post: postCallback };
8891

89-
jsonSchemaTraverse(<object> fullSchema, traverseOptions, callbacks);
92+
jsonSchemaTraverse(fullSchema, traverseOptions, callbacks);
9093
});
9194
}
9295

packages/angular_devkit/build_angular/src/dev-server/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
} from '@angular-devkit/architect';
1515
import { WebpackDevServerBuilder } from '@angular-devkit/build-webpack';
1616
import { Path, getSystemPath, resolve, tags, virtualFs } from '@angular-devkit/core';
17-
import { existsSync, readFileSync } from 'fs';
18-
import * as fs from 'fs';
17+
import { Stats, existsSync, readFileSync } from 'fs';
1918
import * as path from 'path';
2019
import { Observable, throwError } from 'rxjs';
2120
import { concatMap, map, tap } from 'rxjs/operators';
@@ -69,7 +68,7 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
6968
const options = builderConfig.options;
7069
const root = this.context.workspace.root;
7170
const projectRoot = resolve(root, builderConfig.root);
72-
const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<fs.Stats>);
71+
const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<Stats>);
7372
const webpackDevServerBuilder = new WebpackDevServerBuilder({ ...this.context, host });
7473
let browserOptions: BrowserBuilderSchema;
7574
let first = true;
@@ -175,7 +174,7 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
175174
buildWebpackConfig(
176175
root: Path,
177176
projectRoot: Path,
178-
host: virtualFs.Host<fs.Stats>,
177+
host: virtualFs.Host<Stats>,
179178
browserOptions: BrowserBuilderSchema,
180179
) {
181180
const browserBuilder = new BrowserBuilder(this.context);

packages/angular_devkit/core/node/host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ export class NodeJsSyncHost implements virtualFs.Host<fs.Stats> {
336336
}
337337

338338
isDirectory(path: Path): Observable<boolean> {
339-
// tslint:disable-next-line:non-null-operator
339+
// tslint:disable-next-line:no-non-null-assertion
340340
return this.stat(path) !.pipe(map(stat => stat.isDirectory()));
341341
}
342342
isFile(path: Path): Observable<boolean> {
343-
// tslint:disable-next-line:non-null-operator
343+
// tslint:disable-next-line:no-non-null-assertion
344344
return this.stat(path) !.pipe(map(stat => stat.isFile()));
345345
}
346346

packages/angular_devkit/core/node/host_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
// tslint:disable:no-any
9-
// tslint:disable:non-null-operator
9+
// tslint:disable:no-non-null-assertion
1010
// tslint:disable:no-implicit-dependencies
1111
import { normalize, virtualFs } from '@angular-devkit/core';
1212
import { NodeJsAsyncHost, NodeJsSyncHost } from '@angular-devkit/core/node';

packages/angular_devkit/core/src/json/schema/visitor_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function syncObs<T>(obs: Observable<T>): T {
2828
throw new Error('Async observable.');
2929
}
3030

31-
return value !; // tslint:disable-line:non-null-operator
31+
return value !; // tslint:disable-line:no-non-null-assertion
3232
}
3333

3434

packages/angular_devkit/core/src/virtual-fs/host/alias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class AliasHost<StatsT extends object = {}> extends ResolverHost<StatsT>
7474
maybeAlias = join(maybeAlias, ...remaining);
7575
}
7676
// Allow non-null-operator because we know sp.length > 0 (condition on while).
77-
remaining.unshift(sp.pop() !); // tslint:disable-line:non-null-operator
77+
remaining.unshift(sp.pop() !); // tslint:disable-line:no-non-null-assertion
7878
}
7979

8080
return maybeAlias || path;

packages/angular_devkit/core/src/virtual-fs/host/memory_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
// tslint:disable:no-implicit-dependencies
9-
// tslint:disable:non-null-operator
9+
// tslint:disable:no-non-null-assertion
1010
import { fragment, normalize } from '@angular-devkit/core';
1111
import { stringToFileBuffer } from './buffer';
1212
import { SimpleMemoryHost } from './memory';

packages/angular_devkit/core/src/virtual-fs/host/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class SyncDelegateHost<T extends object = {}> {
5353
// The non-null operation is to work around `void` type. We don't allow to return undefined
5454
// but ResultT could be void, which is undefined in JavaScript, so this doesn't change the
5555
// behaviour.
56-
// tslint:disable-next-line:non-null-operator
56+
// tslint:disable-next-line:no-non-null-assertion
5757
return result !;
5858
}
5959

packages/angular_devkit/schematics/src/engine/schematic_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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-
// tslint:disable:non-null-operator
8+
// tslint:disable:no-non-null-assertion
99
import { logging } from '@angular-devkit/core';
1010
import { of as observableOf } from 'rxjs';
1111
import { chain } from '../rules/base';

0 commit comments

Comments
 (0)