Add Additional Lint Rules (#55)

This commit is contained in:
Steve Faulkner
2020-06-23 10:45:51 -05:00
committed by GitHub
parent 123902e7ee
commit 269ea6a349
45 changed files with 172 additions and 182 deletions

View File

@@ -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";

View File

@@ -1,4 +1,4 @@
import { GitHubUtils } from "./GitHubUtils";
import * as GitHubUtils from "./GitHubUtils";
const owner = "owner-1";
const repo = "repo-1";

View File

@@ -1,62 +1,60 @@
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\/([^?]*)/;
// https://github.com/<owner>/<repo>/tree/<branch>
// The url when users visit a repo/branch on github.com
export const RepoUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/tree\/([^?]*)/;
// github://<owner>/<repo>/<path>?ref=<branch>
// Custom scheme for github content
private static readonly ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
// github://<owner>/<repo>/<path>?ref=<branch>
// Custom scheme for github content
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\/([^/]*)\/([^?]*)/;
// https://github.com/<owner>/<repo>/blob/<branch>/<path>
// We need to support this until we move to newer scheme for quickstarts
export const LegacyContentUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/blob\/([^/]*)\/([^?]*)/;
public static 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);
if (matches && matches.length > 3) {
return {
owner: matches[1],
repo: matches[2],
branch: matches[3]
};
}
return undefined;
}
public static fromContentUri(
contentUri: string
): undefined | { owner: string; repo: string; branch: string; path: string } {
let matches = contentUri.match(GitHubUtils.ContentUriPattern);
if (matches && matches.length > 4) {
return {
owner: matches[1],
repo: matches[2],
branch: matches[4],
path: matches[3]
};
}
matches = contentUri.match(GitHubUtils.LegacyContentUriPattern);
if (matches && matches.length > 4) {
console.log(`Using legacy github content uri scheme ${contentUri}`);
return {
owner: matches[1],
repo: matches[2],
branch: matches[3],
path: matches[4]
};
}
return undefined;
}
public static toContentUri(owner: string, repo: string, branch: string, path: string): string {
return `github://${owner}/${repo}/${path}?ref=${branch}`;
}
export function toRepoFullName(owner: string, repo: string): string {
return `${owner}/${repo}`;
}
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],
repo: matches[2],
branch: matches[3]
};
}
return undefined;
}
export function fromContentUri(
contentUri: string
): undefined | { owner: string; repo: string; branch: string; path: string } {
let matches = contentUri.match(ContentUriPattern);
if (matches && matches.length > 4) {
return {
owner: matches[1],
repo: matches[2],
branch: matches[4],
path: matches[3]
};
}
matches = contentUri.match(LegacyContentUriPattern);
if (matches && matches.length > 4) {
console.log(`Using legacy github content uri scheme ${contentUri}`);
return {
owner: matches[1],
repo: matches[2],
branch: matches[3],
path: matches[4]
};
}
return undefined;
}
export function toContentUri(owner: string, repo: string, branch: string, path: string): string {
return `github://${owner}/${repo}/${path}?ref=${branch}`;
}

View File

@@ -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() {}