mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Improve linting within @k8slens/core
- Turning on @typescript-eslint/recommended-requiring-type-checking - Turning off @typescript-eslint/no-unnecessary-type-assertion (due too many false positives) - Making @typescript-eslint/no-explicit-any an error (except in tests) Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
6184c2f03b
commit
fa44b795d4
734 files changed
+32216
-4566
No files matched your search
@@ -14,9 +14,9 @@ import type { Logger } from "@k8slens/logger";
|
||||
import type Fetch from "@k8slens/node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
import type { Defaulted } from "@k8slens/utilities";
|
||||
import { isObject, isString, json } from "@k8slens/utilities";
|
||||
import { isArray, isObject, isString, json } from "@k8slens/utilities";
|
||||
|
||||
export interface JsonApiData {}
|
||||
export type JsonApiData = Record<string, never>;
|
||||
|
||||
export interface JsonApiError {
|
||||
code?: number;
|
||||
@@ -56,11 +56,11 @@ export interface JsonApiLog {
|
||||
method: string;
|
||||
reqUrl: string;
|
||||
reqInit: RequestInit;
|
||||
data?: any;
|
||||
error?: any;
|
||||
data?: unknown;
|
||||
error?: unknown;
|
||||
}
|
||||
|
||||
export type GetRequestOptions = () => Promise<RequestInit>;
|
||||
export type GetRequestOptions = () => RequestInit | Promise<RequestInit>;
|
||||
|
||||
export interface JsonApiConfig {
|
||||
apiBase: string;
|
||||
@@ -236,7 +236,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
|
||||
|
||||
const text = await res.text();
|
||||
const parseResponse = json.parse(text || "{}");
|
||||
const data = parseResponse.callWasSuccessful ? (parseResponse.response as Data) : (text as Data);
|
||||
const data = parseResponse.isOk ? (parseResponse.value as Data) : (text as Data);
|
||||
|
||||
if (status >= 200 && status < 300) {
|
||||
this.onData.emit(data, res);
|
||||
@@ -271,7 +271,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
|
||||
|
||||
const { errors, message } = error as { errors?: { title: string }[]; message?: string };
|
||||
|
||||
if (Array.isArray(errors)) {
|
||||
if (isArray(errors)) {
|
||||
return errors.map((error) => error.title);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user