Skip to content

Commit 70a4cbe

Browse files
alan-agius4vikerman
authored andcommitted
style: enable no-debugger and no-console tslint rules
1 parent 4bfa4e0 commit 70a4cbe

File tree

16 files changed

+262
-245
lines changed

16 files changed

+262
-245
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
122122
collectionName = manifest.name;
123123

124124
if (await this.hasMismatchedPeer(manifest)) {
125-
console.warn('Package has unmet peer dependencies. Adding the package may not succeed.');
125+
this.logger.warn(
126+
'Package has unmet peer dependencies. Adding the package may not succeed.',
127+
);
126128
}
127129
} catch (e) {
128130
this.logger.error('Unable to fetch package manifest: ' + e.message);

packages/angular/cli/lib/cli/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { colors, supportsColor } from '../../utilities/color';
1313
import { getWorkspaceRaw } from '../../utilities/config';
1414
import { getWorkspaceDetails } from '../../utilities/project';
1515

16+
// tslint:disable: no-console
1617
export default async function(options: { testing?: boolean; cliArgs: string[] }) {
1718
const logger = createConsoleLogger(false, process.stdout, process.stderr, {
1819
info: s => (supportsColor ? s : colors.unstyle(s)),
@@ -95,6 +96,7 @@ export default async function(options: { testing?: boolean; cliArgs: string[] })
9596
}
9697

9798
if (options.testing) {
99+
// tslint:disable-next-line: no-debugger
98100
debugger;
99101
throw err;
100102
}

packages/angular/cli/lib/init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
import 'symbol-observable';
99
// symbol polyfill must go first
10+
// tslint:disable: no-console
1011
// tslint:disable-next-line:ordered-imports import-groups
1112
import { tags } from '@angular-devkit/core';
1213
import * as fs from 'fs';

packages/angular/cli/models/analytics.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { colors } from '../utilities/color';
1717
import { getWorkspace, getWorkspaceRaw } from '../utilities/config';
1818
import { isTTY } from '../utilities/tty';
1919

20+
// tslint:disable: no-console
2021
const analyticsDebug = debug('ng:analytics'); // Generate analytics, including settings and users.
2122
const analyticsLogDebug = debug('ng:analytics:log'); // Actual logs of events.
2223

packages/angular_devkit/architect_cli/bin/architect.ts

+68-78
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,14 @@
88
*/
99
import { Architect, BuilderInfo, BuilderProgressState, Target } from '@angular-devkit/architect';
1010
import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node';
11-
import {
12-
json,
13-
logging,
14-
schema,
15-
tags,
16-
terminal,
17-
workspaces,
18-
} from '@angular-devkit/core';
11+
import { json, logging, schema, tags, terminal, workspaces } from '@angular-devkit/core';
1912
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
2013
import { existsSync } from 'fs';
2114
import * as minimist from 'minimist';
2215
import * as path from 'path';
2316
import { tap } from 'rxjs/operators';
2417
import { MultiProgressBar } from '../src/progress';
2518

26-
2719
function findUp(names: string | string[], from: string) {
2820
if (!Array.isArray(names)) {
2921
names = [names];
@@ -64,21 +56,19 @@ function usage(logger: logging.Logger, exitCode = 0): never {
6456
`);
6557

6658
process.exit(exitCode);
67-
throw 0; // The node typing sometimes don't have a never type for process.exit().
59+
throw 0; // The node typing sometimes don't have a never type for process.exit().
6860
}
6961

70-
function _targetStringFromTarget({project, target, configuration}: Target) {
62+
function _targetStringFromTarget({ project, target, configuration }: Target) {
7163
return `${project}:${target}${configuration !== undefined ? ':' + configuration : ''}`;
7264
}
7365
74-
7566
interface BarInfo {
7667
status?: string;
7768
builder: BuilderInfo;
7869
target?: Target;
7970
}
8071
81-
8272
async function _executeTarget(
8373
parentLogger: logging.Logger,
8474
workspace: workspaces.WorkspaceDefinition,
@@ -104,63 +94,64 @@ async function _executeTarget(
10494
const run = await architect.scheduleTarget(targetSpec, argv, { logger });
10595
const bars = new MultiProgressBar<number, BarInfo>(':name :bar (:current/:total) :status');
10696
107-
run.progress.subscribe(
108-
update => {
109-
const data = bars.get(update.id) || {
110-
id: update.id,
111-
builder: update.builder,
112-
target: update.target,
113-
status: update.status || '',
114-
name: ((update.target ? _targetStringFromTarget(update.target) : update.builder.name)
115-
+ ' '.repeat(80)
116-
).substr(0, 40),
117-
};
118-
119-
if (update.status !== undefined) {
120-
data.status = update.status;
121-
}
97+
run.progress.subscribe(update => {
98+
const data = bars.get(update.id) || {
99+
id: update.id,
100+
builder: update.builder,
101+
target: update.target,
102+
status: update.status || '',
103+
name: (
104+
(update.target ? _targetStringFromTarget(update.target) : update.builder.name) +
105+
' '.repeat(80)
106+
).substr(0, 40),
107+
};
108+
109+
if (update.status !== undefined) {
110+
data.status = update.status;
111+
}
122112
123-
switch (update.state) {
124-
case BuilderProgressState.Error:
125-
data.status = 'Error: ' + update.error;
126-
bars.update(update.id, data);
127-
break;
128-
129-
case BuilderProgressState.Stopped:
130-
data.status = 'Done.';
131-
bars.complete(update.id);
132-
bars.update(update.id, data, update.total, update.total);
133-
break;
134-
135-
case BuilderProgressState.Waiting:
136-
bars.update(update.id, data);
137-
break;
138-
139-
case BuilderProgressState.Running:
140-
bars.update(update.id, data, update.current, update.total);
141-
break;
142-
}
113+
switch (update.state) {
114+
case BuilderProgressState.Error:
115+
data.status = 'Error: ' + update.error;
116+
bars.update(update.id, data);
117+
break;
118+
119+
case BuilderProgressState.Stopped:
120+
data.status = 'Done.';
121+
bars.complete(update.id);
122+
bars.update(update.id, data, update.total, update.total);
123+
break;
124+
125+
case BuilderProgressState.Waiting:
126+
bars.update(update.id, data);
127+
break;
128+
129+
case BuilderProgressState.Running:
130+
bars.update(update.id, data, update.current, update.total);
131+
break;
132+
}
143133
144-
bars.render();
145-
},
146-
);
134+
bars.render();
135+
});
147136
148137
// Wait for full completion of the builder.
149138
try {
150-
const { success } = await run.output.pipe(
151-
tap(result => {
152-
if (result.success) {
153-
parentLogger.info(terminal.green('SUCCESS'));
154-
} else {
155-
parentLogger.info(terminal.yellow('FAILURE'));
156-
}
157-
parentLogger.info('Result: ' + JSON.stringify({ ...result, info: undefined }, null, 4));
158-
159-
parentLogger.info('\nLogs:');
160-
logs.forEach(l => parentLogger.next(l));
161-
logs.splice(0);
162-
}),
163-
).toPromise();
139+
const { success } = await run.output
140+
.pipe(
141+
tap(result => {
142+
if (result.success) {
143+
parentLogger.info(terminal.green('SUCCESS'));
144+
} else {
145+
parentLogger.info(terminal.yellow('FAILURE'));
146+
}
147+
parentLogger.info('Result: ' + JSON.stringify({ ...result, info: undefined }, null, 4));
148+
149+
parentLogger.info('\nLogs:');
150+
logs.forEach(l => parentLogger.next(l));
151+
logs.splice(0);
152+
}),
153+
)
154+
.toPromise();
164155
165156
await run.stop();
166157
bars.terminate();
@@ -178,7 +169,6 @@ async function _executeTarget(
178169
}
179170
}
180171
181-
182172
async function main(args: string[]): Promise<number> {
183173
/** Parse the command line. */
184174
const argv = minimist(args, { boolean: ['help'] });
@@ -195,18 +185,15 @@ async function main(args: string[]): Promise<number> {
195185
196186
// Load workspace configuration file.
197187
const currentPath = process.cwd();
198-
const configFileNames = [
199-
'angular.json',
200-
'.angular.json',
201-
'workspace.json',
202-
'.workspace.json',
203-
];
188+
const configFileNames = ['angular.json', '.angular.json', 'workspace.json', '.workspace.json'];
204189
205190
const configFilePath = findUp(configFileNames, currentPath);
206191
207192
if (!configFilePath) {
208-
logger.fatal(`Workspace configuration file (${configFileNames.join(', ')}) cannot be found in `
209-
+ `'${currentPath}' or in parent directories.`);
193+
logger.fatal(
194+
`Workspace configuration file (${configFileNames.join(', ')}) cannot be found in ` +
195+
`'${currentPath}' or in parent directories.`,
196+
);
210197

211198
return 3;
212199
}
@@ -227,10 +214,13 @@ async function main(args: string[]): Promise<number> {
227214
return await _executeTarget(logger, workspace, root, argv, registry);
228215
}
229216

230-
main(process.argv.slice(2))
231-
.then(code => {
217+
main(process.argv.slice(2)).then(
218+
code => {
232219
process.exit(code);
233-
}, err => {
220+
},
221+
err => {
222+
// tslint:disable-next-line: no-console
234223
console.error('Error: ' + err.stack || err.message || err);
235224
process.exit(-1);
236-
});
225+
},
226+
);

packages/angular_devkit/build_optimizer/src/build-optimizer/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { writeFileSync } from 'fs';
1010
import { join } from 'path';
1111
import { buildOptimizer } from './build-optimizer';
1212

13-
13+
// tslint:disable: no-console
1414
if (process.argv.length < 3 || process.argv.length > 4) {
1515
throw new Error(`
1616
build-optimizer should be called with either one or two arguments:
@@ -30,7 +30,7 @@ if (!inputFile.match(tsOrJsRegExp)) {
3030
}
3131

3232
// Use provided output file, or add the .bo suffix before the extension.
33-
const outputFile = process.argv[3] || inputFile.replace(tsOrJsRegExp, (subStr) => `.bo${subStr}`);
33+
const outputFile = process.argv[3] || inputFile.replace(tsOrJsRegExp, subStr => `.bo${subStr}`);
3434

3535
const boOutput = buildOptimizer({
3636
inputFilePath: join(currentDir, inputFile),

packages/angular_devkit/build_optimizer/src/build-optimizer/rollup-plugin.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,27 @@ export default function optimizer(options: Options) {
3131

3232
return {
3333
name: 'build-optimizer',
34-
transform: (content: string, id: string): {code: string, map: RawSourceMap}|null => {
34+
transform: (content: string, id: string): { code: string; map: RawSourceMap } | null => {
3535
const normalizedId = id.replace(/\\/g, '/');
36-
const isSideEffectFree = options.sideEffectFreeModules &&
36+
const isSideEffectFree =
37+
options.sideEffectFreeModules &&
3738
options.sideEffectFreeModules.some(m => normalizedId.indexOf(m) >= 0);
38-
const isAngularCoreFile = options.angularCoreModules &&
39+
const isAngularCoreFile =
40+
options.angularCoreModules &&
3941
options.angularCoreModules.some(m => normalizedId.indexOf(m) >= 0);
4042
const { content: code, sourceMap: map } = buildOptimizer({
41-
content, inputFilePath: id, emitSourceMap: true, isSideEffectFree, isAngularCoreFile,
43+
content,
44+
inputFilePath: id,
45+
emitSourceMap: true,
46+
isSideEffectFree,
47+
isAngularCoreFile,
4248
});
4349
if (!code) {
4450
if (DEBUG) {
45-
console.error('no transforms produced by buildOptimizer for '
46-
+ path.relative(process.cwd(), id));
51+
// tslint:disable-next-line: no-console
52+
console.error(
53+
'no transforms produced by buildOptimizer for ' + path.relative(process.cwd(), id),
54+
);
4755
}
4856

4957
return null;

packages/ngtools/webpack/src/benchmark.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Use with CLI --no-progress flag for best results.
1010
// This should be false for commited code.
1111
const _benchmark = false;
12-
12+
// tslint:disable:no-console
1313
export function time(label: string) {
1414
if (_benchmark) {
1515
console.time(label);

0 commit comments

Comments
 (0)