Skip to content

Commit

Permalink
Fix eslint warnings
Browse files Browse the repository at this point in the history
The @typescript-eslint/no-unused-vars rule allows unused arguments in
functions only if prefix with a '_'.

Closed eclipse-cdt-cloud#83

Signed-off-by: Geneviève Bastien <[email protected]>
  • Loading branch information
tahini committed Jul 7, 2020
1 parent 2d28f10 commit 6b428f8
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 45 deletions.
3 changes: 2 additions & 1 deletion configs/warnings.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"rules": {
"@typescript-eslint/await-thenable": "warn",
"no-return-await": "warn",
"keyword-spacing": ["warn", { "before": true, "after": true} ]
"keyword-spacing": ["warn", { "before": true, "after": true} ],
"@typescript-eslint/no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "argsIgnorePattern": "^_" }]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class TraceExplorerWidget extends ReactWidget {
this.updateAvailableAnalysis(openedExperiment);
}

private onExperimentClosed(closedExperiment: Experiment) {
private onExperimentClosed(_closedExperiment: Experiment) {
this.tooltip = {};
this.updateOpenedExperiments();
this.updateAvailableAnalysis(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export abstract class AbstractOutputComponent<P extends AbstractOutputProps, S e
this.mainAreaContainer = React.createRef();
}

render() {
render(): JSX.Element {
this.closeComponent = this.closeComponent.bind(this);
return <div className='output-container' style={{ width: this.props.style.width }}>
<div className='widget-handle' style={{ width: this.handleWidth }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,
const treeWidth = this.props.style.width - this.props.style.chartWidth - this.getHandleWidth();
return <React.Fragment>
<div ref={this.treeRef} className='output-component-tree'
onScroll={ev => { this.synchronizeTreeScroll(); }}
onScroll={_ev => { this.synchronizeTreeScroll(); }}
style={{ width: treeWidth, height: this.props.style.height }}
>
{this.renderTree()}
Expand All @@ -28,7 +28,7 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,

abstract synchronizeTreeScroll(): void;

protected async waitAnalysisCompletion() {
protected async waitAnalysisCompletion(): Promise<void> {
const traceUUID = this.props.traceId;
const tspClient = this.props.tspClient;
const outPutId = this.props.outputDescriptor.id;
Expand All @@ -45,9 +45,9 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,
});
}

componentWillUnmount() {
componentWillUnmount(): void {
// fix Warning: Can't perform a React state update on an unmounted component
this.setState = (state,callback) => undefined;
this.setState = (_state, _callback) => undefined;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class StyleProvider {
return this.styles;
}

public getStylesTmp(forceUpdate?: boolean): { [key: string]: { [key: string]: any } } {
public getStylesTmp(_forceUpdate?: boolean): { [key: string]: { [key: string]: any } } {
const styles = this.tmpStyleObject[this.outputId];
return styles ? styles : {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class TspDataProvider {
this.timeGraphRows = newTimeGraphRows;
}

protected getStateModelByRow(row: TimeGraphRow, chartStart: number) {
protected getStateModelByRow(row: TimeGraphRow, chartStart: number): TimelineChart.TimeGraphRowElementModel[] {
const states: TimelineChart.TimeGraphRowElementModel[] = [];
row.states.forEach((state: TimeGraphState, idx: number) => {
const end = state.startTime + state.duration - chartStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
}
}

async componentDidMount() {
async componentDidMount(): Promise<void> {
this.waitAnalysisCompletion();
}

async componentDidUpdate(prevProps: TimegraphOutputProps, prevState: TimegraohOutputState) {
async componentDidUpdate(_prevProps: TimegraphOutputProps, _prevState: TimegraohOutputState): Promise<void> {
if (this.state.outputStatus !== ResponseStatus.COMPLETED || !this.state.timegraphTree.length) {
const treeParameters = QueryHelper.timeQuery([0, 1]);
const treeResponse = (await this.props.tspClient.fetchTimeGraphTree<TimeGraphEntry, EntryHeader>(this.props.traceId,
Expand Down Expand Up @@ -161,7 +161,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
</ReactTimeGraphContainer>;
}

protected getVerticalScrollbar() {
protected getVerticalScrollbar(): JSX.Element {
return <ReactTimeGraphContainer
id='vscroll'
options={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
private traceContextContainer: React.RefObject<HTMLDivElement>;

protected widgetResizeHandlers: (() => void)[] = [];
protected readonly addWidgetResizeHandler = (h: () => void) => {
protected readonly addWidgetResizeHandler = (h: () => void): void => {
this.widgetResizeHandlers.push(h);
};

Expand Down Expand Up @@ -124,7 +124,7 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
text: `Indexing ${this.props.experiment.name}: ${this.state.experiment.nbEvents}`,
alignment: StatusBarAlignment.RIGHT
});
await this.sleep(500);
this.sleep(500);
}
}
this.props.statusBar.removeElement(this.INDEXING_STATUS_BAR_KEY);
Expand All @@ -134,13 +134,13 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
new Promise(resolve => setTimeout(resolve, ms));
}

componentDidMount() {
componentDidMount(): void {
this.onResize = this.onResize.bind(this);
this.props.addResizeHandler(this.onResize);
this.onResize();
}

componentWillUnmount() {
componentWillUnmount(): void {
this.props.statusBar.removeElement(this.INDEXING_STATUS_BAR_KEY);
this.props.statusBar.removeElement(this.TIME_SELECTION_STATUS_BAR_KEY);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ export class TraceContextComponent extends React.Component<TraceContextProps, Tr
}));
}

render() {
render(): JSX.Element {
return <div className='trace-context-container' ref={this.traceContextContainer}>
{this.props.outputs.length ? this.renderOutputs() : this.renderPlaceHolder()}
</div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CheckboxComponent extends React.Component<CheckboxProps> {
super(props);
}

renderCheckbox = (checkedStatus: number) => {
renderCheckbox = (checkedStatus: number): React.ReactNode => {
switch (checkedStatus) {
case 0:
return icons.unchecked;
Expand All @@ -26,7 +26,7 @@ export class CheckboxComponent extends React.Component<CheckboxProps> {
}
};

render() {
render(): JSX.Element {
return <div onClick={() => this.props.onChecked(this.props.id)} >
<span style={{padding: 5}}>
{this.renderCheckbox(this.props.checkedStatus)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Message extends React.Component<MessageProps> {
error: ''
};

render() {
render(): JSX.Element {
return <React.Fragment>
<span>{this.props.error}</span>
</React.Fragment>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export class FilterTree extends React.Component<FilterTreeProps> {

getNode = (id: number): TreeNode | undefined => {
const nodes: TreeNode[] = [...this.props.nodes];
if (!nodes) {
return undefined;
}
let currentNode: TreeNode;
while (nodes.length) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
currentNode = nodes.pop()!;
if (currentNode.id === id) {
return currentNode;
Expand Down Expand Up @@ -114,7 +118,7 @@ export class FilterTree extends React.Component<FilterTreeProps> {

isCollapsed = (id: number): boolean => this.props.collapsedNodes.includes(id);

renderTreeNodes = (nodes: TreeNode[], parent: TreeNode = defaultTreeNode, level = 0): JSX.Element | undefined => {
renderTreeNodes = (nodes: TreeNode[], _parent: TreeNode = defaultTreeNode, level = 0): JSX.Element | undefined => {
const treeNodes = nodes.map((node: TreeNode) => {
const children = node.children.length > 0 ? this.renderTreeNodes(node.children, node, level+1) : undefined;
const checkedStatus = this.getCheckedStatus(node.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const entryToTreeNode = (entry: Entry) => ({
children: []
} as TreeNode);

export const listToTree = (list: Entry[]) => {
export const listToTree = (list: Entry[]): TreeNode[] => {
const rootNodes: TreeNode[] = [];
const lookup: { [key: string]: TreeNode } = {};
list.forEach(entry => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export class XYTree extends React.Component<XYTreeProps> {
super(props);
}

shouldComponentUpdate = (nextProps: XYTreeProps) => (this.props.checkedSeries !== nextProps.checkedSeries || this.props.entries !== nextProps.entries);
shouldComponentUpdate = (nextProps: XYTreeProps): boolean => (this.props.checkedSeries !== nextProps.checkedSeries || this.props.entries !== nextProps.entries);

render() {
render(): JSX.Element {
return <FilterTree
nodes = { listToTree(this.props.entries) }
showCheckboxes={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface TimeAxisProps {
}

export class TimeAxisComponent extends React.Component<TimeAxisProps> {
render() {
render(): JSX.Element {
return <ReactTimeGraphContainer
id='timegraph-axis'
options={{
Expand All @@ -31,15 +31,15 @@ export class TimeAxisComponent extends React.Component<TimeAxisProps> {
layer={[this.getAxisLayer(), this.getAxisCursors()]} />;
}

protected getAxisLayer() {
protected getAxisLayer(): TimeGraphAxis {
const timeAxisLayer = new TimeGraphAxis('timeGraphAxis', {
color: this.props.style.naviBackgroundColor,
lineColor: this.props.style.lineColor
});
return timeAxisLayer;
}

protected getAxisCursors() {
protected getAxisCursors(): TimeGraphAxisCursors {
return new TimeGraphAxisCursors('timeGraphAxisCursors', { color: this.props.style.cursorColor });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface TimeNavigatorProps {
}

export class TimeNavigatorComponent extends React.Component<TimeNavigatorProps> {
render() {
render(): JSX.Element {
const navi = new TimeGraphNavigator('timeGraphNavigator');
return <ReactTimeGraphContainer
id='time-navigator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ReactTimeGraphContainer extends React.Component<ReactTimeGraphConta
protected ref: HTMLCanvasElement | undefined;
protected container?: TimeGraphContainer;

componentDidMount() {
componentDidMount(): void {
this.container = new TimeGraphContainer(this.props.options, this.props.unitController, this.ref);
this.props.layer.forEach(l => {
if (this.container) { this.container.addLayer(l); }
Expand All @@ -28,7 +28,7 @@ export class ReactTimeGraphContainer extends React.Component<ReactTimeGraphConta
});
}

render() {
render(): JSX.Element {
return <canvas ref={ref => this.ref = ref || undefined} onWheel={e => e.preventDefault()}></canvas>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ export class XYOutputComponent extends AbstractTreeOutputComponent<AbstractOutpu

this.afterChartDraw = this.afterChartDraw.bind(this);
Chart.pluginService.register({
afterDraw: (chart, easing) => {
afterDraw: (chart, _easing) => {
this.afterChartDraw(chart);
}
});
this.lineChartRef = React.createRef();
}

componentDidMount() {
componentDidMount(): void {
this.waitAnalysisCompletion();
}

componentDidUpdate(prevProps: AbstractOutputProps, prevState: XYOuputState) {
componentDidUpdate(prevProps: AbstractOutputProps, prevState: XYOuputState): void {
const viewRangeChanged = this.props.viewRange !== prevProps.viewRange;
const checkedSeriesChanged = this.state.checkedSeries !== prevState.checkedSeries;
const collapsedNodesChanged = this.state.collapsedNodes !== prevState.collapsedNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class TraceViewerContribution extends WidgetOpenHandler<TraceViewerWidget
registry.registerCommand(TraceViewerCommands.OPEN);
}

canHandle(uri: URI): number {
canHandle(_uri: URI): number {
return 100;
}
}
4 changes: 2 additions & 2 deletions viewer-prototype/src/browser/trace-viewer/trace-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class TraceViewerWidget extends ReactWidget {
this.update();
}

onCloseRequest(msg: Message) {
onCloseRequest(msg: Message): void {
if (this.openedExperiment) {

const traces = this.openedExperiment.traces;
Expand All @@ -107,7 +107,7 @@ export class TraceViewerWidget extends ReactWidget {
super.onCloseRequest(msg);
}

protected onResize() {
protected onResize(): void {
this.resizeHandlers.forEach(h => h());
}

Expand Down
4 changes: 2 additions & 2 deletions viewer-prototype/src/common/experiment-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ExperimentManager {
// Repost with a suffix as long as there are conflicts
const handleConflict = async function (tspClient: TspClient, tryNb: number): Promise<TspClientResponse<Experiment>> {
const suffix = '(' + tryNb + ')';
return await tspClient.createExperiment(new Query({
return tspClient.createExperiment(new Query({
'name': name + suffix,
'traces': traceURIs
}));
Expand Down Expand Up @@ -141,7 +141,7 @@ export class ExperimentManager {
* Close the given on the server
* @param experimentUUID experiment UUID
*/
async closeExperiment(experimentUUID: string) {
async closeExperiment(experimentUUID: string): Promise<void> {
const experimentToClose = this.fOpenExperiments.get(experimentUUID);
if (experimentToClose) {
await this.tspClient.deleteExperiment(experimentUUID);
Expand Down
2 changes: 1 addition & 1 deletion viewer-prototype/src/common/signal-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SignalManager {
return this.instance;
}

public fireTooltipSignal(payload: { [key: string]: string }) {
public fireTooltipSignal(payload: { [key: string]: string }): void {
this.tooltipEmitter.fire(payload);
}
}
4 changes: 2 additions & 2 deletions viewer-prototype/src/common/trace-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class TraceManager {
// Repost with a suffix as long as there are conflicts
const handleConflict = async function (tspClient: TspClient, tryNb: number): Promise<TspClientResponse<Trace>> {
const suffix = '(' + tryNb + ')';
return await tspClient.openTrace(new Query({
return tspClient.openTrace(new Query({
'name': name + suffix,
'uri': tracePath
}));
Expand Down Expand Up @@ -139,7 +139,7 @@ export class TraceManager {
* Close the given on the server
* @param traceUUID Trace UUID
*/
async closeTrace(traceUUID: string) {
async closeTrace(traceUUID: string): Promise<void> {
const traceToClose = this.fOpenTraces.get(traceUUID);
if (traceToClose) {
await this.tspClient.deleteTrace(traceUUID);
Expand Down
8 changes: 4 additions & 4 deletions viewer-prototype/src/common/utils/time-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TimeRange {
* Get the range start time.
* If an offset is present the return value is start + offset.
*/
public getstart() {
public getstart(): number {
if (this.offset !== undefined) {
return this.start + this.offset;
}
Expand All @@ -30,7 +30,7 @@ export class TimeRange {
* Get the range end time.
* If an offset is present the return value is end + offset.
*/
public getEnd() {
public getEnd(): number {
if (this.offset !== undefined) {
return this.end + this.offset;
}
Expand All @@ -40,14 +40,14 @@ export class TimeRange {
/**
* Get range duration
*/
public getDuration() {
public getDuration(): number {
return this.end - this.start;
}

/**
* Return the time offset
*/
public getOffset() {
public getOffset(): number | undefined {
return this.offset;
}
}

0 comments on commit 6b428f8

Please sign in to comment.