Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: lint warning fix for any to unknown #1374 #1397

Conversation

yayoiukai2021
Copy link

@yayoiukai2021 yayoiukai2021 commented Oct 1, 2021

Lint fix for batch 25/26. + No.251 and No.240 (In the same file)

Fixes #1374

@@ -101,14 +101,14 @@ export class QuorumTestLedger implements ITestLedger {
}

public async getFileContents(filePath: string): Promise<string> {
const response: any = await this.getContainer().getArchive({
const response: unknown = await this.getContainer().getArchive({
Copy link
Contributor

@petermetz petermetz Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yayoiukai2021

I recommend simply omitting the explicit type declaration here in order to make the linter warning go away. Using unkown in this particular case just makes the compiler fail somewhere down the line.

Suggested change
const response: unknown = await this.getContainer().getArchive({
const response = await this.getContainer().getArchive({

@petermetz petermetz requested review from takeutak and removed request for jonathan-m-hamilton October 1, 2021 22:34
@petermetz
Copy link
Contributor

@yayoiukai2021 The other thing apart from my recommended change above is the DCO: If you click on the link labeled as "Details" next to the failing check (DCO) then it should give you specific instructions on how to fix it on the command line. If you encounter any trouble with it then feel free to ask for more help ;-)

Signed-off-by: yukai <yayoi.ukai@sony.com>
@yayoiukai2021 yayoiukai2021 force-pushed the style-2021-09-20-linter-warnings-batch25-out-of-26 branch from a946a3b to 58d8df9 Compare October 1, 2021 23:09
Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yayoiukai2021 LGTM, thank you very much!

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yayoiukai2021 You will also need to import the Stream type in order to make my other suggestion work with something like this:

import { Stream } from "stream";

Comment on lines +375 to +396
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: any, stream: any) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: any, output: any[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
docker.pull(
containerNameAndTag,
(pullError: unknown, stream: unknown) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
},
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yayoiukai2021 I'd fix the compiler error like this:

Suggested change
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: any, stream: any) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: any, output: any[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
docker.pull(
containerNameAndTag,
(pullError: unknown, stream: unknown) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
},
);
private pullContainerImage(containerNameAndTag: string): Promise<unknown[]> {
return new Promise((resolve, reject) => {
const docker = new Docker();
docker.pull(containerNameAndTag, (pullError: unknown, stream: Stream) => {
if (pullError) {
reject(pullError);
} else {
docker.modem.followProgress(
stream,
(progressError: unknown, output: unknown[]) => {
if (progressError) {
reject(progressError);
} else {
resolve(output);
}
},
);
}
});
});
}

@petermetz
Copy link
Contributor

Closing due to inactivity, feel free to reopen as needed and then we can continue the review.

@petermetz petermetz closed this Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

style: 2021-09-20 linter warnings batch 25 / 26
3 participants