Skip to content

Commit f1b1149

Browse files
committed
style: fix lint issues
1 parent 59d5dbc commit f1b1149

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+246
-196
lines changed

modules/aspnetcore-engine/src/file-loader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
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 * as fs from 'fs';
98
import { ResourceLoader } from '@angular/compiler';
9+
import * as fs from 'fs';
1010

1111
/** ResourceLoader implementation for loading files */
1212
export class FileLoader implements ResourceLoader {

modules/aspnetcore-engine/src/interfaces/engine-options.ts

+1-1
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-
import { Type, NgModuleFactory, StaticProvider } from '@angular/core';
8+
import { NgModuleFactory, StaticProvider, Type } from '@angular/core';
99
import { IRequestParams } from './request-params';
1010

1111
export interface IEngineOptions {

modules/aspnetcore-engine/src/main.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
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 {Type, NgModuleFactory, CompilerFactory, Compiler, StaticProvider} from '@angular/core';
9-
import { platformDynamicServer } from '@angular/platform-server';
108
import { DOCUMENT } from '@angular/common';
119
import { ResourceLoader } from '@angular/compiler';
10+
import { Compiler, CompilerFactory, NgModuleFactory, StaticProvider, Type } from '@angular/core';
11+
import { platformDynamicServer } from '@angular/platform-server';
1212

13-
import { REQUEST, ORIGIN_URL } from '@nguniversal/aspnetcore-engine/tokens';
13+
import { ORIGIN_URL, REQUEST } from '@nguniversal/aspnetcore-engine/tokens';
1414
import { FileLoader } from './file-loader';
1515
import { IEngineOptions } from './interfaces/engine-options';
1616
import { IEngineRenderResult } from './interfaces/engine-render-result';
@@ -37,7 +37,9 @@ function _getUniversalData(doc: Document): UniversalData {
3737
const META: string[] = [];
3838
const LINKS: string[] = [];
3939

40+
// tslint:disable-next-line: no-non-null-assertion
4041
for (let i = 0; i < doc.head!.children.length; i++) {
42+
// tslint:disable-next-line: no-non-null-assertion
4143
const element = doc.head!.children[i];
4244
const tagName = element.tagName.toUpperCase();
4345

@@ -83,6 +85,7 @@ function _getUniversalData(doc: Document): UniversalData {
8385

8486
return {
8587
title: doc.title,
88+
// tslint:disable-next-line: no-non-null-assertion
8689
appNode: doc.querySelector(appSelector)!.outerHTML,
8790
scripts: SCRIPTS.join('\n'),
8891
styles: STYLES.join('\n'),
@@ -158,6 +161,7 @@ function getReqResProviders(origin: string, request: string): StaticProvider[] {
158161
useValue: request
159162
}
160163
];
164+
161165
return providers;
162166
}
163167

@@ -170,7 +174,7 @@ async function getFactory(
170174
if (moduleOrFactory instanceof NgModuleFactory) {
171175
return moduleOrFactory;
172176
} else {
173-
let moduleFactory = factoryCacheMap.get(moduleOrFactory);
177+
const moduleFactory = factoryCacheMap.get(moduleOrFactory);
174178
// If module factory is cached
175179
if (moduleFactory) {
176180
return moduleFactory;
@@ -179,6 +183,7 @@ async function getFactory(
179183
// Compile the module and cache it
180184
const factory = await compiler.compileModuleAsync(moduleOrFactory);
181185
factoryCacheMap.set(moduleOrFactory, factory);
186+
182187
return factory;
183188
}
184189
}

modules/aspnetcore-engine/src/platform-server-utils.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ import {
2020
StaticProvider,
2121
Type
2222
} from '@angular/core';
23-
import {ɵTRANSITION_ID} from '@angular/platform-browser';
23+
import { ɵTRANSITION_ID } from '@angular/platform-browser';
2424
import {
25-
platformDynamicServer,
26-
platformServer,
2725
BEFORE_APP_SERIALIZED,
2826
INITIAL_CONFIG,
29-
PlatformState
27+
PlatformState,
28+
platformDynamicServer,
29+
platformServer
3030
} from '@angular/platform-server';
31-
import {first} from 'rxjs/operators';
31+
import { first } from 'rxjs/operators';
3232

3333
interface PlatformOptions {
3434
document?: string;
@@ -45,14 +45,17 @@ function _getPlatform(
4545
platformFactory: (extraProviders: StaticProvider[]) => PlatformRef,
4646
options: PlatformOptions): PlatformRef {
4747
const extraProviders = options.extraProviders ? options.extraProviders : [];
48+
4849
return platformFactory([
4950
{ provide: INITIAL_CONFIG, useValue: { document: options.document, url: options.url } },
5051
extraProviders
5152
]);
5253
}
5354

54-
async function _render<T>(platform: PlatformRef,
55-
moduleRefPromise: Promise<NgModuleRef<T>>): Promise<ModuleRenderResult<T>> {
55+
async function _render<T>(
56+
platform: PlatformRef,
57+
moduleRefPromise: Promise<NgModuleRef<T>>,
58+
): Promise<ModuleRenderResult<T>> {
5659
const moduleRef = await moduleRefPromise;
5760
const transitionId = moduleRef.injector.get(ɵTRANSITION_ID, null);
5861
if (!transitionId) {
@@ -75,12 +78,14 @@ async function _render<T>(platform: PlatformRef,
7578
callback();
7679
} catch (e) {
7780
// Ignore exceptions.
81+
// tslint:disable-next-line: no-console
7882
console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
7983
}
8084
}
8185
}
8286
const output = platformState.renderToString();
8387
platform.destroy();
88+
8489
return { html: output, moduleRef };
8590
}
8691

@@ -100,6 +105,7 @@ export function renderModule<T>(
100105
module: Type<T>, options: { document?: string, url?: string, extraProviders?: StaticProvider[] }):
101106
Promise<ModuleRenderResult<T>> {
102107
const platform = _getPlatform(platformDynamicServer, options);
108+
103109
return _render(platform, platform.bootstrapModule(module));
104110
}
105111

@@ -117,5 +123,6 @@ export function renderModuleFactory<T>(
117123
options: { document?: string, url?: string, extraProviders?: StaticProvider[] }):
118124
Promise<ModuleRenderResult<T>> {
119125
const platform = _getPlatform(platformServer, options);
126+
120127
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
121128
}

modules/builders/src/prerender/index.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { Architect } from '@angular-devkit/architect';
10-
import { createArchitect, host, outputPathBrowser } from '../../testing/utils';
1110
import { join, virtualFs } from '@angular-devkit/core';
11+
import { createArchitect, host, outputPathBrowser } from '../../testing/utils';
1212

1313
describe('Prerender Builder', () => {
1414
const target = { project: 'app', target: 'prerender' };

modules/builders/src/prerender/index.ts

+2-1
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

9-
import { BuilderOutput, createBuilder, BuilderContext, targetFromTargetString } from '@angular-devkit/architect';
9+
import { BuilderContext, BuilderOutput, createBuilder, targetFromTargetString } from '@angular-devkit/architect';
1010
import { json } from '@angular-devkit/core';
1111
import { Buffer } from 'buffer';
1212
import * as fs from 'fs';
@@ -116,6 +116,7 @@ async function _renderUniversal(
116116
}
117117
}
118118
}
119+
119120
return browserResult;
120121
}
121122

modules/builders/src/prerender/utils.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { getRoutes } from './utils';
109
import * as fs from 'fs';
10+
import { getRoutes } from './utils';
1111

1212
describe('Prerender Builder Utils', () => {
1313
describe('#getRoutes', () => {

modules/builders/src/ssr-dev-server/index.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*/
88

99
import { Architect, BuilderRun } from '@angular-devkit/architect';
10-
import { debounceTime, take, concatMap, retryWhen, mergeMap } from 'rxjs/operators';
1110
import * as browserSync from 'browser-sync';
11+
import { concatMap, debounceTime, mergeMap, retryWhen, take } from 'rxjs/operators';
1212

13+
import { from, throwError, timer } from 'rxjs';
1314
import { createArchitect, host } from '../../testing/utils';
1415
import { SSRDevServerBuilderOutput } from './index';
15-
import { from, throwError, timer } from 'rxjs';
1616

1717
// todo check why it resolves to mjs
1818
// [ERR_REQUIRE_ESM]: Must use import to load ES Module
@@ -46,7 +46,7 @@ describe('Serve SSR Builder', () => {
4646
expect(output.success).toBe(true);
4747
expect(output.baseUrl).toBe('http://localhost:4200');
4848

49-
const response = await from(fetch(output.baseUrl!)).pipe(
49+
const response = await from(fetch(output.baseUrl as string)).pipe(
5050
retryWhen(err => err.pipe(
5151
mergeMap((error, attempts) => {
5252
return attempts > 10 || error.code !== 'ECONNRESET'
@@ -81,7 +81,7 @@ describe('Serve SSR Builder', () => {
8181
concatMap(async (output, index) => {
8282
expect(output.baseUrl).toBe('http://localhost:7001');
8383
expect(output.success).toBe(true, `index: ${index}`);
84-
const response = await fetch(output.baseUrl!);
84+
const response = await fetch(output.baseUrl as string);
8585
const text = await response.text();
8686

8787
switch (index) {

modules/builders/src/ssr-dev-server/index.ts

+27-21
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@
77
*/
88

99
import {
10+
BuilderContext,
1011
BuilderOutput,
1112
createBuilder,
12-
BuilderContext,
1313
targetFromTargetString,
1414
} from '@angular-devkit/architect';
15-
import { json, tags, logging } from '@angular-devkit/core';
15+
import { json, logging, tags } from '@angular-devkit/core';
16+
import * as browserSync from 'browser-sync';
17+
import * as proxy from 'http-proxy-middleware';
18+
import { join } from 'path';
1619
import {
20+
EMPTY,
1721
Observable,
18-
of,
1922
combineLatest,
20-
zip,
2123
from,
22-
EMPTY,
24+
of,
25+
zip,
2326
} from 'rxjs';
24-
import { Schema } from './schema';
2527
import {
26-
switchMap,
27-
map,
28-
tap,
2928
catchError,
30-
startWith,
31-
mapTo,
32-
ignoreElements,
33-
finalize,
3429
concatMap,
3530
debounce,
3631
debounceTime,
3732
delay,
33+
finalize,
34+
ignoreElements,
35+
map,
36+
mapTo,
37+
startWith,
38+
switchMap,
39+
tap,
3840
} from 'rxjs/operators';
39-
import * as browserSync from 'browser-sync';
40-
import { join } from 'path';
4141
import * as url from 'url';
42-
import * as proxy from 'http-proxy-middleware';
42+
import { Schema } from './schema';
4343

4444
import { getAvailablePort, spawnAsObservable, waitUntilServerIsListening } from './utils';
4545

@@ -97,23 +97,28 @@ export function execute(
9797
if (!s.success) {
9898
return of(s);
9999
}
100+
100101
return startNodeServer(s, nodeServerPort, context.logger).pipe(
101102
mapTo(s),
102103
catchError(err => {
103104
context.logger.error(`A server error has occurred.\n${mapErrorToMessage(err)}`);
105+
104106
return EMPTY;
105107
}),
106108
);
107109
}));
108110

109-
return combineLatest(br.output, server$).pipe(
111+
return combineLatest([br.output, server$]).pipe(
110112
// This is needed so that if both server and browser emit close to each other
111113
// we only emit once. This typically happens on the first build.
112114
debounceTime(120),
113-
map(([b, s]) => ([{
114-
success: b.success && s.success,
115-
error: b.error || s.error,
116-
}, nodeServerPort] as [SSRDevServerBuilderOutput, number])),
115+
map(([b, s]) => ([
116+
{
117+
success: b.success && s.success,
118+
error: b.error || s.error,
119+
},
120+
nodeServerPort,
121+
] as [SSRDevServerBuilderOutput, number])),
117122
tap(([builderOutput]) => {
118123
if (builderOutput.success) {
119124
context.logger.info('\nCompiled successfully.');
@@ -131,6 +136,7 @@ export function execute(
131136

132137
if (bsInstance.active) {
133138
bsInstance.reload();
139+
134140
return of(builderOutput);
135141
} else {
136142
return from(initBrowserSync(bsInstance, nodeServerPort, options))

modules/builders/src/ssr-dev-server/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { spawn, SpawnOptions } from 'child_process';
9+
import { SpawnOptions, spawn } from 'child_process';
10+
import { AddressInfo, createConnection, createServer } from 'net';
1011
import { Observable, throwError, timer } from 'rxjs';
12+
import { mergeMap, retryWhen } from 'rxjs/operators';
1113
import * as treeKill from 'tree-kill';
12-
import { createServer, AddressInfo, createConnection } from 'net';
13-
import { retryWhen, mergeMap } from 'rxjs/operators';
1414

1515
export function getAvailablePort(): Promise<number> {
1616
return new Promise((resolve, reject) => {

modules/builders/testing/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88

99
import { Architect } from '@angular-devkit/architect';
1010
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
11-
import { TestingArchitectHost, TestProjectHost } from '@angular-devkit/architect/testing';
11+
import { TestProjectHost, TestingArchitectHost } from '@angular-devkit/architect/testing';
1212
import {
1313
Path,
1414
getSystemPath,
1515
normalize,
1616
schema,
1717
workspaces,
1818
} from '@angular-devkit/core';
19-
import { mkdirSync, symlinkSync, existsSync } from 'fs';
19+
import { existsSync, mkdirSync, symlinkSync } from 'fs';
2020
import * as path from 'path';
2121
import { cp } from 'shelljs';
2222

2323
// Add link from src -> tmp hello-world-app
2424
const templateRoot = path.join(
25-
process.env.TEST_TMPDIR!,
25+
process.env.TEST_TMPDIR as string,
2626
`hello-world-app-${Math.random().toString(36).slice(2)}`,
2727
);
2828

@@ -39,7 +39,7 @@ cp(
3939
// link node packages
4040
symlinkSync(
4141
path.join(require.resolve('npm/node_modules/@angular/core/package.json'), '../../../'),
42-
path.join(process.env.TEST_TMPDIR!, 'node_modules'),
42+
path.join(process.env.TEST_TMPDIR as string, 'node_modules'),
4343
'junction'
4444
);
4545

0 commit comments

Comments
 (0)