-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[webui] eslint fix #1864
[webui] eslint fix #1864
Changes from 2 commits
725c472
0c4d8d9
e2a9db5
60fa3a7
4c5fe45
336409b
1ce7067
0cdfa8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,15 @@ class App extends React.Component<{}, AppState> { | |
}; | ||
} | ||
|
||
async componentDidMount() { | ||
async componentDidMount(): Promise<any> { | ||
await Promise.all([ EXPERIMENT.init(), TRIALS.init() ]); | ||
this.setState(state => ({ experimentUpdateBroadcast: state.experimentUpdateBroadcast + 1 })); | ||
this.setState(state => ({ trialsUpdateBroadcast: state.trialsUpdateBroadcast + 1 })); | ||
this.timerId = window.setTimeout(this.refresh, this.state.interval * 1000); | ||
this.setState({ metricGraphMode: (EXPERIMENT.optimizeMode === 'minimize' ? 'min' : 'max') }); | ||
} | ||
|
||
changeInterval = (interval: number) => { | ||
changeInterval = (interval: number): void => { | ||
this.setState({ interval }); | ||
if (this.timerId === null && interval !== 0) { | ||
window.setTimeout(this.refresh); | ||
|
@@ -45,15 +45,15 @@ class App extends React.Component<{}, AppState> { | |
} | ||
|
||
// TODO: use local storage | ||
changeColumn = (columnList: Array<string>) => { | ||
changeColumn = (columnList: Array<string>): void => { | ||
this.setState({ columnList: columnList }); | ||
} | ||
|
||
changeMetricGraphMode = (val: 'max' | 'min') => { | ||
changeMetricGraphMode = (val: 'max' | 'min'): void => { | ||
this.setState({ metricGraphMode: val }); | ||
} | ||
|
||
render() { | ||
render(): any{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the return type be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's right! |
||
const { interval, columnList, experimentUpdateBroadcast, trialsUpdateBroadcast, metricGraphMode } = this.state; | ||
if (experimentUpdateBroadcast === 0 || trialsUpdateBroadcast === 0) { | ||
return null; // TODO: render a loading page | ||
|
@@ -86,7 +86,7 @@ class App extends React.Component<{}, AppState> { | |
); | ||
} | ||
|
||
private refresh = async () => { | ||
private refresh = async (): Promise<any> => { | ||
const [ experimentUpdated, trialsUpdated ] = await Promise.all([ EXPERIMENT.update(), TRIALS.update() ]); | ||
if (experimentUpdated) { | ||
this.setState(state => ({ experimentUpdateBroadcast: state.experimentUpdateBroadcast + 1 })); | ||
|
@@ -107,7 +107,7 @@ class App extends React.Component<{}, AppState> { | |
} | ||
} | ||
|
||
private async lastRefresh() { | ||
private async lastRefresh(): Promise<any> { | ||
await EXPERIMENT.update(); | ||
await TRIALS.update(true); | ||
this.setState(state => ({ experimentUpdateBroadcast: state.experimentUpdateBroadcast + 1 })); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ class Compare extends React.Component<CompareProps, {}> { | |
super(props); | ||
} | ||
|
||
intermediate = () => { | ||
intermediate = (): any => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the object type of the return value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's hard to ensure its type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried |
||
const { compareRows } = this.props; | ||
const trialIntermediate: Array<Intermedia> = []; | ||
const idsList: Array<string> = []; | ||
|
@@ -52,14 +52,14 @@ class Compare extends React.Component<CompareProps, {}> { | |
tooltip: { | ||
trigger: 'item', | ||
enterable: true, | ||
position: function (point: Array<number>, data: TooltipForIntermediate) { | ||
position: function (point: Array<number>, data: TooltipForIntermediate): Array<number> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks |
||
if (data.dataIndex < length / 2) { | ||
return [point[0], 80]; | ||
} else { | ||
return [point[0] - 300, 80]; | ||
} | ||
}, | ||
formatter: function (data: TooltipForIntermediate) { | ||
formatter: function (data: TooltipForIntermediate): any { | ||
const trialId = data.seriesName; | ||
let obj = {}; | ||
const temp = trialIntermediate.find(key => key.name === trialId); | ||
|
@@ -106,7 +106,7 @@ class Compare extends React.Component<CompareProps, {}> { | |
} | ||
|
||
// render table column --- | ||
initColumn = () => { | ||
initColumn = (): any => { | ||
const idList: Array<string> = []; | ||
const sequenceIdList: Array<number> = []; | ||
const durationList: Array<number> = []; | ||
|
@@ -195,15 +195,15 @@ class Compare extends React.Component<CompareProps, {}> { | |
); | ||
} | ||
|
||
componentDidMount() { | ||
componentDidMount(): void { | ||
this._isCompareMount = true; | ||
} | ||
|
||
componentWillUnmount() { | ||
componentWillUnmount(): void { | ||
this._isCompareMount = false; | ||
} | ||
|
||
render() { | ||
render(): any{ | ||
const { visible, cancelFunc } = this.props; | ||
|
||
return ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,31 +35,31 @@ class Overview extends React.Component<OverviewProps, OverviewState> { | |
}; | ||
} | ||
|
||
clickMaxTop = (event: React.SyntheticEvent<EventTarget>) => { | ||
clickMaxTop = (event: React.SyntheticEvent<EventTarget>): void => { | ||
event.stopPropagation(); | ||
// #999 panel active bgcolor; #b3b3b3 as usual | ||
const { changeMetricGraphMode } = this.props; | ||
changeMetricGraphMode('max'); | ||
} | ||
|
||
clickMinTop = (event: React.SyntheticEvent<EventTarget>) => { | ||
clickMinTop = (event: React.SyntheticEvent<EventTarget>): void => { | ||
event.stopPropagation(); | ||
const { changeMetricGraphMode } = this.props; | ||
changeMetricGraphMode('min'); | ||
} | ||
|
||
changeConcurrency = (val: number) => { | ||
changeConcurrency = (val: number): void => { | ||
this.setState({ trialConcurrency: val }); | ||
} | ||
|
||
render() { | ||
render(): any { | ||
const { trialConcurrency } = this.state; | ||
const { experimentUpdateBroadcast, metricGraphMode } = this.props; | ||
|
||
const searchSpace = this.convertSearchSpace(); | ||
|
||
const bestTrials = this.findBestTrials(); | ||
const bestAccuracy = bestTrials.length > 0 ? bestTrials[0].accuracy! : NaN; | ||
const bestAccuracy = bestTrials.length > 0 ? bestTrials[0].accuracy! : ''; // eslint-disable-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. |
||
const accuracyGraphData = this.generateAccuracyGraph(bestTrials); | ||
const noDataMessage = bestTrials.length > 0 ? '' : 'No data'; | ||
|
||
|
@@ -147,7 +147,7 @@ class Overview extends React.Component<OverviewProps, OverviewState> { | |
const searchSpace = Object.assign({}, EXPERIMENT.searchSpace); | ||
Object.keys(searchSpace).map(item => { | ||
const key = searchSpace[item]._type; | ||
let value = searchSpace[item]._value; | ||
const value = searchSpace[item]._value; | ||
switch (key) { | ||
case 'quniform': | ||
case 'qnormal': | ||
|
@@ -161,7 +161,7 @@ class Overview extends React.Component<OverviewProps, OverviewState> { | |
} | ||
|
||
private findBestTrials(): Trial[] { | ||
let bestTrials = TRIALS.sort(); | ||
const bestTrials = TRIALS.sort(); | ||
if (this.props.metricGraphMode === 'max') { | ||
bestTrials.reverse().splice(10); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Promise since there is no return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Had changed
Promise<any>
toPromise<void>
.