Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priyanshu kun/clean any #1814

Merged
merged 7 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import * as React from 'react';
import { History as RouterHistory } from 'history';
import queryString from 'query-string';
import { connect } from 'react-redux';
import { match } from 'react-router-dom';
import { bindActionCreators, Dispatch } from 'redux';
Expand Down
7 changes: 4 additions & 3 deletions packages/jaeger-ui/src/components/common/RelativeDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React from 'react';
import dayjs from 'dayjs';

import { formatRelativeDate } from '../../utils/date';

type Props = {
fullMonthName: boolean | undefined | null;
includeTime: boolean | undefined | null;
value: number | Date | any;
value: number | Date;
};

// TODO typescript doesn't understand text or null as react nodes
// https://github.com/Microsoft/TypeScript/issues/21699
export default function RelativeDate(props: Props): any {
export default function RelativeDate(props: Props): JSX.Element {
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
const { value, includeTime, fullMonthName } = props;
const m = dayjs.isDayjs(value) ? value : dayjs(value);
const dateStr = formatRelativeDate(m, Boolean(fullMonthName));
const timeStr = includeTime ? `, ${m.format('h:mm:ss a')}` : '';
return `${dateStr}${timeStr}`;
return <span>{`${dateStr}${timeStr}`}</span>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export default class DraggableManager {
tag: string | TNil;

// handlers for integration with DOM elements
handleMouseEnter: (event: React.MouseEvent<any>) => void;
handleMouseMove: (event: React.MouseEvent<any>) => void;
handleMouseLeave: (event: React.MouseEvent<any>) => void;
handleMouseDown: (event: React.MouseEvent<any>) => void;
handleMouseEnter: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseMove: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseLeave: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;

constructor({ getBounds, tag, resetBoundsOnResize = true, ...rest }: DraggableManagerOptions) {
this.handleMouseDown = this._handleDragEvent;
Expand Down Expand Up @@ -142,7 +142,7 @@ export default class DraggableManager {
this._bounds = undefined;
};

_handleMinorMouseEvent = (event: React.MouseEvent<any>) => {
_handleMinorMouseEvent = (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => {
const { button, clientX, type: eventType } = event;
if (this._isDragging || button !== LEFT_MOUSE_BUTTON) {
return;
Expand Down Expand Up @@ -175,7 +175,7 @@ export default class DraggableManager {
});
};

_handleDragEvent = (event: MouseEvent | React.MouseEvent<any>) => {
_handleDragEvent = (event: MouseEvent | React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => {
const { button, clientX, type: eventType } = event;
let type: EUpdateTypes | null = null;
let handler: ((update: DraggingUpdate) => void) | TNil;
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/DraggableManager/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type DraggableBounds = {
};

export type DraggingUpdate = {
event: React.MouseEvent<any> | MouseEvent;
event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent> | MouseEvent;
manager: DraggableManager;
tag: string | TNil;
type: EUpdateTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ interface IDeprecation {
* - The value at the deprecated config property is moved to the new property
* - The value at the deprecated config property is ignored in favor of the value at the new property
*/
export default function processDeprecation(
config: Record<string, any>,
deprecation: IDeprecation,
issueWarning: boolean
) {
export default function processDeprecation(config: object, deprecation: IDeprecation, issueWarning: boolean) {
const { formerKey, currentKey } = deprecation;
if (_has(config, formerKey)) {
let isTransfered = false;
Expand Down
14 changes: 9 additions & 5 deletions packages/jaeger-ui/src/utils/readJsonFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export default function readJsonFile(fileList: { file: File }) {
}
try {
resolve(JSON.parse(reader.result));
} catch (error: any) {
reject(new Error(`Error parsing JSON: ${error.message}`));
} catch (error: unknown) {
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
if (error instanceof Error) {
reject(new Error(`Error parsing JSON: ${error.message}`));
}
priyanshu-kun marked this conversation as resolved.
Show resolved Hide resolved
}
};
reader.onerror = () => {
Expand All @@ -37,9 +39,11 @@ export default function readJsonFile(fileList: { file: File }) {
};
try {
reader.readAsText(fileList.file);
} catch (error: any) {
// eslint-disable-next-line no-console
reject(new Error(`Error reading the JSON file: ${error.message}`));
} catch (error: unknown) {
if (error instanceof Error) {
// eslint-disable-next-line no-console
reject(new Error(`Error reading the JSON file: ${error.message}`));
}
}
});
}
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/tracking/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
export const OPEN = 'open';
export const CLOSE = 'close';

export function getToggleValue(value: any) {
export function getToggleValue(value: boolean) {
return value ? CLOSE : OPEN;
}
4 changes: 3 additions & 1 deletion packages/jaeger-ui/src/utils/tracking/getTrackFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import _throttle from 'lodash/throttle';

import { trackEvent } from '.';

import { TNil } from '../../types';

// export for tests
export const ACTION_FILTER_SET = 'set';
export const ACTION_FILTER_CLEAR = 'clear';
Expand All @@ -33,5 +35,5 @@ const getTrackFilterClear = (category: string) =>
export default function getTrackFilter(category: string) {
const trackFilterSet = getTrackFilterSet(category);
const trackFilterClear = getTrackFilterClear(category);
return (value: any) => (value ? trackFilterSet() : trackFilterClear());
return (value: string | TNil) => (value ? trackFilterSet() : trackFilterClear());
}
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/ts/pluckTruthy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// Because TypeScript doesn't believe in Array#filter(Boolean)
export default function pluckTruthy<T>(values: (T | any)[]): T[] {
export default function pluckTruthy<T>(values: (T | undefined)[]): T[] {
priyanshu-kun marked this conversation as resolved.
Show resolved Hide resolved
const rv: T[] = [];
for (let i = 0; i < values.length; i++) {
const value = values[i];
Expand Down