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

Fix linting warnings for Function, Boolean and String types #1916

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -112,9 +112,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
error={error.opsLatencies}
/>
<div className="table-graph-avg">
{typeof value === 'number' && row.dataPoints.service_operation_latencies.length > 0
? formatTimeValue(value * 1000)
: ''}
{row.dataPoints.service_operation_latencies.length > 0 ? formatTimeValue(value * 1000) : ''}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replacement is not completely equivalent. What would be a situation when value would not be a number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

In this case, the value of 'value' is 'ServiceOpsMetrics['latency']', and 'latency' is defined as a number type.

export type ServiceOpsMetrics = {
dataPoints: OpsDataPoints;
errRates: number;
impact: number;
latency: number;
name: string;
requests: number;
key: number;
};

Therefore, I thought that there is no need for additional type checking because 'value' is always of type number. Am I mistaken?

</div>
</div>
),
Expand All @@ -133,9 +131,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
error={error.opsCalls}
/>
<div className="table-graph-avg">
{typeof value === 'number' && row.dataPoints.service_operation_call_rate.length > 0
? `${formatValue(value)} req/s`
: ''}
{row.dataPoints.service_operation_call_rate.length > 0 ? `${formatValue(value)} req/s` : ''}
</div>
</div>
),
Expand All @@ -155,9 +151,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
error={error.opsErrors}
/>
<div className="table-graph-avg">
{typeof value === 'number' && row.dataPoints.service_operation_error_rate.length > 0
? `${formatValue(value * 100)}%`
: ''}
{row.dataPoints.service_operation_error_rate.length > 0 ? `${formatValue(value * 100)}%` : ''}
</div>
</div>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ export function findServerChildSpan(spans: Span[]) {
return null;
}

export const isKindClient = (span: Span): Boolean =>
export const isKindClient = (span: Span): boolean =>
span.tags.some(({ key, value }) => key === 'span.kind' && value === 'client');

export const isKindProducer = (span: Span): Boolean =>
export const isKindProducer = (span: Span): boolean =>
span.tags.some(({ key, value }) => key === 'span.kind' && value === 'producer');

export { formatDuration } from '../../../utils/date';
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function transformTracesToPaths(
focalService: string,
focalOperation?: string
): TDdgPayload {
const dependenciesMap = new Map<String, TDdgPayloadPath>();
const dependenciesMap = new Map<string, TDdgPayloadPath>();
Object.values(traces).forEach(({ data }) => {
if (data) {
const spanMap: Map<string, Span> = new Map();
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/types/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type MonitorEmptyStateConfig = {
description?: string;
button?: {
text?: string;
onClick?: Function;
onClick?: () => void;
};
info?: string;
alert?: {
Expand Down
4 changes: 2 additions & 2 deletions packages/jaeger-ui/src/utils/TreeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class TreeNode<TValue> {
return this;
}

find(search: Function): TreeNode<TValue> | null {
find(search: (node: TreeNode<TValue>) => boolean): TreeNode<TValue> | null {
const searchFn = TreeNode.iterFunction(TreeNode.searchFunction(search));
if (searchFn(this)) {
return this;
Expand All @@ -63,7 +63,7 @@ export default class TreeNode<TValue> {
return null;
}

getPath(search: Function) {
getPath(search: (node: TreeNode<TValue>) => boolean) {
const searchFn = TreeNode.iterFunction(TreeNode.searchFunction(search));

const findPath = (
Expand Down
Loading