Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 698ef7b

Browse files
authored
[HOUSEKEEPING] Resolve eslint error and warning (#409)
* remove disable eslint * next round * more fixes * resolve conflict * more lint fixes * added more tests * more lint errors
1 parent f4f3eb4 commit 698ef7b

Some content is hidden

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

46 files changed

+1644
-1755
lines changed

src/commands/command.ts

+27-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-use-before-define */
21
import commander from "commander";
32
import { enableVerboseLogging, logger } from "../logger";
43

@@ -17,6 +16,33 @@ interface Command {
1716
subCommands: Command[];
1817
}
1918

19+
/**
20+
* Links the command and sub-commands in the passed IComponent together.
21+
* Adding the necessary command/actions for each sub-command to the parent.
22+
*
23+
* Note: this linking isn't what actually enables nested sub-command calling,
24+
* this is only used for displaying what sub-commands are available for any
25+
* given parent. For information on how sub-commands are executed refer to
26+
* `executeCommand`
27+
*
28+
* @param c ICommand object to prepare
29+
*/
30+
const linkSubCommands = (c: Command): Command => {
31+
const { command, subCommands } = c;
32+
// Add all sub-commands
33+
for (const subCommand of subCommands) {
34+
// Recur; link all sub-sub-commands to the sub-command before adding to current
35+
linkSubCommands(subCommand);
36+
37+
// Add the subCommand to command
38+
command
39+
.command(subCommand.command.name())
40+
.description(subCommand.command.description());
41+
}
42+
43+
return c;
44+
};
45+
2046
/**
2147
* Generates an concrete implementation of ICommand.
2248
*
@@ -118,30 +144,3 @@ export const executeCommand = (cmd: Command, argv: string[]): void => {
118144
}
119145
}
120146
};
121-
122-
/**
123-
* Links the command and sub-commands in the passed IComponent together.
124-
* Adding the necessary command/actions for each sub-command to the parent.
125-
*
126-
* Note: this linking isn't what actually enables nested sub-command calling,
127-
* this is only used for displaying what sub-commands are available for any
128-
* given parent. For information on how sub-commands are executed refer to
129-
* `executeCommand`
130-
*
131-
* @param c ICommand object to prepare
132-
*/
133-
const linkSubCommands = (c: Command): Command => {
134-
const { command, subCommands } = c;
135-
// Add all sub-commands
136-
for (const subCommand of subCommands) {
137-
// Recur; link all sub-sub-commands to the sub-command before adding to current
138-
linkSubCommands(subCommand);
139-
140-
// Add the subCommand to command
141-
command
142-
.command(subCommand.command.name())
143-
.description(subCommand.command.description());
144-
}
145-
146-
return c;
147-
};

src/commands/deployment/create.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
21
import commander from "commander";
32
import {
43
addSrcToACRPipeline,
@@ -66,6 +65,7 @@ export const handlePipeline1 = async (
6665
}
6766
await addSrcToACRPipeline(
6867
tableInfo,
68+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6969
opts.p1!,
7070
opts.imageTag,
7171
opts.service,
@@ -89,6 +89,7 @@ export const handlePipeline2 = async (
8989
}
9090
await updateACRToHLDPipeline(
9191
tableInfo,
92+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9293
opts.p2!,
9394
opts.imageTag,
9495
opts.hldCommitId,
@@ -113,9 +114,13 @@ export const execute = async (
113114
validateValues(opts);
114115

115116
const tableInfo: DeploymentTable = {
117+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
116118
accountKey: opts.accessKey!,
119+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117120
accountName: opts.name!,
121+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
118122
partitionKey: opts.partitionKey!,
123+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
119124
tableName: opts.tableName!
120125
};
121126

@@ -126,7 +131,9 @@ export const execute = async (
126131
} else if (hasValue(opts.p3) && hasValue(opts.hldCommitId)) {
127132
await updateHLDToManifestPipeline(
128133
tableInfo,
134+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
129135
opts.hldCommitId!,
136+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
130137
opts.p3!,
131138
opts.manifestCommitId,
132139
opts.pr,

src/commands/deployment/dashboard.test.ts

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
2-
/* eslint-disable @typescript-eslint/camelcase */
31
jest.mock("open");
42
import open from "open";
53
jest.mock("../../config");
@@ -32,18 +30,18 @@ afterAll(() => {
3230

3331
const mockConfig = (): void => {
3432
(Config as jest.Mock).mockReturnValueOnce({
35-
azure_devops: {
36-
access_token: uuid(),
33+
"azure_devops": {
34+
"access_token": uuid(),
3735
org: uuid(),
3836
project: uuid()
3937
},
4038
introspection: {
4139
azure: {
42-
account_name: uuid(),
40+
"account_name": uuid(),
4341
key: uuid(),
44-
partition_key: uuid(),
45-
source_repo_access_token: "test_token",
46-
table_name: uuid()
42+
"partition_key": uuid(),
43+
"source_repo_access_token": "test_token",
44+
"table_name": uuid()
4745
}
4846
}
4947
});
@@ -134,6 +132,7 @@ describe("Validate dashboard container pull", () => {
134132
const dockerId = await exec("docker", [
135133
"images",
136134
"-q",
135+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
137136
config.introspection!.dashboard!.image!
138137
]);
139138
expect(dockerId).toBeDefined();
@@ -160,6 +159,7 @@ describe("Validate dashboard clean up", () => {
160159
const dockerId = await exec("docker", [
161160
"images",
162161
"-q",
162+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
163163
config.introspection!.dashboard!.image!
164164
]);
165165

@@ -185,6 +185,7 @@ describe("Fallback to azure devops access token", () => {
185185
const envVars = (await getEnvVars(config)).toString();
186186
logger.info(
187187
`spin: ${envVars}, act: ${
188+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
188189
config.introspection!.azure!.source_repo_access_token
189190
}`
190191
);
@@ -198,6 +199,7 @@ describe("Fallback to azure devops access token", () => {
198199
const envVars = (await getEnvVars(config)).toString();
199200
const expectedSubstring =
200201
"REACT_APP_SOURCE_REPO_ACCESS_TOKEN=" +
202+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
201203
config.introspection!.azure!.source_repo_access_token!;
202204
expect(envVars.includes(expectedSubstring)).toBeTruthy();
203205
});
@@ -206,21 +208,26 @@ describe("Fallback to azure devops access token", () => {
206208
describe("Extract manifest repository information", () => {
207209
test("Manifest repository information is successfully extracted", () => {
208210
(Config as jest.Mock).mockReturnValue({
209-
azure_devops: {
210-
manifest_repository:
211+
"azure_devops": {
212+
"manifest_repository":
211213
"https://dev.azure.com/bhnook/fabrikam/_git/materialized"
212214
}
213215
});
214216
const config = Config();
215217
let manifestInfo = extractManifestRepositoryInformation(config);
216218
expect(manifestInfo).toBeDefined();
219+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
217220
expect(manifestInfo!.githubUsername).toBeUndefined();
221+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
218222
expect(manifestInfo!.manifestRepoName).toBe("materialized");
219-
config.azure_devops!.manifest_repository =
223+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
224+
config.azure_devops!["manifest_repository"] =
220225
"https://github.com/username/manifest";
221226
manifestInfo = extractManifestRepositoryInformation(config);
222227
expect(manifestInfo).toBeDefined();
228+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
223229
expect(manifestInfo!.githubUsername).toBe("username");
230+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
224231
expect(manifestInfo!.manifestRepoName).toBe("manifest");
225232

226233
logger.info("Verified that manifest repository extraction works");

0 commit comments

Comments
 (0)