mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add eslint:recommended lint rule (#4577)
This commit is contained in:
parent
4f75acf2b4
commit
fa3708c879
@ -54,6 +54,7 @@ module.exports = {
|
|||||||
"react-hooks",
|
"react-hooks",
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
"comma-dangle": ["error", "always-multiline"],
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
"comma-spacing": "error",
|
"comma-spacing": "error",
|
||||||
@ -107,6 +108,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
parser: "@typescript-eslint/parser",
|
parser: "@typescript-eslint/parser",
|
||||||
extends: [
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:import/recommended",
|
"plugin:import/recommended",
|
||||||
"plugin:import/typescript",
|
"plugin:import/typescript",
|
||||||
@ -120,7 +122,7 @@ module.exports = {
|
|||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"no-irregular-whitespace": "error",
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
"no-invalid-this": "off",
|
"no-invalid-this": "off",
|
||||||
"@typescript-eslint/no-invalid-this": ["error"],
|
"@typescript-eslint/no-invalid-this": ["error"],
|
||||||
@ -193,6 +195,7 @@ module.exports = {
|
|||||||
"unused-imports",
|
"unused-imports",
|
||||||
],
|
],
|
||||||
extends: [
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:react/recommended",
|
"plugin:react/recommended",
|
||||||
"plugin:import/recommended",
|
"plugin:import/recommended",
|
||||||
@ -204,7 +207,7 @@ module.exports = {
|
|||||||
jsx: true,
|
jsx: true,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"no-irregular-whitespace": "error",
|
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||||
"header/header": [2, "./license-header"],
|
"header/header": [2, "./license-header"],
|
||||||
"react/prop-types": "off",
|
"react/prop-types": "off",
|
||||||
"no-invalid-this": "off",
|
"no-invalid-this": "off",
|
||||||
|
|||||||
@ -472,8 +472,8 @@ describe("pre 2.6.0 config with a cluster icon", () => {
|
|||||||
it("moves the icon into preferences", async () => {
|
it("moves the icon into preferences", async () => {
|
||||||
const storedClusterData = ClusterStore.getInstance().clustersList[0];
|
const storedClusterData = ClusterStore.getInstance().clustersList[0];
|
||||||
|
|
||||||
expect(storedClusterData.hasOwnProperty("icon")).toBe(false);
|
expect(Object.prototype.hasOwnProperty.call(storedClusterData, "icon")).toBe(false);
|
||||||
expect(storedClusterData.preferences.hasOwnProperty("icon")).toBe(true);
|
expect(Object.prototype.hasOwnProperty.call(storedClusterData.preferences, "icon")).toBe(true);
|
||||||
expect(storedClusterData.preferences.icon.startsWith("data:;base64,")).toBe(true);
|
expect(storedClusterData.preferences.icon.startsWith("data:;base64,")).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -164,14 +164,14 @@ describe("KubeObject", () => {
|
|||||||
|
|
||||||
describe("isJsonApiDataList", () => {
|
describe("isJsonApiDataList", () => {
|
||||||
function isAny(val: unknown): val is any {
|
function isAny(val: unknown): val is any {
|
||||||
return !Boolean(void val);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNotAny(val: unknown): val is any {
|
function isNotAny(val: unknown): val is any {
|
||||||
return Boolean(void val);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBoolean(val: unknown): val is Boolean {
|
function isBoolean(val: unknown): val is boolean {
|
||||||
return typeof val === "boolean";
|
return typeof val === "boolean";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,8 @@ export class CustomResourceDefinition extends KubeObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "apiextensions.k8s.io/v1beta1":
|
|
||||||
|
case "apiextensions.k8s.io/v1beta1": {
|
||||||
const { additionalPrinterColumns: apc } = this.spec;
|
const { additionalPrinterColumns: apc } = this.spec;
|
||||||
const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath }));
|
const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath }));
|
||||||
|
|
||||||
@ -173,6 +174,7 @@ export class CustomResourceDefinition extends KubeObject {
|
|||||||
schema: this.spec.validation,
|
schema: this.spec.validation,
|
||||||
additionalPrinterColumns,
|
additionalPrinterColumns,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Unknown apiVersion=${apiVersion}: Failed to find a version for CustomResourceDefinition ${this.metadata.name}`);
|
throw new Error(`Unknown apiVersion=${apiVersion}: Failed to find a version for CustomResourceDefinition ${this.metadata.name}`);
|
||||||
|
|||||||
@ -187,7 +187,7 @@ export class Ingress extends KubeObject {
|
|||||||
const servicePort = defaultBackend?.service.port.number ?? backend?.servicePort;
|
const servicePort = defaultBackend?.service.port.number ?? backend?.servicePort;
|
||||||
|
|
||||||
if (rules && rules.length > 0) {
|
if (rules && rules.length > 0) {
|
||||||
if (rules.some(rule => rule.hasOwnProperty("http"))) {
|
if (rules.some(rule => Object.prototype.hasOwnProperty.call(rule, "http"))) {
|
||||||
ports.push(httpPort);
|
ports.push(httpPort);
|
||||||
}
|
}
|
||||||
} else if (servicePort !== undefined) {
|
} else if (servicePort !== undefined) {
|
||||||
|
|||||||
@ -184,7 +184,8 @@ export function getMetricLastPoints(metrics: Record<string, IMetrics>) {
|
|||||||
if (metric.data.result.length) {
|
if (metric.data.result.length) {
|
||||||
result[metricName] = +metric.data.result[0].values.slice(-1)[0][1];
|
result[metricName] = +metric.data.result[0].values.slice(-1)[0][1];
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
|
// ignore error
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -701,21 +701,16 @@ export class KubeApi<T extends KubeObject> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected modifyWatchEvent(event: IKubeWatchEvent<KubeJsonApiData>) {
|
protected modifyWatchEvent(event: IKubeWatchEvent<KubeJsonApiData>) {
|
||||||
|
if (event.type === "ERROR") {
|
||||||
|
return;
|
||||||
|
|
||||||
switch (event.type) {
|
|
||||||
case "ADDED":
|
|
||||||
case "DELETED":
|
|
||||||
|
|
||||||
case "MODIFIED": {
|
|
||||||
ensureObjectSelfLink(this, event.object);
|
|
||||||
|
|
||||||
const { namespace, resourceVersion } = event.object.metadata;
|
|
||||||
|
|
||||||
this.setResourceVersion(namespace, resourceVersion);
|
|
||||||
this.setResourceVersion("", resourceVersion);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensureObjectSelfLink(this, event.object);
|
||||||
|
|
||||||
|
const { namespace, resourceVersion } = event.object.metadata;
|
||||||
|
|
||||||
|
this.setResourceVersion(namespace, resourceVersion);
|
||||||
|
this.setResourceVersion("", resourceVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -472,7 +472,9 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "ADDED":
|
case "ADDED":
|
||||||
case "MODIFIED":
|
|
||||||
|
// falls through
|
||||||
|
case "MODIFIED": {
|
||||||
const newItem = new this.api.objectConstructor(object);
|
const newItem = new this.api.objectConstructor(object);
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@ -480,7 +482,9 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
|||||||
} else {
|
} else {
|
||||||
items[index] = newItem;
|
items[index] = newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "DELETED":
|
case "DELETED":
|
||||||
if (item) {
|
if (item) {
|
||||||
items.splice(index, 1);
|
items.splice(index, 1);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export abstract class LensProtocolRouter {
|
|||||||
|
|
||||||
public static readonly LoggingPrefix = "[PROTOCOL ROUTER]";
|
public static readonly LoggingPrefix = "[PROTOCOL ROUTER]";
|
||||||
|
|
||||||
static readonly ExtensionUrlSchema = `/:${EXTENSION_PUBLISHER_MATCH}(\@[A-Za-z0-9_]+)?/:${EXTENSION_NAME_MATCH}`;
|
static readonly ExtensionUrlSchema = `/:${EXTENSION_PUBLISHER_MATCH}(@[A-Za-z0-9_]+)?/:${EXTENSION_NAME_MATCH}`;
|
||||||
|
|
||||||
constructor(protected dependencies: Dependencies) {}
|
constructor(protected dependencies: Dependencies) {}
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export class SearchStore {
|
|||||||
* @param value Unescaped string
|
* @param value Unescaped string
|
||||||
*/
|
*/
|
||||||
public static escapeRegex(value?: string): string {
|
public static escapeRegex(value?: string): string {
|
||||||
return value ? value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") : "";
|
return value ? value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
export function defineGlobal(propName: string, descriptor: PropertyDescriptor) {
|
export function defineGlobal(propName: string, descriptor: PropertyDescriptor) {
|
||||||
const scope = typeof global !== "undefined" ? global : window;
|
const scope = typeof global !== "undefined" ? global : window;
|
||||||
|
|
||||||
if (scope.hasOwnProperty(propName)) {
|
if (Object.prototype.hasOwnProperty.call(scope, propName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export type Falsey = false | 0 | "" | null | undefined;
|
|||||||
* Create a new type safe empty Iterable
|
* Create a new type safe empty Iterable
|
||||||
* @returns An `Iterable` that yields 0 items
|
* @returns An `Iterable` that yields 0 items
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line require-yield
|
||||||
export function* newEmpty<T>(): IterableIterator<T> {
|
export function* newEmpty<T>(): IterableIterator<T> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,12 +31,13 @@ export interface ReadFileFromTarOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function readFileFromTar<R = Buffer>({ tarPath, filePath, parseJson }: ReadFileFromTarOpts): Promise<R> {
|
export function readFileFromTar<R = Buffer>({ tarPath, filePath, parseJson }: ReadFileFromTarOpts): Promise<R> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const fileChunks: Buffer[] = [];
|
const fileChunks: Buffer[] = [];
|
||||||
|
|
||||||
await tar.list({
|
tar.list({
|
||||||
file: tarPath,
|
file: tarPath,
|
||||||
filter: entryPath => path.normalize(entryPath) === filePath,
|
filter: entryPath => path.normalize(entryPath) === filePath,
|
||||||
|
sync: true,
|
||||||
onentry(entry: FileStat) {
|
onentry(entry: FileStat) {
|
||||||
entry.on("data", chunk => {
|
entry.on("data", chunk => {
|
||||||
fileChunks.push(chunk);
|
fileChunks.push(chunk);
|
||||||
|
|||||||
@ -119,7 +119,9 @@ export class HelmRepoManager extends Singleton {
|
|||||||
if (typeof parsedConfig === "object" && parsedConfig) {
|
if (typeof parsedConfig === "object" && parsedConfig) {
|
||||||
return parsedConfig as HelmRepoConfig;
|
return parsedConfig as HelmRepoConfig;
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch {
|
||||||
|
// ignore error
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
repositories: [],
|
repositories: [],
|
||||||
|
|||||||
@ -97,7 +97,9 @@ export function initIpcMainHandlers(electronMenuItems: IComputedValue<MenuRegist
|
|||||||
const localStorageFilePath = path.resolve(AppPaths.get("userData"), "lens-local-storage", `${cluster.id}.json`);
|
const localStorageFilePath = path.resolve(AppPaths.get("userData"), "lens-local-storage", `${cluster.id}.json`);
|
||||||
|
|
||||||
await remove(localStorageFilePath);
|
await remove(localStorageFilePath);
|
||||||
} catch {}
|
} catch {
|
||||||
|
// ignore error
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMainHandle(clusterSetDeletingHandler, (event, clusterId: string) => {
|
ipcMainHandle(clusterSetDeletingHandler, (event, clusterId: string) => {
|
||||||
|
|||||||
@ -357,10 +357,10 @@ export class Kubectl {
|
|||||||
bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n`;
|
bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n`;
|
||||||
bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n";
|
bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n";
|
||||||
|
|
||||||
bashScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`;
|
bashScript += `NO_PROXY=",\${NO_PROXY:-localhost},"\n`;
|
||||||
bashScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`;
|
bashScript += `NO_PROXY="\${NO_PROXY//,localhost,/,}"\n`;
|
||||||
bashScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`;
|
bashScript += `NO_PROXY="\${NO_PROXY//,127.0.0.1,/,}"\n`;
|
||||||
bashScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`;
|
bashScript += `NO_PROXY="localhost,127.0.0.1\${NO_PROXY%,}"\n`;
|
||||||
bashScript += "export NO_PROXY\n";
|
bashScript += "export NO_PROXY\n";
|
||||||
bashScript += "unset tempkubeconfig\n";
|
bashScript += "unset tempkubeconfig\n";
|
||||||
await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 });
|
await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 });
|
||||||
@ -378,18 +378,18 @@ export class Kubectl {
|
|||||||
zshScript += "test -f \"$OLD_ZDOTDIR/.zshrc\" && . \"$OLD_ZDOTDIR/.zshrc\"\n";
|
zshScript += "test -f \"$OLD_ZDOTDIR/.zshrc\" && . \"$OLD_ZDOTDIR/.zshrc\"\n";
|
||||||
|
|
||||||
// voodoo to replace any previous occurrences of kubectl path in the PATH
|
// voodoo to replace any previous occurrences of kubectl path in the PATH
|
||||||
zshScript += `kubectlpath=\"${kubectlPath}"\n`;
|
zshScript += `kubectlpath="${kubectlPath}"\n`;
|
||||||
zshScript += `helmpath=\"${helmPath}"\n`;
|
zshScript += `helmpath="${helmPath}"\n`;
|
||||||
zshScript += "p=\":$kubectlpath:\"\n";
|
zshScript += "p=\":$kubectlpath:\"\n";
|
||||||
zshScript += "d=\":$PATH:\"\n";
|
zshScript += "d=\":$PATH:\"\n";
|
||||||
zshScript += `d=\${d//$p/:}\n`;
|
zshScript += `d=\${d//$p/:}\n`;
|
||||||
zshScript += `d=\${d/#:/}\n`;
|
zshScript += `d=\${d/#:/}\n`;
|
||||||
zshScript += `export PATH=\"$helmpath:$kubectlpath:\${d/%:/}\"\n`;
|
zshScript += `export PATH="$helmpath:$kubectlpath:\${d/%:/}"\n`;
|
||||||
zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n";
|
zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n";
|
||||||
zshScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`;
|
zshScript += `NO_PROXY=",\${NO_PROXY:-localhost},"\n`;
|
||||||
zshScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`;
|
zshScript += `NO_PROXY="\${NO_PROXY//,localhost,/,}"\n`;
|
||||||
zshScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`;
|
zshScript += `NO_PROXY="\${NO_PROXY//,127.0.0.1,/,}"\n`;
|
||||||
zshScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`;
|
zshScript += `NO_PROXY="localhost,127.0.0.1\${NO_PROXY%,}"\n`;
|
||||||
zshScript += "export NO_PROXY\n";
|
zshScript += "export NO_PROXY\n";
|
||||||
zshScript += "unset tempkubeconfig\n";
|
zshScript += "unset tempkubeconfig\n";
|
||||||
zshScript += "unset OLD_ZDOTDIR\n";
|
zshScript += "unset OLD_ZDOTDIR\n";
|
||||||
|
|||||||
@ -72,6 +72,7 @@ export class NodeShellSession extends ShellSession {
|
|||||||
switch (nodeOs) {
|
switch (nodeOs) {
|
||||||
default:
|
default:
|
||||||
logger.warn(`[NODE-SHELL-SESSION]: could not determine node OS, falling back with assumption of linux`);
|
logger.warn(`[NODE-SHELL-SESSION]: could not determine node OS, falling back with assumption of linux`);
|
||||||
|
// fallthrough
|
||||||
case "linux":
|
case "linux":
|
||||||
args.push("sh", "-c", "((clear && bash) || (clear && ash) || (clear && sh))");
|
args.push("sh", "-c", "((clear && bash) || (clear && ash) || (clear && sh))");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -134,7 +134,9 @@ export abstract class ShellSession {
|
|||||||
for (const shellProcess of this.processes.values()) {
|
for (const shellProcess of this.processes.values()) {
|
||||||
try {
|
try {
|
||||||
process.kill(shellProcess.pid);
|
process.kill(shellProcess.pid);
|
||||||
} catch {}
|
} catch {
|
||||||
|
// ignore error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.processes.clear();
|
this.processes.clear();
|
||||||
@ -214,7 +216,9 @@ export abstract class ShellSession {
|
|||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
return potentialCwd;
|
return potentialCwd;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
// ignore error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "."; // Always valid
|
return "."; // Always valid
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default {
|
|||||||
const contextName = value[0];
|
const contextName = value[0];
|
||||||
|
|
||||||
// Looping all the keys gives out the store internal stuff too...
|
// Looping all the keys gives out the store internal stuff too...
|
||||||
if (contextName === "__internal__" || value[1].hasOwnProperty("kubeConfig")) continue;
|
if (contextName === "__internal__" || Object.prototype.hasOwnProperty.call(value[1], "kubeConfig")) continue;
|
||||||
store.set(contextName, { kubeConfig: value[1] });
|
store.set(contextName, { kubeConfig: value[1] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export default {
|
|||||||
if (!cluster.kubeConfig) continue;
|
if (!cluster.kubeConfig) continue;
|
||||||
const config = yaml.load(cluster.kubeConfig);
|
const config = yaml.load(cluster.kubeConfig);
|
||||||
|
|
||||||
if (!config || typeof config !== "object" || !config.hasOwnProperty("users")) {
|
if (!config || typeof config !== "object" || !Object.prototype.hasOwnProperty.call(config, "users")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,15 +45,17 @@ export class HpaDetails extends React.Component<HpaDetailsProps> {
|
|||||||
|
|
||||||
const renderName = (metric: IHpaMetric) => {
|
const renderName = (metric: IHpaMetric) => {
|
||||||
switch (metric.type) {
|
switch (metric.type) {
|
||||||
case HpaMetricType.Resource:
|
case HpaMetricType.Resource: {
|
||||||
const addition = metric.resource.targetAverageUtilization ? <>(as a percentage of request)</> : "";
|
const addition = metric.resource.targetAverageUtilization
|
||||||
|
? "(as a percentage of request)"
|
||||||
|
: "";
|
||||||
|
|
||||||
return <>Resource {metric.resource.name} on Pods {addition}</>;
|
return <>Resource {metric.resource.name} on Pods {addition}</>;
|
||||||
|
}
|
||||||
case HpaMetricType.Pods:
|
case HpaMetricType.Pods:
|
||||||
return <>{metric.pods.metricName} on Pods</>;
|
return <>{metric.pods.metricName} on Pods</>;
|
||||||
|
|
||||||
case HpaMetricType.Object:
|
case HpaMetricType.Object: {
|
||||||
const { target } = metric.object;
|
const { target } = metric.object;
|
||||||
const { kind, name } = target;
|
const { kind, name } = target;
|
||||||
const objectUrl = getDetailsUrl(apiManager.lookupApiLink(target, hpa));
|
const objectUrl = getDetailsUrl(apiManager.lookupApiLink(target, hpa));
|
||||||
@ -64,6 +66,7 @@ export class HpaDetails extends React.Component<HpaDetailsProps> {
|
|||||||
<Link to={objectUrl}>{kind}/{name}</Link>
|
<Link to={objectUrl}>{kind}/{name}</Link>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
case HpaMetricType.External:
|
case HpaMetricType.External:
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -47,8 +47,8 @@ export const getBaseRegistryUrl = ({ getRegistryUrlPreference }: Dependencies) =
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
Notifications.error(<p>Failed to get configured registry from <code>.npmrc</code>. Falling back to default registry</p>);
|
Notifications.error(<p>Failed to get configured registry from <code>.npmrc</code>. Falling back to default registry</p>);
|
||||||
console.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error);
|
console.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error);
|
||||||
// fallthrough
|
|
||||||
}
|
}
|
||||||
|
// fallthrough
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
case ExtensionRegistryLocation.DEFAULT:
|
case ExtensionRegistryLocation.DEFAULT:
|
||||||
|
|||||||
@ -133,7 +133,8 @@ export class FilePicker extends React.Component<Props> {
|
|||||||
switch (onOverSizeLimit) {
|
switch (onOverSizeLimit) {
|
||||||
case OverSizeLimitStyle.FILTER:
|
case OverSizeLimitStyle.FILTER:
|
||||||
return files.filter(file => file.size <= maxSize );
|
return files.filter(file => file.size <= maxSize );
|
||||||
case OverSizeLimitStyle.REJECT:
|
|
||||||
|
case OverSizeLimitStyle.REJECT: {
|
||||||
const firstFileToLarge = files.find(file => file.size > maxSize);
|
const firstFileToLarge = files.find(file => file.size > maxSize);
|
||||||
|
|
||||||
if (firstFileToLarge) {
|
if (firstFileToLarge) {
|
||||||
@ -141,6 +142,7 @@ export class FilePicker extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +158,9 @@ export class FilePicker extends React.Component<Props> {
|
|||||||
switch (onOverTotalSizeLimit) {
|
switch (onOverTotalSizeLimit) {
|
||||||
case OverTotalSizeLimitStyle.FILTER_LARGEST:
|
case OverTotalSizeLimitStyle.FILTER_LARGEST:
|
||||||
files = _.orderBy(files, ["size"]);
|
files = _.orderBy(files, ["size"]);
|
||||||
case OverTotalSizeLimitStyle.FILTER_LAST:
|
|
||||||
|
// fallthrough
|
||||||
|
case OverTotalSizeLimitStyle.FILTER_LAST: {
|
||||||
let newTotalSize = totalSize;
|
let newTotalSize = totalSize;
|
||||||
|
|
||||||
for (;files.length > 0;) {
|
for (;files.length > 0;) {
|
||||||
@ -168,6 +172,7 @@ export class FilePicker extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
}
|
||||||
case OverTotalSizeLimitStyle.REJECT:
|
case OverTotalSizeLimitStyle.REJECT:
|
||||||
throw `Total file size to upload is too large. Expected at most ${maxTotalSize}. Found ${totalSize}.`;
|
throw `Total file size to upload is too large. Expected at most ${maxTotalSize}. Found ${totalSize}.`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,6 +73,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
|||||||
switch (evt.nativeEvent.code) {
|
switch (evt.nativeEvent.code) {
|
||||||
case "Space":
|
case "Space":
|
||||||
|
|
||||||
|
// fallthrough
|
||||||
case "Enter": {
|
case "Enter": {
|
||||||
// eslint-disable-next-line react/no-find-dom-node
|
// eslint-disable-next-line react/no-find-dom-node
|
||||||
const icon = findDOMNode(this) as HTMLElement;
|
const icon = findDOMNode(this) as HTMLElement;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export const isRequired: InputValidator = {
|
|||||||
export const isEmail: InputValidator = {
|
export const isEmail: InputValidator = {
|
||||||
condition: ({ type }) => type === "email",
|
condition: ({ type }) => type === "email",
|
||||||
message: () => `Wrong email format`,
|
message: () => `Wrong email format`,
|
||||||
validate: value => !!value.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),
|
validate: value => !!value.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isNumber: InputValidator = {
|
export const isNumber: InputValidator = {
|
||||||
|
|||||||
@ -243,7 +243,9 @@ export class Menu extends React.Component<MenuProps, State> {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "Space":
|
case "Space":
|
||||||
case "Enter":
|
// fallthrough
|
||||||
|
|
||||||
|
case "Enter": {
|
||||||
const focusedItem = this.focusedItem;
|
const focusedItem = this.focusedItem;
|
||||||
|
|
||||||
if (focusedItem) {
|
if (focusedItem) {
|
||||||
@ -251,10 +253,12 @@ export class Menu extends React.Component<MenuProps, State> {
|
|||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "ArrowUp":
|
case "ArrowUp":
|
||||||
this.focusNextItem(true);
|
this.focusNextItem(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
this.focusNextItem();
|
this.focusNextItem();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -50,7 +50,9 @@ export function createStorage<T>(key: string, defaultValue: T) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
storage.data = await fse.readJson(filePath);
|
storage.data = await fse.readJson(filePath);
|
||||||
} catch {} finally {
|
} catch {
|
||||||
|
// ignore error
|
||||||
|
} finally {
|
||||||
if (!isTestEnv) {
|
if (!isTestEnv) {
|
||||||
logger.info(`${logPrefix} loading finished for ${filePath}`);
|
logger.info(`${logPrefix} loading finished for ${filePath}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user