From df3b18d585c9e433b70a5e58ad61f7d047e1158e Mon Sep 17 00:00:00 2001 From: Sunil Kumar Yadav <79906609+sunilyadav840@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:59:21 +0530 Subject: [PATCH] fixed eslint of NotebookComponentBootstrapper and NotebookReadOnlyRenderer (#1122) --- .eslintignore | 4 ++-- .../NotebookComponentBootstrapper.tsx | 21 +++++++++++++++---- .../NotebookReadOnlyRenderer.tsx | 14 +++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.eslintignore b/.eslintignore index c5fa9c4c7..f8d1587bb 100644 --- a/.eslintignore +++ b/.eslintignore @@ -148,10 +148,10 @@ src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.test.t src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.tsx src/Explorer/Menus/CommandBar/CommandBarUtil.tsx src/Explorer/Notebook/NotebookComponent/NotebookComponentAdapter.tsx -src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx +; src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.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/hijack-scroll/index.tsx diff --git a/src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx b/src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx index 2abbc3618..068c63a2f 100644 --- a/src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx +++ b/src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { CellId, CellType, ImmutableNotebook } from "@nteract/commutable"; // Vendor modules import { @@ -30,6 +31,19 @@ export interface NotebookComponentBootstrapperOptions { contentRef: ContentRef; } +interface IWrapModel { + name: string; + path: string; + last_modified: Date; + created: string; + content: unknown; + format: string; + mimetype: unknown; + size: number; + writeable: boolean; + type: string; +} + export class NotebookComponentBootstrapper { public contentRef: ContentRef; protected renderExtraComponent: () => JSX.Element; @@ -41,7 +55,7 @@ export class NotebookComponentBootstrapper { this.contentRef = options.contentRef; } - protected static wrapModelIntoContent(name: string, path: string, content: any) { + protected static wrapModelIntoContent(name: string, path: string, content: unknown): IWrapModel { return { name, path, @@ -49,7 +63,7 @@ export class NotebookComponentBootstrapper { created: "", content, format: "json", - mimetype: null as any, + mimetype: undefined, size: 0, writeable: false, type: "notebook", @@ -85,7 +99,7 @@ export class NotebookComponentBootstrapper { }; } - public setContent(name: string, content: any): void { + public setContent(name: string, content: unknown): void { this.getStore().dispatch( actions.fetchContentFulfilled({ filepath: undefined, @@ -270,7 +284,6 @@ export class NotebookComponentBootstrapper { public isContentDirty(): boolean { const content = selectors.content(this.getStore().getState(), { contentRef: this.contentRef }); if (!content) { - console.log("No error"); return false; } diff --git a/src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx b/src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx index f912acd4a..74ae68b2c 100644 --- a/src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx +++ b/src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx @@ -16,9 +16,10 @@ import "./NotebookReadOnlyRenderer.less"; import SandboxOutputs from "./outputs/SandboxOutputs"; export interface NotebookRendererProps { - contentRef: any; + contentRef: ContentRef; hideInputs?: boolean; hidePrompts?: boolean; + addTransform: (component: React.ComponentType & { MIMETYPE: string }) => void; } /** @@ -27,7 +28,7 @@ export interface NotebookRendererProps { class NotebookReadOnlyRenderer extends React.Component { componentDidMount() { if (!userContext.features.sandboxNotebookOutputs) { - loadTransform(this.props as any); + loadTransform(this.props as NotebookRendererProps); } } @@ -59,7 +60,7 @@ class NotebookReadOnlyRenderer extends React.Component {
{{ - code: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => ( + code: ({ id, contentRef }: { id: string; contentRef: ContentRef }) => ( {{ prompt: (props: { id: string; contentRef: string }) => this.renderPrompt(props.id, props.contentRef), @@ -73,14 +74,14 @@ class NotebookReadOnlyRenderer extends React.Component { }} ), - markdown: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => ( + markdown: ({ id, contentRef }: { id: string; contentRef: ContentRef }) => ( {{ editor: {}, }} ), - raw: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => ( + raw: ({ id, contentRef }: { id: string; contentRef: ContentRef }) => ( {{ editor: { @@ -98,6 +99,7 @@ class NotebookReadOnlyRenderer extends React.Component { } } +// eslint-disable-next-line @typescript-eslint/no-unused-vars const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: NotebookRendererProps) => { const mapDispatchToProps = (dispatch: Dispatch) => { return { @@ -114,4 +116,4 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo return mapDispatchToProps; }; -export default connect(null, makeMapDispatchToProps)(NotebookReadOnlyRenderer); +export default connect(undefined, makeMapDispatchToProps)(NotebookReadOnlyRenderer);