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

[webui] eslint fix #1864

Merged
merged 8 commits into from Dec 23, 2019
Merged

[webui] eslint fix #1864

merged 8 commits into from Dec 23, 2019

Conversation

lvybriage
Copy link
Contributor

@lvybriage lvybriage commented Dec 19, 2019

  • disable react/disable-name in eslint. 参考issue

  • update azure-pipelines.yml to enable webui eslint

  • had specify the rule, such as // eslint-disable-line @typescript-eslint/camelcase

  • render() : any change to render() : React.ReactNode

  • // eslint-disable-line @... , @..., @...

  • change more accuracy function type

Still have seven errors to fix & test

image

@lvybriage lvybriage changed the title fix eslint [Webui] eslint fix Dec 20, 2019
@lvybriage lvybriage changed the title [Webui] eslint fix [webui] eslint fix Dec 20, 2019
@@ -27,15 +27,15 @@ class App extends React.Component<{}, AppState> {
};
}

async componentDidMount() {
async componentDidMount(): Promise<any> {
Copy link
Contributor

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.

Copy link
Contributor Author

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> to Promise<void>.

@scarlett2018 scarlett2018 mentioned this pull request Dec 20, 2019
44 tasks
@@ -20,7 +20,7 @@ class Compare extends React.Component<CompareProps, {}> {
super(props);
}

intermediate = () => {
intermediate = (): any => {
Copy link
Contributor

@chicm-ms chicm-ms Dec 20, 2019

Choose a reason for hiding this comment

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

what is the object type of the return value?

Copy link
Contributor Author

@lvybriage lvybriage Dec 20, 2019

Choose a reason for hiding this comment

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

It's hard to ensure its type.
I try HTMLElement Element HTMLDivElement.
all tooltip this error: Type 'Element' is missing the following properties from type 'HTMLDivElement': align, addEventListener, removeEventListener, accessKey, and 238 more.ts(2740)

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried React.ReactNode?

@@ -189,15 +189,15 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
);
}

fresh = (event: React.SyntheticEvent<EventTarget>) => {
fresh = (event: React.SyntheticEvent<EventTarget>): any => {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be void

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks~

@@ -21,7 +21,7 @@ class Accuracy extends React.Component<AccuracyProps, {}> {

}

render() {
render(): any { // eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

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

should specify the rule being disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

this.setState({ isShowLogDrawer: false });
}

render() {
render(): any { // eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

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

specify the rule being disabled

Copy link
Contributor Author

@lvybriage lvybriage Dec 20, 2019

Choose a reason for hiding this comment

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

Oh, when add the any type, it doesn't need to add the note. I'll delete all the similar questions. Thanks!

@chicm-ms
Copy link
Contributor

please update azure-pipelines.yml to enable webui eslint

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
Copy link
Contributor

Choose a reason for hiding this comment

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

when // eslint-disable-line is used, please specify the rule such as // eslint-disable-line @typescript-eslint/camelcase, so that we know which rule is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

@lvybriage
Copy link
Contributor Author

azure-pipelines.yml

OK.

@@ -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> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Array<number> is more oftenly written as 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.

Thanks

this.setState({ metricGraphMode: val });
}

render() {
render(): any{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the return type be React.ReactNode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's right!

@@ -60,55 +60,57 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
tablePageSize: 20,
whichGraph: '1',
searchType: 'id',
searchFilter: trial => true,
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
searchFilter: trial => true // eslint-disable-line @typescript-eslint/no-unused-vars
Copy link
Contributor

Choose a reason for hiding this comment

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

This two disabling should be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had fixed, thanks~

if (!targetValue.trim()) {
this.setState({ searchFilter: filter });
return;
}
switch (this.state.searchType) {
case 'id':
filter = trial => trial.info.id.toUpperCase().includes(targetValue.toUpperCase());
filter = (trial): any => trial.info.id.toUpperCase().includes(targetValue.toUpperCase()); // elint-disable-line
Copy link
Contributor

@liuzhe-lz liuzhe-lz Dec 23, 2019

Choose a reason for hiding this comment

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

The return type is boolean.
elint-disable-line does nothing I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had fixed. Thanks~

@@ -98,6 +101,8 @@ class Progressed extends React.Component<ProgressProps, ProgressState> {
</div>
);
}

const bestFinalResult = (typeof bestAccuracy === 'number') ? bestAccuracy.toFixed(6) : '--';
Copy link
Contributor

@liuzhe-lz liuzhe-lz Dec 23, 2019

Choose a reason for hiding this comment

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

Accuracy might be NaN (which is a number) in next release.
No need to fix now though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change origin code back. And then add // eslint-disable-line @...

@@ -73,10 +73,17 @@ class OpenRow extends React.Component<OpenRowProps, OpenRowState> {
Trails for multiphase experiment will return a set of parameters,
we are listing the latest parameter in webportal.
<br />
For the entire parameter set, please refer to the following "
<a href={trialLink} target="_blank">{trialLink}</a>".
For the entire parameter set, please refer to the following&quot;
Copy link
Contributor

Choose a reason for hiding this comment

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

space before &quot;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@leckie-chn leckie-chn merged commit 56be400 into microsoft:master Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants