mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-08 09:23:30 +01: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/PricingUtils.test.ts
|
||||||
src/Utils/QueryUtils.test.ts
|
src/Utils/QueryUtils.test.ts
|
||||||
src/Utils/QueryUtils.ts
|
src/Utils/QueryUtils.ts
|
||||||
src/Utils/StringUtils.test.ts
|
|
||||||
src/Utils/StringUtils.ts
|
|
||||||
src/applyExplorerBindings.ts
|
src/applyExplorerBindings.ts
|
||||||
src/global.d.ts
|
src/global.d.ts
|
||||||
src/setupTests.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 { KeyCodes } from "../../../Common/Constants";
|
||||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as DataModels from "../../../Contracts/DataModels";
|
import * as DataModels from "../../../Contracts/DataModels";
|
||||||
import { StringUtils } from "../../../Utils/StringUtils";
|
import * as StringUtils from "../../../Utils/StringUtils";
|
||||||
import { userContext } from "../../../UserContext";
|
import { userContext } from "../../../UserContext";
|
||||||
import { TerminalQueryParams } from "../../../Common/Constants";
|
import { TerminalQueryParams } from "../../../Common/Constants";
|
||||||
import { handleError } from "../../../Common/ErrorHandlingUtils";
|
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 { actions, AppState, ContentRef, selectors } from "@nteract/core";
|
||||||
import { IMonacoProps as MonacoEditorProps } from "@nteract/monaco-editor";
|
import { IMonacoProps as MonacoEditorProps } from "@nteract/monaco-editor";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||||
import { StringUtils } from "../../Utils/StringUtils";
|
import * as StringUtils from "../../Utils/StringUtils";
|
||||||
import { FileSystemUtil } from "./FileSystemUtil";
|
import { FileSystemUtil } from "./FileSystemUtil";
|
||||||
import { NotebookUtil } from "./NotebookUtil";
|
import { NotebookUtil } from "./NotebookUtil";
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { ImmutableNotebook, ImmutableCodeCell } from "@nteract/commutable";
|
import { ImmutableNotebook, ImmutableCodeCell } from "@nteract/commutable";
|
||||||
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
import { NotebookContentItem, NotebookContentItemType } from "./NotebookContentItem";
|
||||||
import { StringUtils } from "../../Utils/StringUtils";
|
import * as StringUtils from "../../Utils/StringUtils";
|
||||||
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
import * as GitHubUtils from "../../Utils/GitHubUtils";
|
||||||
|
|
||||||
// Must match rx-jupyter' FileType
|
// Must match rx-jupyter' FileType
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { StringUtils } from "./StringUtils";
|
import * as StringUtils from "./StringUtils";
|
||||||
|
|
||||||
describe("StringUtils", () => {
|
describe("StringUtils", () => {
|
||||||
describe("stripSpacesFromString()", () => {
|
describe("stripSpacesFromString()", () => {
|
||||||
@ -12,9 +12,9 @@ describe("StringUtils", () => {
|
|||||||
expect(transformedString).toBe("abc");
|
expect(transformedString).toBe("abc");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return null if input is null", () => {
|
it("should return undefined if input is undefined", () => {
|
||||||
const transformedString: string = StringUtils.stripSpacesFromString(null);
|
const transformedString: string = StringUtils.stripSpacesFromString(undefined);
|
||||||
expect(transformedString).toBeNull();
|
expect(transformedString).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return undefined if input is undefiend", () => {
|
it("should return undefined if input is undefiend", () => {
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
export class StringUtils {
|
export function stripSpacesFromString(inputString: string): string {
|
||||||
public static stripSpacesFromString(inputString: string): string {
|
if (inputString === undefined || typeof inputString !== "string") {
|
||||||
if (inputString == null || typeof inputString !== "string") {
|
return inputString;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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