mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Enforce semicolons in eslint
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
0f3f5611ba
commit
1477bb8274
531 files changed
+3979
-3975
No files matched your search
@@ -1,18 +1,18 @@
|
||||
import React from "react"
|
||||
import { displayBooleans } from "../display-booleans"
|
||||
import React from "react";
|
||||
import { displayBooleans } from "../display-booleans";
|
||||
|
||||
describe("displayBooleans tests", () => {
|
||||
it("should not do anything to div's if shouldShow is false", () => {
|
||||
expect(displayBooleans(false, <div></div>)).toStrictEqual(<div></div>)
|
||||
})
|
||||
expect(displayBooleans(false, <div></div>)).toStrictEqual(<div></div>);
|
||||
});
|
||||
|
||||
it("should not do anything to booleans's if shouldShow is false", () => {
|
||||
expect(displayBooleans(false, true)).toStrictEqual(true)
|
||||
expect(displayBooleans(false, false)).toStrictEqual(false)
|
||||
})
|
||||
expect(displayBooleans(false, true)).toStrictEqual(true);
|
||||
expect(displayBooleans(false, false)).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it("should stringify booleans when shouldShow is true", () => {
|
||||
expect(displayBooleans(true, true)).toStrictEqual("true")
|
||||
expect(displayBooleans(true, false)).toStrictEqual("false")
|
||||
})
|
||||
})
|
||||
expect(displayBooleans(true, true)).toStrictEqual("true");
|
||||
expect(displayBooleans(true, false)).toStrictEqual("false");
|
||||
});
|
||||
});
|
||||
@@ -23,11 +23,11 @@ export function cancelableFetch(reqInfo: RequestInfo, reqInit: RequestInit = {})
|
||||
promise.then = function (onfulfilled, onrejected) {
|
||||
const data = Object.getPrototypeOf(this).then.call(this, onfulfilled, onrejected);
|
||||
return wrapResult(data);
|
||||
}
|
||||
};
|
||||
promise.cancel = cancel;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
const req = fetch(reqInfo, { ...reqInit, signal });
|
||||
return wrapResult(req);
|
||||
|
||||
@@ -5,9 +5,9 @@ const million = thousand * thousand;
|
||||
const shortBillion = thousand * million;
|
||||
|
||||
export function cpuUnitsToNumber(cpu: string) {
|
||||
const cpuNum = parseInt(cpu)
|
||||
if (cpu.includes("m")) return cpuNum / thousand
|
||||
if (cpu.includes("u")) return cpuNum / million
|
||||
if (cpu.includes("n")) return cpuNum / shortBillion
|
||||
return parseFloat(cpu)
|
||||
const cpuNum = parseInt(cpu);
|
||||
if (cpu.includes("m")) return cpuNum / thousand;
|
||||
if (cpu.includes("u")) return cpuNum / million;
|
||||
if (cpu.includes("n")) return cpuNum / shortBillion;
|
||||
return parseFloat(cpu);
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
// Helper to convert memory from units Ki, Mi, Gi, Ti, Pi to bytes and vise versa
|
||||
|
||||
const base = 1024
|
||||
const suffixes = ['K', 'M', 'G', 'T', 'P', 'E'] // Equivalents: Ki, Mi, Gi, Ti, Pi, Ei
|
||||
const base = 1024;
|
||||
const suffixes = ['K', 'M', 'G', 'T', 'P', 'E']; // Equivalents: Ki, Mi, Gi, Ti, Pi, Ei
|
||||
|
||||
export function unitsToBytes(value: string) {
|
||||
if (!suffixes.some(suffix => value.includes(suffix))) {
|
||||
return parseFloat(value)
|
||||
return parseFloat(value);
|
||||
}
|
||||
|
||||
const suffix = value.replace(/[0-9]|i|\./g, '');
|
||||
const index = suffixes.indexOf(suffix);
|
||||
return parseInt(
|
||||
(parseFloat(value) * Math.pow(base, index + 1)).toFixed(1)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function bytesToUnits(bytes: number, precision = 1) {
|
||||
const sizes = ["B", ...suffixes]
|
||||
const index = Math.floor(Math.log(bytes) / Math.log(base))
|
||||
const sizes = ["B", ...suffixes];
|
||||
const index = Math.floor(Math.log(bytes) / Math.log(base));
|
||||
if (!bytes) {
|
||||
return "N/A"
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
return `${bytes}${sizes[index]}`
|
||||
return `${bytes}${sizes[index]}`;
|
||||
}
|
||||
|
||||
return `${(bytes / (1024 ** index)).toFixed(precision)}${sizes[index]}i`
|
||||
return `${(bytes / (1024 ** index)).toFixed(precision)}${sizes[index]}i`;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ export function copyToClipboard(elem: HTMLElement, resetSelection = true): boole
|
||||
let clearSelection: () => void;
|
||||
if (isSelectable(elem)) {
|
||||
elem.select();
|
||||
clearSelection = () => elem.setSelectionRange(0, 0)
|
||||
clearSelection = () => elem.setSelectionRange(0, 0);
|
||||
}
|
||||
else {
|
||||
const selection = window.getSelection();
|
||||
|
||||
@@ -36,7 +36,7 @@ export class StorageHelper<T> {
|
||||
try {
|
||||
return JSON.parse(strValue);
|
||||
} catch (e) {
|
||||
console.error(`Parsing json failed for pair: ${this.key}=${strValue}`)
|
||||
console.error(`Parsing json failed for pair: ${this.key}=${strValue}`);
|
||||
}
|
||||
}
|
||||
return this.defaultValue;
|
||||
|
||||
@@ -13,5 +13,5 @@ export function cssVar(elem: HTMLElement) {
|
||||
if (typeof value === "number") value = value + "px";
|
||||
elem.style.setProperty(name, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import React from "react"
|
||||
import React from "react";
|
||||
|
||||
export function displayBooleans(shouldShow: boolean, from: React.ReactNode): React.ReactNode {
|
||||
if (shouldShow) {
|
||||
if (typeof from === "boolean") {
|
||||
return from.toString()
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
if (Array.isArray(from)) {
|
||||
return from.map(node => displayBooleans(shouldShow, node))
|
||||
return from.map(node => displayBooleans(shouldShow, node));
|
||||
}
|
||||
}
|
||||
|
||||
return from
|
||||
return from;
|
||||
}
|
||||
@@ -8,5 +8,5 @@ export function downloadFile(filename: string, contents: any, type: string) {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url)
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
+15
-15
@@ -3,19 +3,19 @@
|
||||
export const noop: any = Function();
|
||||
export const isElectron = !!navigator.userAgent.match(/Electron/);
|
||||
|
||||
export * from "../../common/utils"
|
||||
export * from "../../common/utils";
|
||||
|
||||
export * from "./cssVar"
|
||||
export * from "./cssNames"
|
||||
export * from "../../common/event-emitter"
|
||||
export * from "./downloadFile"
|
||||
export * from "./prevDefault"
|
||||
export * from "./createStorage"
|
||||
export * from "./interval"
|
||||
export * from "./copyToClipboard"
|
||||
export * from "./formatDuration"
|
||||
export * from "./isReactNode"
|
||||
export * from "./convertMemory"
|
||||
export * from "./convertCpu"
|
||||
export * from "./metricUnitsToNumber"
|
||||
export * from "./display-booleans"
|
||||
export * from "./cssVar";
|
||||
export * from "./cssNames";
|
||||
export * from "../../common/event-emitter";
|
||||
export * from "./downloadFile";
|
||||
export * from "./prevDefault";
|
||||
export * from "./createStorage";
|
||||
export * from "./interval";
|
||||
export * from "./copyToClipboard";
|
||||
export * from "./formatDuration";
|
||||
export * from "./isReactNode";
|
||||
export * from "./convertMemory";
|
||||
export * from "./convertCpu";
|
||||
export * from "./metricUnitsToNumber";
|
||||
export * from "./display-booleans";
|
||||
@@ -26,7 +26,7 @@ export function interval(timeSec = 1, callback: IntervalCallback, autoRun = fals
|
||||
get isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (autoRun) intervalManager.start();
|
||||
return intervalManager;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// Type guard for checking valid react node to use in render
|
||||
import React, { ReactNode } from "react"
|
||||
import React, { ReactNode } from "react";
|
||||
|
||||
export function isReactNode(node: ReactNode): node is ReactNode {
|
||||
return React.isValidElement(node)
|
||||
|| Array.isArray(node) && node.every(isReactNode)
|
||||
|| node == null
|
||||
|| typeof node !== "object"
|
||||
|| typeof node !== "object";
|
||||
}
|
||||
@@ -6,5 +6,5 @@ export function metricUnitsToNumber(value: string): number {
|
||||
const index = suffixes.indexOf(suffix);
|
||||
return parseInt(
|
||||
(parseFloat(value) * Math.pow(base, index + 1)).toFixed(1)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export function prevDefault<E extends React.SyntheticEvent | Event>(callback: (e
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
return callback(evt);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function stopPropagation(evt: Event | React.SyntheticEvent) {
|
||||
|
||||
@@ -25,4 +25,4 @@ export const ResourceNames: Record<KubeResource, string> = {
|
||||
"horizontalpodautoscalers": _i18n._("Horizontal Pod Autoscalers"),
|
||||
"podsecuritypolicies": _i18n._("Pod Security Policies"),
|
||||
"poddisruptionbudgets": _i18n._("Pod Disruption Budgets"),
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user