From 0bbf9de963724c9cf918ac0541796e2ca374cccd Mon Sep 17 00:00:00 2001 From: Hardikkumar Nai <80053762+hardiknai-techm@users.noreply.github.com> Date: Thu, 15 Jul 2021 19:23:07 +0530 Subject: [PATCH] Resolve ESLint Errors (#934) --- .eslintignore | 4 -- src/Explorer/ContextMenuButtonFactory.tsx | 2 +- src/Explorer/Tree/Collection.ts | 4 +- src/Explorer/Tree/UserDefinedFunction.ts | 6 ++- src/GitHub/GitHubContentProvider.test.ts | 52 ++++++++++--------- src/GitHub/GitHubContentProvider.ts | 22 ++++---- .../Helpers/ConnectionStringParser.test.ts | 4 +- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.eslintignore b/.eslintignore index cd598d58b..15d8762b6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -143,19 +143,15 @@ src/Explorer/Tree/ResourceTokenCollection.ts src/Explorer/Tree/StoredProcedure.ts src/Explorer/Tree/TreeComponents.ts src/Explorer/Tree/Trigger.ts -src/Explorer/Tree/UserDefinedFunction.ts src/Explorer/WaitsForTemplateViewModel.ts src/GitHub/GitHubClient.test.ts src/GitHub/GitHubClient.ts src/GitHub/GitHubConnector.ts -src/GitHub/GitHubContentProvider.test.ts -src/GitHub/GitHubContentProvider.ts src/GitHub/GitHubOAuthService.ts src/Index.ts src/Juno/JunoClient.test.ts src/Juno/JunoClient.ts src/Platform/Hosted/Authorization.ts -src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts src/ReactDevTools.ts src/Shared/Constants.ts src/Shared/DefaultExperienceUtility.test.ts diff --git a/src/Explorer/ContextMenuButtonFactory.tsx b/src/Explorer/ContextMenuButtonFactory.tsx index ece39b07d..70d02e5aa 100644 --- a/src/Explorer/ContextMenuButtonFactory.tsx +++ b/src/Explorer/ContextMenuButtonFactory.tsx @@ -109,7 +109,7 @@ export const createCollectionContextMenuButton = ( iconSrc: AddUdfIcon, onClick: () => { const selectedCollection: ViewModels.Collection = useSelectedNode.getState().findSelectedCollection(); - selectedCollection && selectedCollection.onNewUserDefinedFunctionClick(selectedCollection, undefined); + selectedCollection && selectedCollection.onNewUserDefinedFunctionClick(selectedCollection); }, label: "New UDF", }); diff --git a/src/Explorer/Tree/Collection.ts b/src/Explorer/Tree/Collection.ts index d2ceb8deb..c486da03e 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -744,8 +744,8 @@ export default class Collection implements ViewModels.Collection { StoredProcedure.create(source, event); } - public onNewUserDefinedFunctionClick(source: ViewModels.Collection, event: MouseEvent) { - UserDefinedFunction.create(source, event); + public onNewUserDefinedFunctionClick(source: ViewModels.Collection) { + UserDefinedFunction.create(source); } public onNewTriggerClick(source: ViewModels.Collection, event: MouseEvent) { diff --git a/src/Explorer/Tree/UserDefinedFunction.ts b/src/Explorer/Tree/UserDefinedFunction.ts index 2d2b64889..4264c0954 100644 --- a/src/Explorer/Tree/UserDefinedFunction.ts +++ b/src/Explorer/Tree/UserDefinedFunction.ts @@ -30,7 +30,7 @@ export default class UserDefinedFunction { this.body = ko.observable(data.body as string); } - public static create(source: ViewModels.Collection, event: MouseEvent) { + public static create(source: ViewModels.Collection) { const id = useTabs.getState().getTabs(ViewModels.CollectionTabKind.UserDefinedFunctions).length + 1; const userDefinedFunction = { id: "", @@ -104,7 +104,9 @@ export default class UserDefinedFunction { useTabs.getState().closeTabsByComparator((tab) => tab.node && tab.node.rid === this.rid); this.collection.children.remove(this); }, - (reason) => {} + () => { + /**/ + } ); } } diff --git a/src/GitHub/GitHubContentProvider.test.ts b/src/GitHub/GitHubContentProvider.test.ts index c7311bbf6..129863df3 100644 --- a/src/GitHub/GitHubContentProvider.test.ts +++ b/src/GitHub/GitHubContentProvider.test.ts @@ -1,11 +1,13 @@ import { IContent } from "@nteract/core"; import { fixture } from "@nteract/fixtures"; import { HttpStatusCodes } from "../Common/Constants"; +import * as GitHubUtils from "../Utils/GitHubUtils"; import { GitHubClient, IGitHubCommit, IGitHubFile } from "./GitHubClient"; import { GitHubContentProvider } from "./GitHubContentProvider"; -import * as GitHubUtils from "../Utils/GitHubUtils"; -const gitHubClient = new GitHubClient(() => {}); +const gitHubClient = new GitHubClient(() => { + /**/ +}); const gitHubContentProvider = new GitHubContentProvider({ gitHubClient, promptForCommitMsg: () => Promise.resolve("commit msg"), @@ -46,7 +48,7 @@ const sampleNotebookModel: IContent<"notebook"> = { created: "", last_modified: "date", mimetype: "application/x-ipynb+json", - content: sampleFile.content ? JSON.parse(sampleFile.content) : null, + content: sampleFile.content ? JSON.parse(sampleFile.content) : undefined, format: "json", }; @@ -54,7 +56,7 @@ describe("GitHubContentProvider remove", () => { it("errors on invalid path", async () => { spyOn(GitHubClient.prototype, "getContentsAsync"); - const response = await gitHubContentProvider.remove(null, "invalid path").toPromise(); + const response = await gitHubContentProvider.remove(undefined, "invalid path").toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); expect(gitHubClient.getContentsAsync).not.toBeCalled(); @@ -63,7 +65,7 @@ describe("GitHubContentProvider remove", () => { it("errors on failed read", async () => { spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.remove(null, sampleGitHubUri).toPromise(); + const response = await gitHubContentProvider.remove(undefined, sampleGitHubUri).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -75,7 +77,7 @@ describe("GitHubContentProvider remove", () => { ); spyOn(GitHubClient.prototype, "deleteFileAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.remove(null, sampleGitHubUri).toPromise(); + const response = await gitHubContentProvider.remove(undefined, sampleGitHubUri).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -90,7 +92,7 @@ describe("GitHubContentProvider remove", () => { Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }) ); - const response = await gitHubContentProvider.remove(null, sampleGitHubUri).toPromise(); + const response = await gitHubContentProvider.remove(undefined, sampleGitHubUri).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(HttpStatusCodes.NoContent); expect(gitHubClient.deleteFileAsync).toBeCalled(); @@ -102,7 +104,7 @@ describe("GitHubContentProvider get", () => { it("errors on invalid path", async () => { spyOn(GitHubClient.prototype, "getContentsAsync"); - const response = await gitHubContentProvider.get(null, "invalid path", null).toPromise(); + const response = await gitHubContentProvider.get(undefined, "invalid path", undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); expect(gitHubClient.getContentsAsync).not.toBeCalled(); @@ -111,7 +113,7 @@ describe("GitHubContentProvider get", () => { it("errors on failed read", async () => { spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.get(null, sampleGitHubUri, null).toPromise(); + const response = await gitHubContentProvider.get(undefined, sampleGitHubUri, undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -122,7 +124,7 @@ describe("GitHubContentProvider get", () => { Promise.resolve({ status: HttpStatusCodes.OK, data: sampleFile }) ); - const response = await gitHubContentProvider.get(null, sampleGitHubUri, {}).toPromise(); + const response = await gitHubContentProvider.get(undefined, sampleGitHubUri, {}).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(HttpStatusCodes.OK); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -134,7 +136,7 @@ describe("GitHubContentProvider update", () => { it("errors on invalid path", async () => { spyOn(GitHubClient.prototype, "getContentsAsync"); - const response = await gitHubContentProvider.update(null, "invalid path", null).toPromise(); + const response = await gitHubContentProvider.update(undefined, "invalid path", undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); expect(gitHubClient.getContentsAsync).not.toBeCalled(); @@ -143,7 +145,7 @@ describe("GitHubContentProvider update", () => { it("errors on failed read", async () => { spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.update(null, sampleGitHubUri, null).toPromise(); + const response = await gitHubContentProvider.update(undefined, sampleGitHubUri, undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -155,7 +157,7 @@ describe("GitHubContentProvider update", () => { ); spyOn(GitHubClient.prototype, "renameFileAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.update(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.update(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -170,7 +172,7 @@ describe("GitHubContentProvider update", () => { Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }) ); - const response = await gitHubContentProvider.update(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.update(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(HttpStatusCodes.OK); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -186,7 +188,7 @@ describe("GitHubContentProvider create", () => { it("errors on invalid path", async () => { spyOn(GitHubClient.prototype, "createOrUpdateFileAsync"); - const response = await gitHubContentProvider.create(null, "invalid path", sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.create(undefined, "invalid path", sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); expect(gitHubClient.createOrUpdateFileAsync).not.toBeCalled(); @@ -195,7 +197,7 @@ describe("GitHubContentProvider create", () => { it("errors on failed create", async () => { spyOn(GitHubClient.prototype, "createOrUpdateFileAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.create(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.create(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.createOrUpdateFileAsync).toBeCalled(); @@ -206,7 +208,7 @@ describe("GitHubContentProvider create", () => { Promise.resolve({ status: HttpStatusCodes.Created, data: gitHubCommit }) ); - const response = await gitHubContentProvider.create(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.create(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(HttpStatusCodes.Created); expect(gitHubClient.createOrUpdateFileAsync).toBeCalled(); @@ -221,7 +223,7 @@ describe("GitHubContentProvider save", () => { it("errors on invalid path", async () => { spyOn(GitHubClient.prototype, "getContentsAsync"); - const response = await gitHubContentProvider.save(null, "invalid path", null).toPromise(); + const response = await gitHubContentProvider.save(undefined, "invalid path", undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); expect(gitHubClient.getContentsAsync).not.toBeCalled(); @@ -230,7 +232,7 @@ describe("GitHubContentProvider save", () => { it("errors on failed read", async () => { spyOn(GitHubClient.prototype, "getContentsAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.save(null, sampleGitHubUri, null).toPromise(); + const response = await gitHubContentProvider.save(undefined, sampleGitHubUri, undefined).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -242,7 +244,7 @@ describe("GitHubContentProvider save", () => { ); spyOn(GitHubClient.prototype, "createOrUpdateFileAsync").and.returnValue(Promise.resolve({ status: 888 })); - const response = await gitHubContentProvider.save(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.save(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(888); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -257,7 +259,7 @@ describe("GitHubContentProvider save", () => { Promise.resolve({ status: HttpStatusCodes.OK, data: gitHubCommit }) ); - const response = await gitHubContentProvider.save(null, sampleGitHubUri, sampleNotebookModel).toPromise(); + const response = await gitHubContentProvider.save(undefined, sampleGitHubUri, sampleNotebookModel).toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(HttpStatusCodes.OK); expect(gitHubClient.getContentsAsync).toBeCalled(); @@ -271,7 +273,7 @@ describe("GitHubContentProvider save", () => { describe("GitHubContentProvider listCheckpoints", () => { it("errors for everything", async () => { - const response = await gitHubContentProvider.listCheckpoints(null, null).toPromise(); + const response = await gitHubContentProvider.listCheckpoints().toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); }); @@ -279,7 +281,7 @@ describe("GitHubContentProvider listCheckpoints", () => { describe("GitHubContentProvider createCheckpoint", () => { it("errors for everything", async () => { - const response = await gitHubContentProvider.createCheckpoint(null, null).toPromise(); + const response = await gitHubContentProvider.createCheckpoint().toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); }); @@ -287,7 +289,7 @@ describe("GitHubContentProvider createCheckpoint", () => { describe("GitHubContentProvider deleteCheckpoint", () => { it("errors for everything", async () => { - const response = await gitHubContentProvider.deleteCheckpoint(null, null, null).toPromise(); + const response = await gitHubContentProvider.deleteCheckpoint().toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); }); @@ -295,7 +297,7 @@ describe("GitHubContentProvider deleteCheckpoint", () => { describe("GitHubContentProvider restoreFromCheckpoint", () => { it("errors for everything", async () => { - const response = await gitHubContentProvider.restoreFromCheckpoint(null, null, null).toPromise(); + const response = await gitHubContentProvider.restoreFromCheckpoint().toPromise(); expect(response).toBeDefined(); expect(response.status).toBe(GitHubContentProvider.SelfErrorCode); }); diff --git a/src/GitHub/GitHubContentProvider.ts b/src/GitHub/GitHubContentProvider.ts index ac45ce9de..57c4d0a7c 100644 --- a/src/GitHub/GitHubContentProvider.ts +++ b/src/GitHub/GitHubContentProvider.ts @@ -1,15 +1,15 @@ -import { Notebook, stringifyNotebook, makeNotebookRecord, toJS } from "@nteract/commutable"; +import { makeNotebookRecord, Notebook, stringifyNotebook, toJS } from "@nteract/commutable"; import { FileType, IContent, IContentProvider, IEmptyContent, IGetParams, ServerConfig } from "@nteract/core"; import { from, Observable, of } from "rxjs"; import { AjaxResponse } from "rxjs/ajax"; -import * as Base64Utils from "../Utils/Base64Utils"; import { HttpStatusCodes } from "../Common/Constants"; -import * as Logger from "../Common/Logger"; -import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil"; -import { GitHubClient, IGitHubFile, IGitHubResponse } from "./GitHubClient"; -import * as GitHubUtils from "../Utils/GitHubUtils"; -import * as UrlUtility from "../Common/UrlUtility"; import { getErrorMessage } from "../Common/ErrorHandlingUtils"; +import * as Logger from "../Common/Logger"; +import * as UrlUtility from "../Common/UrlUtility"; +import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil"; +import * as Base64Utils from "../Utils/Base64Utils"; +import * as GitHubUtils from "../Utils/GitHubUtils"; +import { GitHubClient, IGitHubFile, IGitHubResponse } from "./GitHubClient"; export interface GitHubContentProviderParams { gitHubClient: GitHubClient; @@ -267,25 +267,25 @@ export class GitHubContentProvider implements IContentProvider { ); } - public listCheckpoints(_: ServerConfig, path: string): Observable { + public listCheckpoints(): Observable { const error = new GitHubContentProviderError("Not implemented"); Logger.logError(error.message, "GitHubContentProvider/listCheckpoints", error.errno); return of(this.createErrorAjaxResponse(error)); } - public createCheckpoint(_: ServerConfig, path: string): Observable { + public createCheckpoint(): Observable { const error = new GitHubContentProviderError("Not implemented"); Logger.logError(error.message, "GitHubContentProvider/createCheckpoint", error.errno); return of(this.createErrorAjaxResponse(error)); } - public deleteCheckpoint(_: ServerConfig, path: string, checkpointID: string): Observable { + public deleteCheckpoint(): Observable { const error = new GitHubContentProviderError("Not implemented"); Logger.logError(error.message, "GitHubContentProvider/deleteCheckpoint", error.errno); return of(this.createErrorAjaxResponse(error)); } - public restoreFromCheckpoint(_: ServerConfig, path: string, checkpointID: string): Observable { + public restoreFromCheckpoint(): Observable { const error = new GitHubContentProviderError("Not implemented"); Logger.logError(error.message, "GitHubContentProvider/restoreFromCheckpoint", error.errno); return of(this.createErrorAjaxResponse(error)); diff --git a/src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts b/src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts index 8762171e7..bd1447891 100644 --- a/src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts +++ b/src/Platform/Hosted/Helpers/ConnectionStringParser.test.ts @@ -2,8 +2,8 @@ import * as DataModels from "../../../Contracts/DataModels"; import { parseConnectionString } from "./ConnectionStringParser"; describe("ConnectionStringParser", () => { - const mockAccountName: string = "Test"; - const mockMasterKey: string = "some-key"; + const mockAccountName = "Test"; + const mockMasterKey = "some-key"; it("should parse a valid sql account connection string", () => { const metadata = parseConnectionString(