mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
fixed lint issue of StringUtils file (#480)
* fixed lint issue of StringUtils file * Fixed null lint issue
This commit is contained in:
parent
9617b80b56
commit
d85b6285ac
@ -279,8 +279,6 @@ src/Utils/NotebookConfigurationUtils.ts
|
||||
src/Utils/PricingUtils.test.ts
|
||||
src/Utils/QueryUtils.test.ts
|
||||
src/Utils/QueryUtils.ts
|
||||
src/Utils/StringUtils.test.ts
|
||||
src/Utils/StringUtils.ts
|
||||
src/applyExplorerBindings.ts
|
||||
src/global.d.ts
|
||||
src/setupTests.ts
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../Utils/StringUtils";
|
||||
import { KeyCodes } from "../../../Common/Constants";
|
||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import { StringUtils } from "../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../Utils/StringUtils";
|
||||
import { userContext } from "../../../UserContext";
|
||||
import { TerminalQueryParams } from "../../../Common/Constants";
|
||||
import { handleError } from "../../../Common/ErrorHandlingUtils";
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "../../../../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../../../../Utils/StringUtils";
|
||||
import { actions, AppState, ContentRef, selectors } from "@nteract/core";
|
||||
import { IMonacoProps as MonacoEditorProps } from "@nteract/monaco-editor";
|
||||
import * as React from "react";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||
import { StringUtils } from "../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../Utils/StringUtils";
|
||||
import { FileSystemUtil } from "./FileSystemUtil";
|
||||
import { NotebookUtil } from "./NotebookUtil";
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import { ImmutableNotebook, ImmutableCodeCell } from "@nteract/commutable";
|
||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||
import { StringUtils } from "../../Utils/StringUtils";
|
||||
import * as StringUtils from "../../Utils/StringUtils";
|
||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||
|
||||
// Must match rx-jupyter' FileType
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { StringUtils } from "./StringUtils";
|
||||
import * as StringUtils from "./StringUtils";
|
||||
|
||||
describe("StringUtils", () => {
|
||||
describe("stripSpacesFromString()", () => {
|
||||
@ -12,9 +12,9 @@ describe("StringUtils", () => {
|
||||
expect(transformedString).toBe("abc");
|
||||
});
|
||||
|
||||
it("should return null if input is null", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(null);
|
||||
expect(transformedString).toBeNull();
|
||||
it("should return undefined if input is undefined", () => {
|
||||
const transformedString: string = StringUtils.stripSpacesFromString(undefined);
|
||||
expect(transformedString).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined if input is undefiend", () => {
|
||||
|
@ -1,21 +1,19 @@
|
||||
export class StringUtils {
|
||||
public static stripSpacesFromString(inputString: string): string {
|
||||
if (inputString == null || typeof inputString !== "string") {
|
||||
return inputString;
|
||||
}
|
||||
return inputString.replace(/ /g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of endsWith which works for IE
|
||||
* @param stringToTest
|
||||
* @param suffix
|
||||
*/
|
||||
public static endsWith(stringToTest: string, suffix: string): boolean {
|
||||
return stringToTest.indexOf(suffix, stringToTest.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
public static startsWith(stringToTest: string, prefix: string): boolean {
|
||||
return stringToTest.indexOf(prefix) === 0;
|
||||
export function stripSpacesFromString(inputString: string): string {
|
||||
if (inputString === undefined || typeof inputString !== "string") {
|
||||
return inputString;
|
||||
}
|
||||
return inputString.replace(/ /g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of endsWith which works for IE
|
||||
* @param stringToTest
|
||||
* @param suffix
|
||||
*/
|
||||
export function endsWith(stringToTest: string, suffix: string): boolean {
|
||||
return stringToTest.indexOf(suffix, stringToTest.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
export function startsWith(stringToTest: string, prefix: string): boolean {
|
||||
return stringToTest.indexOf(prefix) === 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user