Add Additional Lint Rules (#55)
This commit is contained in:
parent
123902e7ee
commit
269ea6a349
|
@ -3,7 +3,7 @@ module.exports = {
|
|||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
plugins: ["@typescript-eslint", "no-null"],
|
||||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
globals: {
|
||||
Atomics: "readonly",
|
||||
|
@ -37,6 +37,8 @@ module.exports = {
|
|||
],
|
||||
rules: {
|
||||
curly: "error",
|
||||
"@typescript-eslint/no-unused-vars": "error"
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"no-null/no-null": "error"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7924,6 +7924,12 @@
|
|||
"@typescript-eslint/experimental-utils": "^2.5.0"
|
||||
}
|
||||
},
|
||||
"eslint-plugin-no-null": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-no-null/-/eslint-plugin-no-null-1.0.2.tgz",
|
||||
"integrity": "sha1-EjaoEjkTkKGHetQAfCbnRTQclR8=",
|
||||
"dev": true
|
||||
},
|
||||
"eslint-plugin-react": {
|
||||
"version": "7.20.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.20.0.tgz",
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
"enzyme-to-json": "3.4.3",
|
||||
"eslint": "7.2.0",
|
||||
"eslint-cli": "1.1.1",
|
||||
"eslint-plugin-no-null": "1.0.2",
|
||||
"eslint-plugin-react": "7.20.0",
|
||||
"expose-loader": "0.7.5",
|
||||
"file-loader": "2.0.0",
|
||||
|
|
|
@ -6,7 +6,7 @@ import Q from "q";
|
|||
import { ConflictDefinition, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { DataAccessUtilityBase } from "./DataAccessUtilityBase";
|
||||
import { Logger } from "./Logger";
|
||||
import * as Logger from "./Logger";
|
||||
import { MessageHandler } from "./MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { MinimalQueryIterator, nextPage } from "./IteratorUtilities";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { LogEntryLevel } from "../Contracts/Diagnostics";
|
||||
import { Logger } from "./Logger";
|
||||
import * as Logger from "./Logger";
|
||||
import { MessageHandler } from "./MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
|
||||
|
|
|
@ -4,51 +4,35 @@ import { appInsights } from "../Shared/appInsights";
|
|||
import { SeverityLevel } from "@microsoft/applicationinsights-web";
|
||||
|
||||
// TODO: Move to a separate Diagnostics folder
|
||||
export class Logger {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public static logInfo(message: string | Record<string, any>, area: string, code?: number): void {
|
||||
export function logInfo(message: string | Record<string, any>, area: string, code?: number): void {
|
||||
let logMessage: string;
|
||||
if (typeof message === "string") {
|
||||
logMessage = message;
|
||||
} else {
|
||||
logMessage = JSON.stringify(message, Object.getOwnPropertyNames(message));
|
||||
}
|
||||
const entry: Diagnostics.LogEntry = Logger._generateLogEntry(
|
||||
Diagnostics.LogEntryLevel.Verbose,
|
||||
logMessage,
|
||||
area,
|
||||
code
|
||||
);
|
||||
return Logger._logEntry(entry);
|
||||
const entry: Diagnostics.LogEntry = _generateLogEntry(Diagnostics.LogEntryLevel.Verbose, logMessage, area, code);
|
||||
return _logEntry(entry);
|
||||
}
|
||||
|
||||
public static logWarning(message: string, area: string, code?: number): void {
|
||||
const entry: Diagnostics.LogEntry = Logger._generateLogEntry(
|
||||
Diagnostics.LogEntryLevel.Warning,
|
||||
message,
|
||||
area,
|
||||
code
|
||||
);
|
||||
return Logger._logEntry(entry);
|
||||
export function logWarning(message: string, area: string, code?: number): void {
|
||||
const entry: Diagnostics.LogEntry = _generateLogEntry(Diagnostics.LogEntryLevel.Warning, message, area, code);
|
||||
return _logEntry(entry);
|
||||
}
|
||||
|
||||
public static logError(message: string | Error, area: string, code?: number): void {
|
||||
export function logError(message: string | Error, area: string, code?: number): void {
|
||||
let logMessage: string;
|
||||
if (typeof message === "string") {
|
||||
logMessage = message;
|
||||
} else {
|
||||
logMessage = JSON.stringify(message, Object.getOwnPropertyNames(message));
|
||||
}
|
||||
const entry: Diagnostics.LogEntry = Logger._generateLogEntry(
|
||||
Diagnostics.LogEntryLevel.Error,
|
||||
logMessage,
|
||||
area,
|
||||
code
|
||||
);
|
||||
return Logger._logEntry(entry);
|
||||
const entry: Diagnostics.LogEntry = _generateLogEntry(Diagnostics.LogEntryLevel.Error, logMessage, area, code);
|
||||
return _logEntry(entry);
|
||||
}
|
||||
|
||||
private static _logEntry(entry: Diagnostics.LogEntry): void {
|
||||
function _logEntry(entry: Diagnostics.LogEntry): void {
|
||||
MessageHandler.sendMessage({
|
||||
type: MessageTypes.LogInfo,
|
||||
data: JSON.stringify(entry)
|
||||
|
@ -71,7 +55,7 @@ export class Logger {
|
|||
appInsights.trackTrace({ message: entry.message, severityLevel }, { area: entry.area });
|
||||
}
|
||||
|
||||
private static _generateLogEntry(
|
||||
function _generateLogEntry(
|
||||
level: Diagnostics.LogEntryLevel,
|
||||
message: string,
|
||||
area: string,
|
||||
|
@ -85,4 +69,3 @@ export class Logger {
|
|||
code: code
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import { BackendDefaults, HttpStatusCodes, SavedQueries } from "./Constants";
|
|||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "./CosmosClient";
|
||||
import { ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import { Logger } from "./Logger";
|
||||
import * as Logger from "./Logger";
|
||||
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
|
||||
import { QueryUtils } from "../Utils/QueryUtils";
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
IContextualMenuProps,
|
||||
ContextualMenuItemType
|
||||
} from "office-ui-fabric-react/lib/ContextualMenu";
|
||||
import { Logger } from "../../../Common/Logger";
|
||||
import * as Logger from "../../../Common/Logger";
|
||||
|
||||
export interface ArcadiaMenuPickerProps {
|
||||
selectText?: string;
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as Constants from "../../../Common/Constants";
|
|||
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
import { RepoListItem } from "./GitHubReposComponent";
|
||||
import { ChildrenMargin } from "./GitHubStyleConstants";
|
||||
import { GitHubUtils } from "../../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../../Utils/GitHubUtils";
|
||||
import { IGitHubRepo } from "../../../GitHub/GitHubClient";
|
||||
import TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
import UrlUtility from "../../../Common/UrlUtility";
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
} from "office-ui-fabric-react";
|
||||
import * as React from "react";
|
||||
import { IGitHubBranch, IGitHubPageInfo } from "../../../GitHub/GitHubClient";
|
||||
import { GitHubUtils } from "../../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../../Utils/GitHubUtils";
|
||||
import { RepoListItem } from "./GitHubReposComponent";
|
||||
import {
|
||||
BranchesDropdownCheckboxStyles,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as React from "react";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import { Logger } from "../../../Common/Logger";
|
||||
import * as Logger from "../../../Common/Logger";
|
||||
import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { StringUtils } from "../../../Utils/StringUtils";
|
||||
|
|
|
@ -22,7 +22,7 @@ export class GalleryCardComponent extends React.Component<GalleryCardComponentPr
|
|||
private attendantsCardSectionTokens: ICardSectionTokens = { childrenGap: 6 };
|
||||
|
||||
public render(): JSX.Element {
|
||||
return this.props.notebookMetadata != null ? (
|
||||
return this.props.notebookMetadata !== undefined ? (
|
||||
<Card aria-label="Notebook Card" onClick={this.props.onClick} tokens={this.cardTokens}>
|
||||
<Card.Item>
|
||||
<Persona text={this.props.notebookMetadata.author} secondaryText={this.props.notebookMetadata.date} />
|
||||
|
|
|
@ -350,7 +350,7 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
|
|||
if (!this.props.container) {
|
||||
SessionStorageUtility.setEntryString(
|
||||
StorageKey.NotebookMetadata,
|
||||
notebookMetadata ? JSON.stringify(notebookMetadata) : null
|
||||
notebookMetadata ? JSON.stringify(notebookMetadata) : undefined
|
||||
);
|
||||
SessionStorageUtility.setEntryString(StorageKey.NotebookName, path.basename(url));
|
||||
window.open(`${config.hostedExplorerURL}notebookViewer.html?notebookurl=${url}`, "_blank");
|
||||
|
|
|
@ -57,7 +57,7 @@ import { isInvalidParentFrameOrigin } from "../Utils/MessageValidation";
|
|||
import { JunoClient } from "../Juno/JunoClient";
|
||||
import { LibraryManagePane } from "./Panes/LibraryManagePane";
|
||||
import { LoadQueryPane } from "./Panes/LoadQueryPane";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { ManageSparkClusterPane } from "./Panes/ManageSparkClusterPane";
|
||||
import { MessageHandler } from "../Common/MessageHandler";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./Notebook/NotebookContentItem";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as sinon from "sinon";
|
||||
import { GremlinClient, GremlinClientParameters } from "./GremlinClient";
|
||||
import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { Logger } from "../../../Common/Logger";
|
||||
import * as Logger from "../../../Common/Logger";
|
||||
|
||||
describe("Gremlin Client", () => {
|
||||
const emptyParams: GremlinClientParameters = {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { GremlinSimpleClient, Result } from "./GremlinSimpleClient";
|
|||
import { NotificationConsoleUtils } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { HashMap } from "../../../Common/HashMap";
|
||||
import { Logger } from "../../../Common/Logger";
|
||||
import * as Logger from "../../../Common/Logger";
|
||||
|
||||
export interface GremlinClientParameters {
|
||||
endpoint: string;
|
||||
|
|
|
@ -2,7 +2,7 @@ import { ServerConfig, IContentProvider, FileType, IContent, IGetParams } from "
|
|||
import { Observable } from "rxjs";
|
||||
import { AjaxResponse } from "rxjs/ajax";
|
||||
import { GitHubContentProvider } from "../../../GitHub/GitHubContentProvider";
|
||||
import { GitHubUtils } from "../../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../../Utils/GitHubUtils";
|
||||
|
||||
export class NotebookContentProvider implements IContentProvider {
|
||||
constructor(private gitHubContentProvider: GitHubContentProvider, private jupyterContentProvider: IContentProvider) {}
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as ViewModels from "../../Contracts/ViewModels";
|
|||
import * as Constants from "../../Common/Constants";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
|
||||
export class NotebookContainerClient implements ViewModels.INotebookContainerClient {
|
||||
private reconnectingNotificationId: string;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { NotebookUtil } from "./NotebookUtil";
|
||||
import { GitHubUtils } from "../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
|
||||
const fileName = "file";
|
||||
const notebookName = "file.ipynb";
|
||||
|
|
|
@ -2,7 +2,7 @@ import path from "path";
|
|||
import { ImmutableNotebook } from "@nteract/commutable";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||
import { StringUtils } from "../../Utils/StringUtils";
|
||||
import { GitHubUtils } from "../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
|
||||
// Must match rx-jupyter' FileType
|
||||
export type FileType = "directory" | "file" | "notebook";
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as ViewModels from "../../Contracts/ViewModels";
|
|||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../Common/Constants";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { QueriesGridComponentAdapter } from "../Controls/QueriesGridReactComponent/QueriesGridComponentAdapter";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ContextualPaneBase } from "./ContextualPaneBase";
|
|||
import { ClusterLibraryGridAdapter } from "../Controls/LibraryManagement/ClusterLibraryGridAdapter";
|
||||
import { ClusterLibraryGridProps, ClusterLibraryItem } from "../Controls/LibraryManagement/ClusterLibraryGrid";
|
||||
import { Library, SparkCluster, SparkClusterLibrary } from "../../Contracts/DataModels";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
|
||||
export class ClusterLibraryPane extends ContextualPaneBase {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import _ from "underscore";
|
||||
import { Areas, HttpStatusCodes } from "../../Common/Constants";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { GitHubClient, IGitHubPageInfo, IGitHubRepo } from "../../GitHub/GitHubClient";
|
||||
import { IPinnedRepo, JunoClient } from "../../Juno/JunoClient";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { GitHubUtils } from "../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
import { JunoUtils } from "../../Utils/JunoUtils";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import { AuthorizeAccessComponent } from "../Controls/GitHub/AuthorizeAccessComponent";
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
LibraryManageGridProps
|
||||
} from "../Controls/LibraryManagement/LibraryManage";
|
||||
import { Library } from "../../Contracts/DataModels";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
|
||||
export class LibraryManagePane extends ContextualPaneBase {
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as Constants from "../../Common/Constants";
|
|||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
|
||||
export class LoadQueryPane extends ContextualPaneBase implements ViewModels.LoadQueryPane {
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as Constants from "../../Common/Constants";
|
|||
import * as Entities from "./Entities";
|
||||
import EnvironmentUtility from "../../Common/EnvironmentUtility";
|
||||
import * as HeadersUtility from "../../Common/HeadersUtility";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import * as TableConstants from "./Constants";
|
||||
import * as TableEntityProcessor from "./TableEntityProcessor";
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
updateDocument
|
||||
} from "../../Common/MongoProxyClient";
|
||||
import { extractPartitionKey } from "@azure/cosmos";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { PartitionKeyDefinition } from "@azure/cosmos";
|
||||
|
||||
export default class MongoDocumentsTab extends DocumentsTab implements ViewModels.DocumentsTab {
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as ErrorParserUtility from "../../Common/ErrorParserUtility";
|
|||
import TabsBase from "./TabsBase";
|
||||
import { HashMap } from "../../Common/HashMap";
|
||||
import * as HeadersUtility from "../../Common/HeadersUtility";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { Splitter, SplitterBounds, SplitterDirection } from "../../Common/Splitter";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg";
|
||||
|
|
|
@ -5,7 +5,7 @@ import UploadWorker from "worker-loader!../../workers/upload";
|
|||
import { AuthType } from "../../AuthType";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { PlatformType } from "../../PlatformType";
|
||||
|
|
|
@ -10,7 +10,7 @@ import Collection from "./Collection";
|
|||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
|
||||
export default class Database implements ViewModels.Database {
|
||||
public nodeKind: string;
|
||||
|
|
|
@ -23,7 +23,7 @@ import { JunoClient, IPinnedRepo } from "../../Juno/JunoClient";
|
|||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../Common/Constants";
|
||||
import { GitHubUtils } from "../../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
import { SamplesRepo, SamplesBranch } from "../Notebook/NotebookSamples";
|
||||
|
||||
export class ResourceTreeAdapter implements ReactAdapter {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Octokit } from "@octokit/rest";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import UrlUtility from "../Common/UrlUtility";
|
||||
import { isSamplesCall, SamplesContentsQueryResponse } from "../Explorer/Notebook/NotebookSamples";
|
||||
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
|
||||
|
|
|
@ -3,7 +3,7 @@ import { fixture } from "@nteract/fixtures";
|
|||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { GitHubClient, IGitHubCommit, IGitHubFile } from "./GitHubClient";
|
||||
import { GitHubContentProvider } from "./GitHubContentProvider";
|
||||
import { GitHubUtils } from "../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../Utils/GitHubUtils";
|
||||
|
||||
const gitHubClient = new GitHubClient("token", () => {});
|
||||
const gitHubContentProvider = new GitHubContentProvider({
|
||||
|
|
|
@ -3,10 +3,10 @@ import { FileType, IContent, IContentProvider, IEmptyContent, IGetParams, Server
|
|||
import { from, Observable, of } from "rxjs";
|
||||
import { AjaxResponse } from "rxjs/ajax";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
|
||||
import { GitHubClient, IGitHubFile, IGitHubResponse, IGitHubCommit, IGitHubBranch } from "./GitHubClient";
|
||||
import { GitHubUtils } from "../Utils/GitHubUtils";
|
||||
import * as GitHubUtils from "../Utils/GitHubUtils";
|
||||
import UrlUtility from "../Common/UrlUtility";
|
||||
|
||||
export interface GitHubContentProviderParams {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ko from "knockout";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { config } from "../Config";
|
||||
import { AuthorizeAccessComponent } from "../Explorer/Controls/GitHub/AuthorizeAccessComponent";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
|
|
|
@ -23,7 +23,7 @@ import { DialogProps } from "./Explorer/Controls/DialogReactComponent/DialogComp
|
|||
import { DirectoryListProps } from "./Explorer/Controls/Directory/DirectoryListComponent";
|
||||
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
||||
import { LocalStorageUtility, StorageKey, SessionStorageUtility } from "./Shared/StorageUtility";
|
||||
import { Logger } from "./Common/Logger";
|
||||
import * as Logger from "./Common/Logger";
|
||||
import { MeControlComponentProps } from "./Explorer/Menus/NavBar/MeControlComponent";
|
||||
import { MeControlComponentAdapter } from "./Explorer/Menus/NavBar/MeControlComponentAdapter";
|
||||
import { MessageTypes } from "./Contracts/ExplorerContracts";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { ArmApiVersions } from "../Common/Constants";
|
||||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import {
|
||||
NotebookWorkspace,
|
||||
NotebookWorkspaceConnectionInfo,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import AuthHeadersUtil from "./Authorization";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { Tenant, Subscription, DatabaseAccount, AccountKeys } from "../../Contracts/DataModels";
|
||||
import { config } from "../../Config";
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
|||
import { ConsoleDataType } from "../../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
import { CosmosClient } from "../../Common/CosmosClient";
|
||||
import { Logger } from "../../Common/Logger";
|
||||
import * as Logger from "../../Common/Logger";
|
||||
import { config } from "../../Config";
|
||||
|
||||
export default class AuthHeadersUtil {
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
} from "../Contracts/DataModels";
|
||||
import { ArmApiVersions, ArmResourceTypes } from "../Common/Constants";
|
||||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import { config } from "../Config";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { ArmApiVersions } from "../Common/Constants";
|
||||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import {
|
||||
SparkCluster,
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as Constants from "../Common/Constants";
|
|||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import AuthHeadersUtil from "../Platform/Hosted/Authorization";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { PlatformType } from "../PlatformType";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { config } from "../Config";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GitHubUtils } from "./GitHubUtils";
|
||||
import * as GitHubUtils from "./GitHubUtils";
|
||||
|
||||
const owner = "owner-1";
|
||||
const repo = "repo-1";
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
export class GitHubUtils {
|
||||
// https://github.com/<owner>/<repo>/tree/<branch>
|
||||
// The url when users visit a repo/branch on github.com
|
||||
private static readonly RepoUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/tree\/([^?]*)/;
|
||||
export const RepoUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/tree\/([^?]*)/;
|
||||
|
||||
// github://<owner>/<repo>/<path>?ref=<branch>
|
||||
// Custom scheme for github content
|
||||
private static readonly ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
|
||||
export const ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
|
||||
|
||||
// https://github.com/<owner>/<repo>/blob/<branch>/<path>
|
||||
// We need to support this until we move to newer scheme for quickstarts
|
||||
private static readonly LegacyContentUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/blob\/([^/]*)\/([^?]*)/;
|
||||
export const LegacyContentUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/blob\/([^/]*)\/([^?]*)/;
|
||||
|
||||
public static toRepoFullName(owner: string, repo: string): string {
|
||||
export function toRepoFullName(owner: string, repo: string): string {
|
||||
return `${owner}/${repo}`;
|
||||
}
|
||||
|
||||
public static fromRepoUri(repoUri: string): undefined | { owner: string; repo: string; branch: string } {
|
||||
const matches = repoUri.match(GitHubUtils.RepoUriPattern);
|
||||
export function fromRepoUri(repoUri: string): undefined | { owner: string; repo: string; branch: string } {
|
||||
const matches = repoUri.match(RepoUriPattern);
|
||||
if (matches && matches.length > 3) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
|
@ -28,10 +27,10 @@ export class GitHubUtils {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
public static fromContentUri(
|
||||
export function fromContentUri(
|
||||
contentUri: string
|
||||
): undefined | { owner: string; repo: string; branch: string; path: string } {
|
||||
let matches = contentUri.match(GitHubUtils.ContentUriPattern);
|
||||
let matches = contentUri.match(ContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
|
@ -41,7 +40,7 @@ export class GitHubUtils {
|
|||
};
|
||||
}
|
||||
|
||||
matches = contentUri.match(GitHubUtils.LegacyContentUriPattern);
|
||||
matches = contentUri.match(LegacyContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
console.log(`Using legacy github content uri scheme ${contentUri}`);
|
||||
|
||||
|
@ -56,7 +55,6 @@ export class GitHubUtils {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
public static toContentUri(owner: string, repo: string, branch: string, path: string): string {
|
||||
export function toContentUri(owner: string, repo: string, branch: string, path: string): string {
|
||||
return `github://${owner}/${repo}/${path}?ref=${branch}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as DataModels from "../Contracts/DataModels";
|
||||
import { Explorer, KernelConnectionMetadata } from "../Contracts/ViewModels";
|
||||
import { Logger } from "../Common/Logger";
|
||||
import * as Logger from "../Common/Logger";
|
||||
|
||||
export class NotebookConfigurationUtils {
|
||||
private constructor() {}
|
||||
|
|
Loading…
Reference in New Issue