fixed lint issue of NoteBookUtils

This commit is contained in:
sunilyadav840 2021-03-08 18:35:19 +05:30
parent 69975cd0e8
commit 7bc4894382
12 changed files with 158 additions and 161 deletions

View File

@ -122,7 +122,6 @@ src/Explorer/Notebook/NotebookComponent/types.ts
src/Explorer/Notebook/NotebookContainerClient.ts
src/Explorer/Notebook/NotebookContentClient.ts
src/Explorer/Notebook/NotebookContentItem.ts
src/Explorer/Notebook/NotebookUtil.ts
src/Explorer/OpenActions.test.ts
src/Explorer/OpenActions.ts
src/Explorer/OpenActionsStubs.ts

View File

@ -49,7 +49,7 @@ import { LoadQueryPane } from "./Panes/LoadQueryPane";
import * as Logger from "../Common/Logger";
import { sendMessage, sendCachedDataMessage } from "../Common/MessageHandler";
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
import { NotebookUtil } from "./Notebook/NotebookUtil";
import * as NotebookUtil from "./Notebook/NotebookUtil";
import { NotebookWorkspaceManager } from "../NotebookWorkspaceManager/NotebookWorkspaceManager";
import * as NotificationConsoleUtils from "../Utils/NotificationConsoleUtils";
import { QueriesClient } from "../Common/QueriesClient";

View File

@ -2,7 +2,7 @@ import * as React from "react";
import { NotebookComponent } from "./NotebookComponent";
import { NotebookClientV2 } from "../NotebookClientV2";
import { NotebookUtil } from "../NotebookUtil";
import * as NotebookUtil from "../NotebookUtil";
// Vendor modules
import {

View File

@ -8,7 +8,7 @@ import * as sinon from "sinon";
import { CdbAppState, makeCdbRecord } from "./types";
import { launchWebSocketKernelEpic } from "./epics";
import { NotebookUtil } from "../NotebookUtil";
import * as NotebookUtil from "../NotebookUtil";
import { sessions } from "rx-jupyter";

View File

@ -43,7 +43,7 @@ import { Action as TelemetryAction, ActionModifiers } from "../../../Shared/Tele
import { CdbAppState } from "./types";
import { decryptJWTToken } from "../../../Utils/AuthorizationUtils";
import * as TextFile from "./contents/file/text-file";
import { NotebookUtil } from "../NotebookUtil";
import * as NotebookUtil from "../NotebookUtil";
import { FileSystemUtil } from "../FileSystemUtil";
import * as cdbActions from "../NotebookComponent/actions";
import { Areas } from "../../../Common/Constants";

View File

@ -2,7 +2,7 @@ import * as DataModels from "../../Contracts/DataModels";
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
import { StringUtils } from "../../Utils/StringUtils";
import { FileSystemUtil } from "./FileSystemUtil";
import { NotebookUtil } from "./NotebookUtil";
import * as NotebookUtil from "./NotebookUtil";
import { ServerConfig, IContent, IContentProvider, FileType, IEmptyContent } from "@nteract/core";
import { AjaxResponse } from "rxjs/ajax";

View File

@ -1,4 +1,4 @@
import { NotebookUtil } from "./NotebookUtil";
import * as NotebookUtil from "./NotebookUtil";
import * as GitHubUtils from "../../Utils/GitHubUtils";
import {
ImmutableNotebook,

View File

@ -7,12 +7,11 @@ import * as GitHubUtils from "../../Utils/GitHubUtils";
// Must match rx-jupyter' FileType
export type FileType = "directory" | "file" | "notebook";
// Utilities for notebooks
export class NotebookUtil {
/**
* It's a notebook file if the filename ends with .ipynb.
*/
public static isNotebookFile(notebookPath: string): boolean {
const fileName = NotebookUtil.getName(notebookPath);
export function isNotebookFile(notebookPath: string): boolean {
const fileName = getName(notebookPath);
return !!fileName && StringUtils.endsWith(fileName, ".ipynb");
}
@ -21,12 +20,12 @@ export class NotebookUtil {
* @param name
* @param path
*/
public static createNotebookContentItem(name: string, path: string, type: FileType): NotebookContentItem {
export function createNotebookContentItem(name: string, path: string, type: FileType): NotebookContentItem {
return {
name,
path,
type: NotebookUtil.getType(type),
timestamp: NotebookUtil.getCurrentTimestamp(),
type: getType(type),
timestamp: getCurrentTimestamp(),
};
}
@ -34,7 +33,7 @@ export class NotebookUtil {
* Convert rx-jupyter type to our type
* @param type
*/
public static getType(type: FileType): NotebookContentItemType {
export function getType(type: FileType): NotebookContentItemType {
switch (type) {
case "directory":
return NotebookContentItemType.Directory;
@ -47,7 +46,7 @@ export class NotebookUtil {
}
}
public static getCurrentTimestamp(): number {
export function getCurrentTimestamp(): number {
return new Date().getTime();
}
@ -58,7 +57,7 @@ export class NotebookUtil {
* @param filepath
* @param notebook
*/
public static extractNewKernel(filepath: string | null, notebook: ImmutableNotebook) {
export function extractNewKernel(filepath: string | null, notebook: ImmutableNotebook) {
const cwd = (filepath && path.dirname(filepath)) || "/";
const kernelSpecName =
@ -70,7 +69,7 @@ export class NotebookUtil {
};
}
public static getFilePath(path: string, fileName: string): string {
export function getFilePath(path: string, fileName: string): string {
const contentInfo = GitHubUtils.fromContentUri(path);
if (contentInfo) {
let path = fileName;
@ -83,8 +82,8 @@ export class NotebookUtil {
return `${path}/${fileName}`;
}
public static getParentPath(filepath: string): undefined | string {
const basename = NotebookUtil.getName(filepath);
export function getParentPath(filepath: string): undefined | string {
const basename = getName(filepath);
if (basename) {
const contentInfo = GitHubUtils.fromContentUri(filepath);
if (contentInfo) {
@ -110,7 +109,7 @@ export class NotebookUtil {
return undefined;
}
public static getName(path: string): undefined | string {
export function getName(path: string): undefined | string {
let relativePath: string = path;
const contentInfo = GitHubUtils.fromContentUri(path);
if (contentInfo) {
@ -120,7 +119,7 @@ export class NotebookUtil {
return relativePath.split("/").pop();
}
public static replaceName(path: string, newName: string): string {
export function replaceName(path: string, newName: string): string {
const contentInfo = GitHubUtils.fromContentUri(path);
if (contentInfo) {
const contentName = contentInfo.path.split("/").pop();
@ -141,7 +140,7 @@ export class NotebookUtil {
return `${basePath}${newName}`;
}
public static findFirstCodeCellWithDisplay(notebookObject: ImmutableNotebook): number {
export function findFirstCodeCellWithDisplay(notebookObject: ImmutableNotebook): number {
let codeCellIndex = 0;
for (let i = 0; i < notebookObject.cellOrder.size; i++) {
const cellId = notebookObject.cellOrder.get(i);
@ -160,4 +159,3 @@ export class NotebookUtil {
}
throw new Error("Output does not exist for any of the cells.");
}
}

View File

@ -5,7 +5,7 @@ import { FileSystemUtil } from "../Notebook/FileSystemUtil";
import "./PublishNotebookPaneComponent.less";
import Html2Canvas from "html2canvas";
import { ImmutableNotebook } from "@nteract/commutable/src";
import { NotebookUtil } from "../Notebook/NotebookUtil";
import * as NotebookUtil from "../Notebook/NotebookUtil";
export interface PublishNotebookPaneProps {
notebookName: string;

View File

@ -17,7 +17,7 @@ import NewNotebookIcon from "../../../images/notebook/Notebook-new.svg";
import FileIcon from "../../../images/notebook/file-cosmos.svg";
import PublishIcon from "../../../images/notebook/publish_content.svg";
import { ArrayHashMap } from "../../Common/ArrayHashMap";
import { NotebookUtil } from "../Notebook/NotebookUtil";
import * as NotebookUtil from "../Notebook/NotebookUtil";
import _ from "underscore";
import { IPinnedRepo } from "../../Juno/JunoClient";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";

View File

@ -2,7 +2,7 @@ import { Octokit } from "@octokit/rest";
import { HttpStatusCodes } from "../Common/Constants";
import * as Logger from "../Common/Logger";
import UrlUtility from "../Common/UrlUtility";
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
import * as NotebookUtil from "../Explorer/Notebook/NotebookUtil";
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
export interface IGitHubPageInfo {

View File

@ -5,7 +5,7 @@ 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 * as NotebookUtil from "../Explorer/Notebook/NotebookUtil";
import { GitHubClient, IGitHubFile, IGitHubResponse } from "./GitHubClient";
import * as GitHubUtils from "../Utils/GitHubUtils";
import UrlUtility from "../Common/UrlUtility";