Compare commits

..

1 Commits

Author SHA1 Message Date
sunilyadav840
2ff5efcea4 Fixed eslint issue of githuvClient and NotebookRenderer files 2021-10-05 13:29:21 +05:30
6 changed files with 25 additions and 23 deletions

View File

@@ -44,6 +44,8 @@ src/Explorer/DataSamples/ContainerSampleGenerator.test.ts
src/Explorer/DataSamples/ContainerSampleGenerator.ts src/Explorer/DataSamples/ContainerSampleGenerator.ts
src/Explorer/DataSamples/DataSamplesUtil.test.ts src/Explorer/DataSamples/DataSamplesUtil.test.ts
src/Explorer/DataSamples/DataSamplesUtil.ts src/Explorer/DataSamples/DataSamplesUtil.ts
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts
src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts
@@ -104,7 +106,6 @@ src/Explorer/Tabs/ScriptTabBase.ts
src/Explorer/Tabs/TabComponents.ts src/Explorer/Tabs/TabComponents.ts
src/Explorer/Tabs/TabsBase.ts src/Explorer/Tabs/TabsBase.ts
src/Explorer/Tabs/TriggerTab.ts src/Explorer/Tabs/TriggerTab.ts
src/Explorer/Tabs/UserDefinedFunctionTab.ts
src/Explorer/Tree/AccessibleVerticalList.ts src/Explorer/Tree/AccessibleVerticalList.ts
src/Explorer/Tree/Collection.ts src/Explorer/Tree/Collection.ts
src/Explorer/Tree/ConflictId.ts src/Explorer/Tree/ConflictId.ts
@@ -116,14 +117,12 @@ src/Explorer/Tree/TreeComponents.ts
src/Explorer/Tree/Trigger.ts src/Explorer/Tree/Trigger.ts
src/Explorer/WaitsForTemplateViewModel.ts src/Explorer/WaitsForTemplateViewModel.ts
src/GitHub/GitHubClient.test.ts src/GitHub/GitHubClient.test.ts
src/GitHub/GitHubClient.ts
src/GitHub/GitHubConnector.ts src/GitHub/GitHubConnector.ts
src/GitHub/GitHubOAuthService.ts src/GitHub/GitHubOAuthService.ts
src/Index.ts src/Index.ts
src/Juno/JunoClient.test.ts src/Juno/JunoClient.test.ts
src/Juno/JunoClient.ts src/Juno/JunoClient.ts
src/Platform/Hosted/Authorization.ts src/Platform/Hosted/Authorization.ts
src/ReactDevTools.ts
src/Shared/Constants.ts src/Shared/Constants.ts
src/Shared/DefaultExperienceUtility.test.ts src/Shared/DefaultExperienceUtility.test.ts
src/Shared/DefaultExperienceUtility.ts src/Shared/DefaultExperienceUtility.ts
@@ -155,7 +154,6 @@ src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx
src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx
src/Explorer/Notebook/NotebookComponent/contents/index.tsx src/Explorer/Notebook/NotebookComponent/contents/index.tsx
src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx
src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/draggable/index.tsx src/Explorer/Notebook/NotebookRenderer/decorators/draggable/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/index.tsx src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/index.tsx src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/index.tsx

View File

@@ -6,7 +6,7 @@ describe("Cache arrays by key", () => {
const key = "key"; const key = "key";
cache.insert(key, 1, 0); cache.insert(key, 1, 0);
cache.clear(); cache.clear();
expect(cache.retrieve(key, 0, 1)).toBe(undefined); expect(cache.retrieve(key, 0, 1)).toBe(null);
}); });
it("should invalidate oldest key to keep cache size under maximum", () => { it("should invalidate oldest key to keep cache size under maximum", () => {
@@ -21,7 +21,7 @@ describe("Cache arrays by key", () => {
cache.insert(key1, 2, 4); cache.insert(key1, 2, 4);
expect(cache.retrieve(key1, 0, 3)).toEqual([0, 2, 4]); expect(cache.retrieve(key1, 0, 3)).toEqual([0, 2, 4]);
expect(cache.retrieve(key2, 1, 1)).toEqual(undefined); expect(cache.retrieve(key2, 1, 1)).toEqual(null);
}); });
it("should cache and retrieve cached page within boundaries", () => { it("should cache and retrieve cached page within boundaries", () => {
@@ -39,7 +39,7 @@ describe("Cache arrays by key", () => {
const key = "key"; const key = "key";
cache.insert(key, 0, 0); cache.insert(key, 0, 0);
cache.insert(key, 1, 1); cache.insert(key, 1, 1);
expect(cache.retrieve(key, 2, 1)).toEqual(undefined); expect(cache.retrieve(key, 2, 1)).toEqual(null);
}); });
it("should not retrieve cached page overlapping boundaries", () => { it("should not retrieve cached page overlapping boundaries", () => {
@@ -48,7 +48,7 @@ describe("Cache arrays by key", () => {
cache.insert(key, 0, 0); cache.insert(key, 0, 0);
cache.insert(key, 1, 1); cache.insert(key, 1, 1);
cache.insert(key, 2, 2); cache.insert(key, 2, 2);
expect(cache.retrieve(key, 2, 4)).toEqual(undefined); expect(cache.retrieve(key, 2, 4)).toEqual(null);
}); });
it("should not insert non-contiguous element", () => { it("should not insert non-contiguous element", () => {
@@ -57,7 +57,7 @@ describe("Cache arrays by key", () => {
cache.insert(key, 0, 0); cache.insert(key, 0, 0);
cache.insert(key, 1, 1); cache.insert(key, 1, 1);
cache.insert(key, 3, 3); cache.insert(key, 3, 3);
expect(cache.retrieve(key, 3, 1)).toEqual(undefined); expect(cache.retrieve(key, 3, 1)).toEqual(null);
}); });
it("should cache multiple keys", () => { it("should cache multiple keys", () => {

View File

@@ -61,12 +61,12 @@ export class ArraysByKeyCache<T> {
* @param pageSize * @param pageSize
*/ */
public retrieve(key: string, startIndex: number, pageSize: number): T[] | null { public retrieve(key: string, startIndex: number, pageSize: number): T[] | null {
if (!Object.prototype.hasOwnProperty.call(this.cache, key)) { if (!this.cache.hasOwnProperty(key)) {
return undefined; return null;
} }
const elements = this.cache[key]; const elements = this.cache[key];
if (startIndex + pageSize > elements.length) { if (startIndex + pageSize > elements.length) {
return undefined; return null;
} }
return elements.slice(startIndex, startIndex + pageSize); return elements.slice(startIndex, startIndex + pageSize);

View File

@@ -31,12 +31,13 @@ import StatusBar from "./StatusBar";
import CellToolbar from "./Toolbar"; import CellToolbar from "./Toolbar";
export interface NotebookRendererBaseProps { export interface NotebookRendererBaseProps {
contentRef: any; contentRef: ContentRef;
} }
interface NotebookRendererDispatchProps { interface NotebookRendererDispatchProps {
storeNotebookSnapshot: (imageSrc: string, requestId: string) => void; storeNotebookSnapshot: (imageSrc: string, requestId: string) => void;
notebookSnapshotError: (error: string) => void; notebookSnapshotError: (error: string) => void;
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => void;
} }
interface StateProps { interface StateProps {
@@ -73,7 +74,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
componentDidMount() { componentDidMount() {
if (!userContext.features.sandboxNotebookOutputs) { if (!userContext.features.sandboxNotebookOutputs) {
loadTransform(this.props as any); loadTransform(this.props as NotebookRendererProps);
} }
} }
@@ -138,7 +139,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
}} }}
</CodeCell> </CodeCell>
), ),
markdown: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => markdown: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) =>
decorate( decorate(
id, id,
contentRef, contentRef,
@@ -155,7 +156,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
</MarkdownCell> </MarkdownCell>
), ),
raw: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => raw: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) =>
decorate( decorate(
id, id,
contentRef, contentRef,
@@ -202,7 +203,8 @@ export const makeMapStateToProps = (
return mapStateToProps; return mapStateToProps;
}; };
const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: NotebookRendererBaseProps) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars
const makeMapDispatchToProps = (_initialDispatch: Dispatch, _initialProps: NotebookRendererBaseProps) => {
const mapDispatchToProps = (dispatch: Dispatch) => { const mapDispatchToProps = (dispatch: Dispatch) => {
return { return {
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => addTransform: (transform: React.ComponentType & { MIMETYPE: string }) =>

View File

@@ -1,9 +1,9 @@
import { Octokit } from "@octokit/rest"; import { Octokit } from "@octokit/rest";
import { HttpStatusCodes } from "../Common/Constants"; import { HttpStatusCodes } from "../Common/Constants";
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
import * as Logger from "../Common/Logger"; import * as Logger from "../Common/Logger";
import * as UrlUtility from "../Common/UrlUtility"; import * as UrlUtility from "../Common/UrlUtility";
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil"; import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
export interface IGitHubPageInfo { export interface IGitHubPageInfo {
endCursor: string; endCursor: string;
@@ -225,7 +225,7 @@ export class GitHubClient {
private static readonly SelfErrorCode = 599; private static readonly SelfErrorCode = 599;
private ocktokit: Octokit; private ocktokit: Octokit;
constructor(private errorCallback: (error: any) => void) { constructor(private errorCallback: (error: Error) => void) {
this.initOctokit(); this.initOctokit();
} }
@@ -501,10 +501,11 @@ export class GitHubClient {
this.ocktokit = new Octokit({ this.ocktokit = new Octokit({
auth: token, auth: token,
log: { log: {
// eslint-disable-next-line @typescript-eslint/no-empty-function
debug: () => {}, debug: () => {},
info: (message?: any) => GitHubClient.log(Logger.logInfo, message), info: (message?: string) => GitHubClient.log(Logger.logInfo, message),
warn: (message?: any) => GitHubClient.log(Logger.logWarning, message), warn: (message?: string) => GitHubClient.log(Logger.logWarning, message),
error: (error?: any) => Logger.logError(getErrorMessage(error), "GitHubClient.Octokit"), error: (error?: Error) => Logger.logError(getErrorMessage(error), "GitHubClient.Octokit"),
}, },
}); });
@@ -514,7 +515,7 @@ export class GitHubClient {
}); });
} }
private static log(logger: (message: string, area: string) => void, message?: any) { private static log(logger: (message: string, area: string) => void, message?: string) {
if (message) { if (message) {
message = typeof message === "string" ? message : JSON.stringify(message); message = typeof message === "string" ? message : JSON.stringify(message);
logger(message, "GitHubClient.Octokit"); logger(message, "GitHubClient.Octokit");

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
if (window.parent !== window) { if (window.parent !== window) {
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window.parent as any).__REACT_DEVTOOLS_GLOBAL_HOOK__; (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window.parent as any).__REACT_DEVTOOLS_GLOBAL_HOOK__;
} }