Skip to content

Commit 77f2dfd

Browse files
committed
refactor: additional lint fixes
1 parent 796a51e commit 77f2dfd

24 files changed

+63
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:messages": "node scripts/test-commit-messages.js",
2424
"test:packages": "node scripts/run-packages-spec.js",
2525
"eslint": "eslint .",
26-
"tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/config/schema.d.ts\" -e \"**/tests/**\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"",
26+
"tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/config/schema.d.ts\" -e \"**/tests/**\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\" -e \"tools/**\"",
2727
"lint": "npm-run-all -c eslint tslint",
2828
"tool": "node scripts/run-tool.js"
2929
},

packages/@angular/cli/commands/add.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { tags, terminal } from '@angular-devkit/core';
23
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
34
import { CommandScope, Option } from '../models/command';

packages/@angular/cli/commands/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default class BuildCommand extends ArchitectCommand {
1818
// Check Angular and TypeScript versions.
1919
Version.assertCompatibleAngularVersion(this.project.root);
2020
Version.assertTypescriptVersion(this.project.root);
21+
2122
return super.validate(options);
2223
}
2324

packages/@angular/cli/commands/config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function setValueFromPath<T extends JsonArray | JsonObject>(
105105
value[current] = {};
106106
}
107107
}
108+
108109
return value[current];
109110
} else if (typeof current == 'number' && Array.isArray(value)) {
110111
if (index === fragments.length - 1) {
@@ -116,6 +117,7 @@ function setValueFromPath<T extends JsonArray | JsonObject>(
116117
value[current] = {};
117118
}
118119
}
120+
119121
return value[current];
120122
} else {
121123
return undefined;
@@ -211,7 +213,12 @@ export default class ConfigCommand extends Command {
211213
}
212214

213215
private get(config: experimental.workspace.WorkspaceSchema, options: ConfigOptions) {
214-
const value = options.jsonPath ? getValueFromPath(config as any, options.jsonPath) : config;
216+
let value;
217+
if (options.jsonPath) {
218+
value = getValueFromPath(config as {} as JsonObject, options.jsonPath);
219+
} else {
220+
value = config;
221+
}
215222

216223
if (value === undefined) {
217224
this.logger.error('Value cannot be found.');

packages/@angular/cli/commands/doc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class DocCommand extends Command {
2424
public validate(options: Options) {
2525
if (!options.keyword) {
2626
this.logger.error(`keyword argument is required.`);
27+
2728
return false;
2829
}
2930
}

packages/@angular/cli/commands/easter-egg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class AwesomeCommand extends Command {
1212
readonly arguments: string[] = [];
1313
readonly options: Option[] = [];
1414

15-
run(_options: any) {
15+
run() {
1616
const phrase = pickOne([
1717
`You're on it, there's nothing for me to do!`,
1818
`Let's take a look... nope, it's all good!`,

packages/@angular/cli/commands/generate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { tags, terminal } from '@angular-devkit/core';
23
import { CommandScope, Option } from '../models/command';
34
import { SchematicCommand } from '../models/schematic-command';

packages/@angular/cli/commands/help.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { terminal } from '@angular-devkit/core';
23
import { Command, Option } from '../models/command';
34

@@ -13,6 +14,7 @@ export default class HelpCommand extends Command {
1314
.map(key => {
1415
const Cmd = options.commandMap[key];
1516
const command: Command = new Cmd(null, null);
17+
1618
return command;
1719
})
1820
.filter(cmd => !cmd.hidden && !cmd.unknown)

packages/@angular/cli/commands/new.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { CommandScope, Option } from '../models/command';
23
import { SchematicCommand } from '../models/schematic-command';
34
import { getDefaultSchematicCollection } from '../utilities/config';
@@ -93,6 +94,7 @@ export default class NewCommand extends SchematicCommand {
9394
const opts = Object.assign({}, options);
9495
delete opts.verbose;
9596
delete opts.collection;
97+
9698
return opts;
9799
}
98100
}

packages/@angular/cli/commands/serve.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default class ServeCommand extends ArchitectCommand {
1818
// Check Angular and TypeScript versions.
1919
Version.assertCompatibleAngularVersion(this.project.root);
2020
Version.assertTypescriptVersion(this.project.root);
21+
2122
return true;
2223
}
2324

packages/@angular/cli/commands/update.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { normalize } from '@angular-devkit/core';
23
import { CommandScope, Option } from '../models/command';
34
import { CoreSchematicOptions, SchematicCommand } from '../models/schematic-command';

packages/@angular/cli/commands/version.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export default class VersionCommand extends Command {
1313
public readonly arguments: string[] = [];
1414
public readonly options: Option[] = [];
1515

16-
public run(_options: any) {
16+
public run() {
1717
let angularCoreVersion = '';
1818
const angularSameAsCore: string[] = [];
1919
const pkg = require(path.resolve(__dirname, '..', 'package.json'));
20-
let projPkg: any;
20+
let projPkg;
2121
try {
2222
projPkg = require(path.resolve(this.project.root, 'package.json'));
2323
} catch (exception) {
@@ -66,6 +66,7 @@ export default class VersionCommand extends Command {
6666
}
6767

6868
acc[name] = this.getVersion(name, packageRoot, maybeNodeModules);
69+
6970
return acc;
7071
}, {} as { [module: string]: string });
7172

@@ -124,6 +125,7 @@ export default class VersionCommand extends Command {
124125
} else {
125126
acc[acc.length - 1] = line;
126127
}
128+
127129
return acc;
128130
}, []).join('\n... ')}
129131
@@ -144,6 +146,7 @@ export default class VersionCommand extends Command {
144146
try {
145147
if (projectNodeModules) {
146148
const modulePkg = require(path.resolve(projectNodeModules, moduleName, 'package.json'));
149+
147150
return modulePkg.version;
148151
}
149152
} catch (_) {
@@ -152,6 +155,7 @@ export default class VersionCommand extends Command {
152155
try {
153156
if (cliNodeModules) {
154157
const modulePkg = require(path.resolve(cliNodeModules, moduleName, 'package.json'));
158+
155159
return modulePkg.version + ' (cli-only)';
156160
}
157161
} catch (e) {

packages/@angular/cli/custom-typings.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
declare module 'yargs-parser' {
23
const parseOptions: any;
34
const yargsParser: <T = any>(args: string | string[], options?: parseOptions) => T;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function loadCommands() {
3939
};
4040
}
4141

42-
export default async function(options: any) {
42+
export default async function(options: { testing?: boolean, cliArgs: string[] }) {
4343
const commands = loadCommands();
4444

4545
const logger = new logging.IndentLogger('cling');
@@ -83,6 +83,7 @@ export default async function(options: any) {
8383
}
8484

8585
loggingSubscription.unsubscribe();
86+
8687
return 1;
8788
}
8889
}

packages/@angular/cli/lib/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ function _fromPackageJson(cwd?: string) {
4141

4242
// Check if we need to profile this CLI run.
4343
if (process.env['NG_CLI_PROFILING']) {
44-
const profiler = require('v8-profiler');
44+
const profiler = require('v8-profiler'); // tslint:disable-line:no-implicit-dependencies
4545
profiler.startProfiling();
46-
function exitHandler(options: any, _err: Error) {
46+
function exitHandler(options: { cleanup: boolean, exit: boolean }, _err: Error) {
4747
if (options.cleanup) {
4848
const cpuProfile = profiler.stopProfiling();
4949
fs.writeFileSync(path.resolve(process.cwd(), process.env.NG_CLI_PROFILING) + '.cpuprofile',

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// tslint:disable:no-any
12
import {
2-
Architect, BuildEvent, BuilderDescription,
3+
Architect,
4+
BuildEvent,
5+
BuilderDescription,
36
TargetSpecifier,
47
} from '@angular-devkit/architect';
58
import { JsonObject, experimental, schema, strings } from '@angular-devkit/core';
@@ -84,6 +87,7 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
8487
+ `'${this.target}' would be run on the following projects: ${projectNames.join()}`);
8588
}
8689
}
90+
8791
return true;
8892
}
8993

@@ -187,6 +191,7 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
187191

188192
if (newErrors.length > 0) {
189193
this.logger.error(new schema.SchemaValidationException(newErrors).message);
194+
190195
return 1;
191196
}
192197
} else {

packages/@angular/cli/models/command-runner.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { logging, tags } from '@angular-devkit/core';
23
import { camelize } from '@angular-devkit/core/src/utils/strings';
34
import {
@@ -85,6 +86,7 @@ export async function runCommand(commandMap: CommandMap,
8586
if (!(b in commandsDistance)) {
8687
commandsDistance[b] = levenshtein(b, commandName);
8788
}
89+
8890
return commandsDistance[a] - commandsDistance[b];
8991
});
9092

@@ -176,6 +178,7 @@ export function parseOptions<T = any>(
176178
.reduce((aliases: any, opt: Option) => {
177179
aliases[opt.name] = opt.aliases
178180
.filter(a => a.length === 1);
181+
179182
return aliases;
180183
}, {});
181184

@@ -187,6 +190,7 @@ export function parseOptions<T = any>(
187190
.filter(o => o.default !== undefined || booleans.indexOf(o.name) !== -1)
188191
.reduce((defaults: any, opt: Option) => {
189192
defaults[opt.name] = opt.default;
193+
190194
return defaults;
191195
}, {});
192196

@@ -277,6 +281,7 @@ function findCommand(map: CommandMap, name: string): CommandConstructor | null {
277281
if (!Cmd) {
278282
return null;
279283
}
284+
280285
return Cmd;
281286
}
282287

packages/@angular/cli/models/command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { logging, terminal } from '@angular-devkit/core';
23

34
export interface CommandConstructor {
@@ -30,6 +31,7 @@ export abstract class Command<T = any> {
3031

3132
async initializeRaw(args: string[]): Promise<any> {
3233
this._rawArgs = args;
34+
3335
return args;
3436
}
3537
async initialize(_options: any): Promise<void> {

packages/@angular/cli/models/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class NgToolkitError extends Error {
55
if (message) {
66
this.message = message;
77
} else {
8-
this.message = (<any> this.constructor).name;
8+
this.message = this.constructor.name;
99
}
1010
}
1111
}

packages/@angular/cli/models/schematic-command.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { JsonObject, experimental } from '@angular-devkit/core';
23
import { normalize, strings, tags, terminal, virtualFs } from '@angular-devkit/core';
34
import { NodeJsSyncHost } from '@angular-devkit/core/node';
@@ -70,12 +71,14 @@ export abstract class SchematicCommand extends Command {
7071
if (workingDir === '') {
7172
return {};
7273
}
74+
7375
return this.options
7476
.filter(o => o.format === 'path')
7577
.map(o => o.name)
7678
.filter(name => options[name] === undefined)
7779
.reduce((acc: any, curr) => {
7880
acc[curr] = workingDir;
81+
7982
return acc;
8083
}, {});
8184
}
@@ -120,6 +123,7 @@ export abstract class SchematicCommand extends Command {
120123
return this._workspace.getProjectByPath(normalize(process.cwd()))
121124
|| this._workspace.getDefaultProjectName();
122125
}
126+
123127
return undefined;
124128
});
125129

@@ -214,6 +218,7 @@ export abstract class SchematicCommand extends Command {
214218
if (this._originalOptions.find(option => option.name == 'debug')) {
215219
delete opts.debug;
216220
}
221+
217222
return opts;
218223
}
219224

packages/@angular/cli/utilities/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function getWorkspace(
6060

6161
if (!configPath) {
6262
cachedWorkspaces.set(level, null);
63+
6364
return null;
6465
}
6566

@@ -72,6 +73,7 @@ export function getWorkspace(
7273

7374
workspace.loadWorkspaceFromHost(file).subscribe();
7475
cachedWorkspaces.set(level, workspace);
76+
7577
return workspace;
7678
}
7779

@@ -109,6 +111,7 @@ export function getWorkspaceRaw(
109111
if (ast.kind != 'object') {
110112
throw new Error('Invalid JSON');
111113
}
114+
112115
return [ast as JsonAstObject, configPath];
113116
}
114117

@@ -164,6 +167,7 @@ export function getPackageManager(): string {
164167
return legacyPackageManager;
165168
}
166169
}
170+
167171
return 'npm';
168172
}
169173

@@ -211,6 +215,7 @@ export function migrateLegacyGlobalConfig(): boolean {
211215
if (Object.getOwnPropertyNames(cli).length > 0) {
212216
const globalPath = path.join(homeDir, globalFileName);
213217
writeFileSync(globalPath, JSON.stringify({ version: 1, cli }, null, 2));
218+
214219
return true;
215220
}
216221
}
@@ -238,6 +243,7 @@ function getLegacyPackageManager(): string | null {
238243
}
239244
}
240245
}
246+
241247
return null;
242248
}
243249

packages/@angular/cli/utilities/project.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable:no-any
12
import { normalize } from '@angular-devkit/core';
23
import * as fs from 'fs';
34
import * as os from 'os';
@@ -44,6 +45,7 @@ export function getProjectDetails(): ProjectDetails | null {
4445
return null;
4546
}
4647
}
48+
4749
return {
4850
root: possibleDir,
4951
configFile: configFileName,
@@ -60,5 +62,6 @@ function containsCliDep(obj: any): boolean {
6062
return true;
6163
}
6264
}
65+
6366
return false;
6467
}

packages/@angular/cli/utilities/schematics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* require('@schematics/angular')
66
*/
7-
7+
// tslint:disable:no-any
88
import { schema } from '@angular-devkit/core';
99
import {
1010
Collection,

0 commit comments

Comments
 (0)