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

Add an ESLint rule requiring the names of interfaces to be prefixed with "I" #411

Merged
merged 1 commit into from
Jul 10, 2019
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
plugins: ['@typescript-eslint'],
rules: {
'no-unused-vars': 0,
'@typescript-eslint/interface-name-prefix': ['error', 'always'],
'@typescript-eslint/no-unused-vars': 1,
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/jaeger-ui/src/components/TracePage/ScrollManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type Accessors = {
mapSpanIndexToRowIndex: (spanIndex: number) => number;
};

interface Scroller {
interface IScroller {
scrollTo: (rowIndex: number) => void;
// TODO arg names throughout
scrollBy: (rowIndex: number, opt?: boolean) => void;
Expand All @@ -55,7 +55,7 @@ interface Scroller {
* @returns {{ isHidden: boolean, parentIds: Set<string> }}
*/
function isSpanHidden(span: Span, childrenAreHidden: Set<string>, spansMap: Map<string, Span | TNil>) {
const parentIDs = new Set();
const parentIDs = new Set<string>();
let { references }: { references: SpanReference[] | TNil } = span;
let parentID: undefined | string;
const checkRef = (ref: SpanReference) => {
Expand Down Expand Up @@ -87,10 +87,10 @@ function isSpanHidden(span: Span, childrenAreHidden: Set<string>, spansMap: Map<
*/
export default class ScrollManager {
_trace: Trace | TNil;
_scroller: Scroller;
_scroller: IScroller;
_accessors: Accessors | TNil;

constructor(trace: Trace | TNil, scroller: Scroller) {
constructor(trace: Trace | TNil, scroller: IScroller) {
this._trace = trace;
this._scroller = scroller;
this._accessors = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as React from 'react';

import GraphTicks from './GraphTicks';
import Scrubber from './Scrubber';
import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate } from '../../types';
import { TUpdateViewRangeTimeFunction, IViewRange, ViewRangeTimeUpdate } from '../../types';
import { TNil } from '../../../../types';
import DraggableManager, {
DraggableBounds,
Expand All @@ -33,7 +33,7 @@ type ViewingLayerProps = {
numTicks: number;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
viewRange: ViewRange;
viewRange: IViewRange;
};

type ViewingLayerState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as React from 'react';
import CanvasSpanGraph from './CanvasSpanGraph';
import TickLabels from './TickLabels';
import ViewingLayer from './ViewingLayer';
import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate } from '../../types';
import { TUpdateViewRangeTimeFunction, IViewRange, ViewRangeTimeUpdate } from '../../types';
import { Span, Trace } from '../../../../types/trace';

const DEFAULT_HEIGHT = 60;
Expand All @@ -26,7 +26,7 @@ const TIMELINE_TICK_INTERVAL = 4;
type SpanGraphProps = {
height?: number;
trace: Trace;
viewRange: ViewRange;
viewRange: IViewRange;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
updateNextViewRangeTime: (nextUpdate: ViewRangeTimeUpdate) => void;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import AltViewOptions from './AltViewOptions';
import KeyboardShortcutsHelp from './KeyboardShortcutsHelp';
import SpanGraph from './SpanGraph';
import TracePageSearchBar from './TracePageSearchBar';
import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate } from '../types';
import { TUpdateViewRangeTimeFunction, IViewRange, ViewRangeTimeUpdate } from '../types';
import LabeledList from '../../common/LabeledList';
import NewWindowIcon from '../../common/NewWindowIcon';
import TraceName from '../../common/TraceName';
Expand Down Expand Up @@ -61,7 +61,7 @@ type TracePageHeaderEmbedProps = {
traceGraphView: boolean;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
viewRange: ViewRange;
viewRange: IViewRange;
};

export const HEADER_ITEMS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import TimelineColumnResizer from './TimelineColumnResizer';
import TimelineViewingLayer from './TimelineViewingLayer';
import Ticks from '../Ticks';
import TimelineRow from '../TimelineRow';
import { TUpdateViewRangeTimeFunction, ViewRangeTime, ViewRangeTimeUpdate } from '../../types';
import { TUpdateViewRangeTimeFunction, IViewRangeTime, ViewRangeTimeUpdate } from '../../types';

import './TimelineHeaderRow.css';

Expand All @@ -34,7 +34,7 @@ type TimelineHeaderRowProps = {
onExpandOne: () => void;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
viewRangeTime: ViewRangeTime;
viewRangeTime: IViewRangeTime;
};

export default function TimelineHeaderRow(props: TimelineHeaderRowProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as React from 'react';
import cx from 'classnames';

import { TUpdateViewRangeTimeFunction, ViewRangeTime, ViewRangeTimeUpdate } from '../../types';
import { TUpdateViewRangeTimeFunction, IViewRangeTime, ViewRangeTimeUpdate } from '../../types';
import { TNil } from '../../../../types';
import DraggableManager, { DraggableBounds, DraggingUpdate } from '../../../../utils/DraggableManager';

Expand All @@ -30,7 +30,7 @@ type TimelineViewingLayerProps = {
boundsInvalidator: any | null | undefined;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
viewRangeTime: ViewRangeTime;
viewRangeTime: IViewRangeTime;
};

type TDraggingLeftLayout = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import * as React from 'react';

import './TimelineRow.css';

type TimelineRowProps = {
type TTimelineRowProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are leading Ts for types being enforced along with Is for interfaces or was this just because you caught it?
If not, we should find a rule for that as well.

children: React.ReactNode;
className?: string;
};

interface TimelineRowCellProps extends React.HTMLAttributes<HTMLDivElement> {
interface ITimelineRowCellProps extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode;
className?: string;
width: number;
style?: Object;
}

export default function TimelineRow(props: TimelineRowProps) {
export default function TimelineRow(props: TTimelineRowProps) {
const { children, className = '', ...rest } = props;
return (
<div className={`flex-row ${className}`} {...rest}>
Expand All @@ -41,7 +41,7 @@ TimelineRow.defaultProps = {
className: '',
};

function TimelineRowCell(props: TimelineRowCellProps) {
function TimelineRowCell(props: ITimelineRowCellProps) {
const { children, className = '', width, style, ...rest } = props;
const widthPercent = `${width * 100}%`;
const mergedStyle = { ...style, flexBasis: widthPercent, maxWidth: widthPercent };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TimelineHeaderRow from './TimelineHeaderRow';
import VirtualizedTraceView from './VirtualizedTraceView';
import { merge as mergeShortcuts } from '../keyboard-shortcuts';
import { Accessors } from '../ScrollManager';
import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate } from '../types';
import { TUpdateViewRangeTimeFunction, IViewRange, ViewRangeTimeUpdate } from '../types';
import { TNil, ReduxState } from '../../../types';
import { Span, Trace } from '../../../types/trace';

Expand All @@ -43,7 +43,7 @@ type TProps = TDispatchProps & {
trace: Trace;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
viewRange: ViewRange;
viewRange: IViewRange;
};

const NUM_TICKS = 5;
Expand Down
4 changes: 2 additions & 2 deletions packages/jaeger-ui/src/components/TracePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { trackSlimHeaderToggle } from './TracePageHeader/TracePageHeader.track';
import TracePageHeader from './TracePageHeader';
import TraceTimelineViewer from './TraceTimelineViewer';
import { actions as timelineActions } from './TraceTimelineViewer/duck';
import { TUpdateViewRangeTimeFunction, ViewRange, ViewRangeTimeUpdate } from './types';
import { TUpdateViewRangeTimeFunction, IViewRange, ViewRangeTimeUpdate } from './types';
import { getLocation, getUrl } from './url';
import ErrorMessage from '../common/ErrorMessage';
import LoadingIndicator from '../common/LoadingIndicator';
Expand Down Expand Up @@ -87,7 +87,7 @@ type TState = {
headerHeight: number | TNil;
slimView: boolean;
traceGraphView: boolean;
viewRange: ViewRange;
viewRange: IViewRange;
};

// export for tests
Expand Down
22 changes: 11 additions & 11 deletions packages/jaeger-ui/src/components/TracePage/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@

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

interface TimeCursorUpdate {
interface ITimeCursorUpdate {
cursor: number | TNil;
}

interface TimeReframeUpdate {
interface ITimeReframeUpdate {
reframe: {
anchor: number;
shift: number;
};
}

interface TimeShiftEndUpdate {
interface ITimeShiftEndUpdate {
shiftEnd: number;
}

interface TimeShiftStartUpdate {
interface ITimeShiftStartUpdate {
shiftStart: number;
}

export type TUpdateViewRangeTimeFunction = (start: number, end: number, trackSrc?: string) => void;

export type ViewRangeTimeUpdate =
| TimeCursorUpdate
| TimeReframeUpdate
| TimeShiftEndUpdate
| TimeShiftStartUpdate;
| ITimeCursorUpdate
| ITimeReframeUpdate
| ITimeShiftEndUpdate
| ITimeShiftStartUpdate;

export interface ViewRangeTime {
export interface IViewRangeTime {
current: [number, number];
cursor?: number | TNil;
reframe?: {
Expand All @@ -52,6 +52,6 @@ export interface ViewRangeTime {
shiftStart?: number;
}

export interface ViewRange {
time: ViewRangeTime;
export interface IViewRange {
time: IViewRangeTime;
}