From ff498b51e26c28ac0e47fb9e24af582e65ca8376 Mon Sep 17 00:00:00 2001 From: Sunil Kumar Yadav <79906609+sunilyadav840@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:25:21 +0530 Subject: [PATCH] fixed eslint of Trigger.ts GithubOAuthService.ts etc (#1126) --- .eslintignore | 5 ----- .eslintrc.js | 1 - src/Explorer/Tree/Trigger.ts | 11 +++++++---- src/GitHub/GitHubOAuthService.ts | 4 ++-- src/Juno/JunoClient.test.ts | 30 ++++++++++++++++-------------- src/Juno/JunoClient.ts | 2 +- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.eslintignore b/.eslintignore index 3de1fdee0..5db30dd6a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -115,15 +115,10 @@ src/Explorer/Tree/ObjectId.ts src/Explorer/Tree/ResourceTokenCollection.ts src/Explorer/Tree/StoredProcedure.ts src/Explorer/Tree/TreeComponents.ts -src/Explorer/Tree/Trigger.ts src/Explorer/WaitsForTemplateViewModel.ts src/GitHub/GitHubClient.test.ts src/GitHub/GitHubClient.ts -src/GitHub/GitHubConnector.ts -src/GitHub/GitHubOAuthService.ts src/Index.ts -src/Juno/JunoClient.test.ts -src/Juno/JunoClient.ts src/Platform/Hosted/Authorization.ts src/ReactDevTools.ts src/Shared/Constants.ts diff --git a/.eslintrc.js b/.eslintrc.js index f32961a91..22f294717 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,7 +39,6 @@ module.exports = { "@typescript-eslint/switch-exhaustiveness-check": "error", "@typescript-eslint/no-unused-vars": "error", "@typescript-eslint/no-extraneous-class": "error", - "no-null/no-null": "error", "@typescript-eslint/no-explicit-any": "error", "prefer-arrow/prefer-arrow-functions": ["error", { allowStandaloneDeclarations: true }], eqeqeq: "error", diff --git a/src/Explorer/Tree/Trigger.ts b/src/Explorer/Tree/Trigger.ts index 59d05de60..01fc9e044 100644 --- a/src/Explorer/Tree/Trigger.ts +++ b/src/Explorer/Tree/Trigger.ts @@ -22,6 +22,7 @@ export default class Trigger { public triggerType: ko.Observable; public triggerOperation: ko.Observable; + // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(container: Explorer, collection: ViewModels.Collection, data: any) { this.nodeKind = "Trigger"; this.container = container; @@ -34,7 +35,7 @@ export default class Trigger { this.triggerType = ko.observable(data.triggerType); } - public select() { + public select(): void { useSelectedNode.getState().setSelectedNode(this); TelemetryProcessor.trace(Action.SelectItem, ActionModifiers.Mark, { description: "Trigger node", @@ -43,7 +44,8 @@ export default class Trigger { }); } - public static create(source: ViewModels.Collection, event: MouseEvent) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public static create(source: ViewModels.Collection, _event: MouseEvent): void { const id = useTabs.getState().getTabs(ViewModels.CollectionTabKind.Triggers).length + 1; const trigger = { id: "", @@ -99,7 +101,7 @@ export default class Trigger { } }; - public delete() { + public delete(): void { useDialog.getState().showOkCancelModalDialog( "Confirm delete", "Are you sure you want to delete the trigger?", @@ -110,7 +112,8 @@ export default class Trigger { useTabs.getState().closeTabsByComparator((tab) => tab.node && tab.node.rid === this.rid); this.collection.children.remove(this); }, - (reason) => {} + // eslint-disable-next-line @typescript-eslint/no-empty-function + () => {} ); }, "Cancel", diff --git a/src/GitHub/GitHubOAuthService.ts b/src/GitHub/GitHubOAuthService.ts index 6f800e66d..fb9288c7c 100644 --- a/src/GitHub/GitHubOAuthService.ts +++ b/src/GitHub/GitHubOAuthService.ts @@ -64,7 +64,7 @@ export class GitHubOAuthService { return params.state; } - public async finishOAuth(params: IGitHubConnectorParams) { + public async finishOAuth(params: IGitHubConnectorParams): Promise { try { this.validateState(params.state); const response = await this.junoClient.getGitHubToken(params.code); @@ -113,7 +113,7 @@ export class GitHubOAuthService { return this.state; } - public resetToken() { + public resetToken(): void { this.token(undefined); } diff --git a/src/Juno/JunoClient.test.ts b/src/Juno/JunoClient.test.ts index 299b0d6bb..9893d5c9e 100644 --- a/src/Juno/JunoClient.test.ts +++ b/src/Juno/JunoClient.test.ts @@ -50,7 +50,8 @@ describe("Pinned repos", () => { }); it("updatePinnedRepos invokes pinned repos subscribers", async () => { - const callback = jest.fn().mockImplementation((pinnedRepos: IPinnedRepo[]) => {}); + // eslint-disable-next-line @typescript-eslint/no-empty-function + const callback = jest.fn().mockImplementation(() => {}); junoClient.subscribeToPinnedRepos(callback); const response = await junoClient.updatePinnedRepos(samplePinnedRepos); @@ -60,7 +61,8 @@ describe("Pinned repos", () => { }); it("getPinnedRepos invokes pinned repos subscribers", async () => { - const callback = jest.fn().mockImplementation((pinnedRepos: IPinnedRepo[]) => {}); + // eslint-disable-next-line @typescript-eslint/no-empty-function + const callback = jest.fn().mockImplementation(() => {}); junoClient.subscribeToPinnedRepos(callback); const response = await junoClient.getPinnedRepos("scope"); @@ -153,7 +155,7 @@ describe("Gallery", () => { it("getSampleNotebooks", async () => { window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.getSampleNotebooks(); @@ -165,7 +167,7 @@ describe("Gallery", () => { it("getPublicNotebooks", async () => { window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.getPublicNotebooks(); @@ -178,7 +180,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.getNotebookInfo(id); @@ -191,7 +193,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - text: () => undefined as any, + text: () => undefined as undefined, }); const response = await junoClient.getNotebookContent(id); @@ -204,7 +206,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.increaseNotebookViews(id); @@ -218,7 +220,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.increaseNotebookDownloadCount(id); @@ -243,7 +245,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.favoriteNotebook(id); @@ -268,7 +270,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.unfavoriteNotebook(id); @@ -292,7 +294,7 @@ describe("Gallery", () => { it("getFavoriteNotebooks", async () => { window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.getFavoriteNotebooks(); @@ -315,7 +317,7 @@ describe("Gallery", () => { it("getPublishedNotebooks", async () => { window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.getPublishedNotebooks(); @@ -339,7 +341,7 @@ describe("Gallery", () => { const id = "id"; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.deleteNotebook(id); @@ -369,7 +371,7 @@ describe("Gallery", () => { const addLinkToNotebookViewer = true; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, - json: () => undefined as any, + json: () => undefined as undefined, }); const response = await junoClient.publishNotebook(name, description, tags, thumbnailUrl, content); diff --git a/src/Juno/JunoClient.ts b/src/Juno/JunoClient.ts index 9beb1a0c2..1a43cccc6 100644 --- a/src/Juno/JunoClient.ts +++ b/src/Juno/JunoClient.ts @@ -62,7 +62,7 @@ export interface IPublishNotebookRequest { description: string; tags: string[]; thumbnailUrl: string; - content: any; + content: unknown; addLinkToNotebookViewer: boolean; }