1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Bump typescript, @typescript-eslint/eslint-plugin, and @typescript-eslint/parser (#6143)

This commit is contained in:
Sebastian Malton 2022-09-01 07:05:32 -07:00 committed by GitHub
parent 27871f57b6
commit b0d72b78d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 105 additions and 118 deletions

View File

@ -362,8 +362,8 @@
"@types/webpack-dev-server": "^4.7.2",
"@types/webpack-env": "^1.18.0",
"@types/webpack-node-externals": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"adr": "^1.4.1",
"ansi_up": "^5.1.0",
"chart.js": "^2.9.4",
@ -428,7 +428,7 @@
"typed-emitter": "^1.4.0",
"typedoc": "0.23.11",
"typedoc-plugin-markdown": "^3.13.1",
"typescript": "^4.7.4",
"typescript": "^4.8.2",
"typescript-plugin-css-modules": "^3.4.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.9.2",

View File

@ -31,7 +31,7 @@ export interface BaseStoreParams<T> extends ConfOptions<T> {
/**
* Note: T should only contain base JSON serializable types.
*/
export abstract class BaseStore<T> extends Singleton {
export abstract class BaseStore<T extends object> extends Singleton {
protected storeConfig?: Config<T>;
protected syncDisposers: Disposer[] = [];

View File

@ -8,7 +8,7 @@ import type { BaseStoreParams } from "../base-store";
const getConfigurationFileModelInjectable = getInjectable({
id: "get-configuration-file-model",
instantiate: () => <ConfigurationContent>(content: BaseStoreParams<ConfigurationContent>) => new Config(content),
instantiate: () => <T extends object>(content: BaseStoreParams<T>) => new Config(content),
causesSideEffects: true,
});

View File

@ -7,7 +7,6 @@
import moment from "moment";
import { apiBase } from "../index";
import type { IMetricsQuery } from "../../../main/routes/metrics/metrics-query";
export interface MetricData {
status: string;
@ -55,8 +54,11 @@ export interface IResourceMetrics<T extends MetricData> {
networkTransmit: T;
}
export const metricsApi = {
async getMetrics<T = IMetricsQuery>(query: T, reqParams: IMetricsReqParams = {}): Promise<T extends object ? { [K in keyof T]: MetricData } : MetricData> {
async function getMetrics(query: string, reqParams?: IMetricsReqParams): Promise<MetricData>;
async function getMetrics(query: string[], reqParams?: IMetricsReqParams): Promise<MetricData[]>;
async function getMetrics<MetricNames extends string>(query: Record<MetricNames, Partial<Record<string, string>>>, reqParams?: IMetricsReqParams): Promise<Record<MetricNames, MetricData>>;
async function getMetrics(query: string | string[] | Partial<Record<string, Partial<Record<string, string>>>>, reqParams: IMetricsReqParams = {}): Promise<MetricData | MetricData[] | Partial<Record<string, MetricData>>> {
const { range = 3600, step = 60, namespace } = reqParams;
let { start, end } = reqParams;
@ -75,8 +77,10 @@ export const metricsApi = {
"kubernetes_namespace": namespace,
},
});
},
}
export const metricsApi = {
getMetrics,
async getMetricProviders(): Promise<MetricProviderInfo[]> {
return apiBase.get("/metrics/providers");
},

View File

@ -113,7 +113,17 @@ export abstract class LensProtocolRouter {
}
// if no exact match pick the one that is the most specific
return matches.sort(([a], [b]) => compareMatches(a, b))[0] ?? null;
return matches.sort(([a], [b]) => {
if (a.path === "/") {
return 1;
}
if (b.path === "/") {
return -1;
}
return countBy(b.path)["/"] - countBy(a.path)["/"];
})[0] ?? null;
}
/**
@ -265,21 +275,3 @@ export abstract class LensProtocolRouter {
this.internalRoutes.delete(urlSchema);
}
}
/**
* a comparison function for `array.sort(...)`. Sort order should be most path
* parts to least path parts.
* @param a the left side to compare
* @param b the right side to compare
*/
function compareMatches<T>(a: match<T>, b: match<T>): number {
if (a.path === "/") {
return 1;
}
if (b.path === "/") {
return -1;
}
return countBy(b.path)["/"] - countBy(a.path)["/"];
}

View File

@ -4,6 +4,7 @@
*/
import { Readable } from "readable-stream";
import type { ReadableStreamDefaultReadResult } from "stream/web";
import type { TypedArray } from "type-fest";
/**

View File

@ -27,7 +27,7 @@ export class Singleton {
* @param args The constructor arguments for the child class
* @returns An instance of the child class
*/
static createInstance<T, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
static createInstance<T extends Singleton, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
if (!Singleton.instances.has(this)) {
if (Singleton.creating.length > 0) {
throw new TypeError(`Cannot create a second singleton (${this.name}) while creating a first (${Singleton.creating})`);

View File

@ -9,7 +9,7 @@ import type { Injectable } from "@ogre-tools/injectable";
* @deprecated use asLegacyGlobalForExtensionApi instead, and use proper implementations instead of "modifications".
*/
export const asLegacyGlobalObjectForExtensionApiWithModifications = <
InjectableInstance extends InjectionTokenInstance,
InjectableInstance extends InjectionTokenInstance & object,
InjectionTokenInstance,
ModificationObject extends object,
>(

View File

@ -8,7 +8,7 @@ import * as path from "path";
import type { LensExtension } from "./lens-extension";
import assert from "assert";
export abstract class ExtensionStore<T> extends BaseStore<T> {
export abstract class ExtensionStore<T extends object> extends BaseStore<T> {
readonly displayName = "ExtensionStore<T>";
protected extension?: LensExtension;

View File

@ -9,7 +9,6 @@ import type { ClusterPrometheusMetadata } from "../../../common/cluster-types";
import { ClusterMetadataKey } from "../../../common/cluster-types";
import logger from "../../logger";
import type { Cluster } from "../../../common/cluster/cluster";
import type { IMetricsQuery } from "./metrics-query";
import { clusterRoute } from "../../router/route";
import { isObject } from "lodash";
import { isRequestError } from "../../../common/utils";
@ -60,7 +59,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
const getMetrics = di.inject(getMetricsInjectable);
const loadMetrics = loadMetricsFor(getMetrics);
const queryParams: IMetricsQuery = Object.fromEntries(query.entries());
const queryParams = Object.fromEntries(query.entries());
const prometheusMetadata: ClusterPrometheusMetadata = {};
try {

View File

@ -1,7 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export type IMetricsQuery = string | string[] | {
[metricName: string]: string;
};

View File

@ -4,6 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { reaction, when } from "mobx";
import type { GeneralEntity } from "../../../common/catalog-entities";
import generalCategoryInjectable from "../../../common/catalog/categories/general.injectable";
import isActiveRouteInjectable from "../../navigation/is-route-active.injectable";
import observableHistoryInjectable from "../../navigation/observable-history.injectable";
@ -30,7 +31,7 @@ const watchForGeneralEntityNavigationInjectable = getInjectable({
dispose.push(reaction(
() => observableHistory.location,
() => {
const entities = entityRegistry.getItemsForCategory(generalCategory);
const entities = entityRegistry.getItemsForCategory(generalCategory) as GeneralEntity[];
const activeEntity = entities.find(entity => isActiveRoute(entity.spec.path));
if (activeEntity) {

View File

@ -5,7 +5,6 @@
import { asLegacyGlobalFunctionForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-function-for-extension-api";
import { asLegacyGlobalForExtensionApi } from "../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
import matchRouteInjectable from "./match-route.injectable";
import navigateInjectable from "./navigate.injectable";
import observableHistoryInjectable from "./observable-history.injectable";
@ -21,9 +20,4 @@ export const navigation = asLegacyGlobalForExtensionApi(observableHistoryInjecta
*/
export const navigate = asLegacyGlobalFunctionForExtensionApi(navigateInjectable);
/**
* @deprecated use `di.inject(matchRouteInjectable)` instead
*/
export const matchRoute = asLegacyGlobalFunctionForExtensionApi(matchRouteInjectable);
export * from "./page-param";

View File

@ -7,7 +7,7 @@ import type { match, RouteProps } from "react-router";
import { matchPath } from "react-router";
import observableHistoryInjectable from "./observable-history.injectable";
export type MatchRoute = <Params>(route: string | string[] | RouteProps) => match<Params> | null;
export type MatchRoute = <Params extends { [K in keyof Params]?: string }>(route: string | string[] | RouteProps) => match<Params> | null;
const matchRouteInjectable = getInjectable({
id: "match-route",

View File

@ -9,6 +9,7 @@ import type { Draft } from "immer";
import { produce, isDraft } from "immer";
import { isEqual, isPlainObject } from "lodash";
import logger from "../../main/logger";
import assert from "assert";
export interface StorageChange<T> {
key: string;
@ -154,8 +155,9 @@ export class StorageHelper<T> implements StorageLayer<T> {
}
@action
merge(value: Partial<T> | ((draft: Draft<T>) => Partial<T> | void)) {
merge(value: T extends object ? Partial<T> | ((draft: Draft<T>) => Partial<T> | void) : never) {
const nextValue = produce<T>(toJS(this.get()), (draft) => {
assert(typeof draft === "object" && draft);
if (typeof value == "function") {
const newValue = value(draft);

103
yarn.lock
View File

@ -2571,14 +2571,14 @@
dependencies:
"@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@^5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.35.1.tgz#0d822bfea7469904dfc1bb8f13cabd362b967c93"
integrity sha512-RBZZXZlI4XCY4Wzgy64vB+0slT9+yAPQRjj/HSaRwUot33xbDjF1oN9BLwOLTewoOI0jothIltZRe9uJCHf8gg==
"@typescript-eslint/eslint-plugin@^5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.1.tgz#471f64dc53600025e470dad2ca4a9f2864139019"
integrity sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==
dependencies:
"@typescript-eslint/scope-manager" "5.35.1"
"@typescript-eslint/type-utils" "5.35.1"
"@typescript-eslint/utils" "5.35.1"
"@typescript-eslint/scope-manager" "5.36.1"
"@typescript-eslint/type-utils" "5.36.1"
"@typescript-eslint/utils" "5.36.1"
debug "^4.3.4"
functional-red-black-tree "^1.0.1"
ignore "^5.2.0"
@ -2586,69 +2586,70 @@
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/parser@^5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.35.1.tgz#bf2ee2ebeaa0a0567213748243fb4eec2857f04f"
integrity sha512-XL2TBTSrh3yWAsMYpKseBYTVpvudNf69rPOWXWVBI08My2JVT5jR66eTt4IgQFHA/giiKJW5dUD4x/ZviCKyGg==
"@typescript-eslint/parser@^5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.36.1.tgz#931c22c7bacefd17e29734628cdec8b2acdcf1ce"
integrity sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==
dependencies:
"@typescript-eslint/scope-manager" "5.35.1"
"@typescript-eslint/types" "5.35.1"
"@typescript-eslint/typescript-estree" "5.35.1"
"@typescript-eslint/scope-manager" "5.36.1"
"@typescript-eslint/types" "5.36.1"
"@typescript-eslint/typescript-estree" "5.36.1"
debug "^4.3.4"
"@typescript-eslint/scope-manager@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.35.1.tgz#ccb69d54b7fd0f2d0226a11a75a8f311f525ff9e"
integrity sha512-kCYRSAzIW9ByEIzmzGHE50NGAvAP3wFTaZevgWva7GpquDyFPFcmvVkFJGWJJktg/hLwmys/FZwqM9EKr2u24Q==
"@typescript-eslint/scope-manager@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.36.1.tgz#23c49b7ddbcffbe09082e6694c2524950766513f"
integrity sha512-pGC2SH3/tXdu9IH3ItoqciD3f3RRGCh7hb9zPdN2Drsr341zgd6VbhP5OHQO/reUqihNltfPpMpTNihFMarP2w==
dependencies:
"@typescript-eslint/types" "5.35.1"
"@typescript-eslint/visitor-keys" "5.35.1"
"@typescript-eslint/types" "5.36.1"
"@typescript-eslint/visitor-keys" "5.36.1"
"@typescript-eslint/type-utils@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.35.1.tgz#d50903b56758c5c8fc3be52b3be40569f27f9c4a"
integrity sha512-8xT8ljvo43Mp7BiTn1vxLXkjpw8wS4oAc00hMSB4L1/jIiYbjjnc3Qp2GAUOG/v8zsNCd1qwcqfCQ0BuishHkw==
"@typescript-eslint/type-utils@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.36.1.tgz#016fc2bff6679f54c0b2df848a493f0ca3d4f625"
integrity sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==
dependencies:
"@typescript-eslint/utils" "5.35.1"
"@typescript-eslint/typescript-estree" "5.36.1"
"@typescript-eslint/utils" "5.36.1"
debug "^4.3.4"
tsutils "^3.21.0"
"@typescript-eslint/types@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.35.1.tgz#af355fe52a0cc88301e889bc4ada72f279b63d61"
integrity sha512-FDaujtsH07VHzG0gQ6NDkVVhi1+rhq0qEvzHdJAQjysN+LHDCKDKCBRlZFFE0ec0jKxiv0hN63SNfExy0KrbQQ==
"@typescript-eslint/types@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.36.1.tgz#1cf0e28aed1cb3ee676917966eb23c2f8334ce2c"
integrity sha512-jd93ShpsIk1KgBTx9E+hCSEuLCUFwi9V/urhjOWnOaksGZFbTOxAT47OH2d4NLJnLhkVD+wDbB48BuaycZPLBg==
"@typescript-eslint/typescript-estree@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.35.1.tgz#db878a39a0dbdc9bb133f11cdad451770bfba211"
integrity sha512-JUqE1+VRTGyoXlDWWjm6MdfpBYVq+hixytrv1oyjYIBEOZhBCwtpp5ZSvBt4wIA1MKWlnaC2UXl2XmYGC3BoQA==
"@typescript-eslint/typescript-estree@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.1.tgz#b857f38d6200f7f3f4c65cd0a5afd5ae723f2adb"
integrity sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==
dependencies:
"@typescript-eslint/types" "5.35.1"
"@typescript-eslint/visitor-keys" "5.35.1"
"@typescript-eslint/types" "5.36.1"
"@typescript-eslint/visitor-keys" "5.36.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/utils@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.35.1.tgz#ae1399afbfd6aa7d0ed1b7d941e9758d950250eb"
integrity sha512-v6F8JNXgeBWI4pzZn36hT2HXXzoBBBJuOYvoQiaQaEEjdi5STzux3Yj8v7ODIpx36i/5s8TdzuQ54TPc5AITQQ==
"@typescript-eslint/utils@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.36.1.tgz#136d5208cc7a3314b11c646957f8f0b5c01e07ad"
integrity sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==
dependencies:
"@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.35.1"
"@typescript-eslint/types" "5.35.1"
"@typescript-eslint/typescript-estree" "5.35.1"
"@typescript-eslint/scope-manager" "5.36.1"
"@typescript-eslint/types" "5.36.1"
"@typescript-eslint/typescript-estree" "5.36.1"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
"@typescript-eslint/visitor-keys@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.35.1.tgz#285e9e34aed7c876f16ff646a3984010035898e6"
integrity sha512-cEB1DvBVo1bxbW/S5axbGPE6b7FIMAbo3w+AGq6zNDA7+NYJOIkKj/sInfTv4edxd4PxJSgdN4t6/pbvgA+n5g==
"@typescript-eslint/visitor-keys@5.36.1":
version "5.36.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.1.tgz#7731175312d65738e501780f923896d200ad1615"
integrity sha512-ojB9aRyRFzVMN3b5joSYni6FAS10BBSCAfKJhjJAV08t/a95aM6tAhz+O1jF+EtgxktuSO3wJysp2R+Def/IWQ==
dependencies:
"@typescript-eslint/types" "5.35.1"
"@typescript-eslint/types" "5.36.1"
eslint-visitor-keys "^3.3.0"
"@webassemblyjs/ast@1.11.1":
@ -13498,10 +13499,10 @@ typescript-plugin-css-modules@^3.4.0:
stylus "^0.54.8"
tsconfig-paths "^3.9.0"
typescript@^4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
typescript@^4.8.2:
version "4.8.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.2.tgz#e3b33d5ccfb5914e4eeab6699cf208adee3fd790"
integrity sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==
typical@^4.0.0:
version "4.0.0"