Fix more defects reported by ESLint

This commit is contained in:
Jesús Ángel 2019-08-23 14:37:38 +02:00
parent 2784db6681
commit a1086a9e2d
4 changed files with 3 additions and 133 deletions

View File

@ -24,7 +24,9 @@
"no-extra-boolean-cast": "off",
"node/no-unpublished-require": 0,
"node/no-unsupported-features": 0,
"node/no-unsupported-features/es-syntax": 0
"node/no-unsupported-features/es-syntax": 0,
"react/prop-types": 0,
"node/no-unsupported-features/es-builtins": 0
},
"plugins": ["node", "async-await"],
"extends": [

View File

@ -1,66 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { EuiGlobalToastList, Toast } from '@elastic/eui';
import React from 'react';
import * as Rx from 'rxjs';
interface Props {
toasts$: Rx.Observable<Toast[]>;
dismissToast: (t: Toast) => void;
}
interface State {
toasts: Toast[];
}
export class GlobalToastListw extends React.Component<Props, State> {
public state: State = {
toasts: []
};
private subscription?: Rx.Subscription;
public componentDidMount() {
this.subscription = this.props.toasts$.subscribe(toasts => {
this.setState({ toasts });
});
}
public componentWillUnmount() {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
public render() {
const increaseTime = ((this.state || {}).toasts || []).some(
item => item.color === 'danger'
);
return (
<EuiGlobalToastList
toasts={this.state.toasts}
dismissToast={this.props.dismissToast}
toastLifeTimeMs={increaseTime ? 30000 : 6000}
/>
);
}
}

View File

@ -1,64 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Toast } from '@elastic/eui';
import { I18nSetup } from '../../../../../src/core/public/i18n';
import { GlobalToastList } from '../../../../../src/core/public/notifications/toasts/global_toast_list';
import { ToastsApi } from '../../../../../src/core/public/notifications/toasts/toasts_api';
interface StartDeps {
i18n: I18nSetup;
targetDomElement: HTMLElement;
}
export class ToastsService {
private api?: ToastsApi;
private targetDomElement?: HTMLElement;
public setup() {
this.api = new ToastsApi();
return this.api!;
}
public start({ i18n, targetDomElement }: StartDeps) {
this.targetDomElement = targetDomElement;
render(
<i18n.Context>
<GlobalToastList
dismissToast={(toast: Toast) => this.api!.remove(toast)}
toasts$={this.api!.get$()}
/>
</i18n.Context>,
targetDomElement
);
return this.api!;
}
public stop() {
if (this.targetDomElement) {
unmountComponentAtNode(this.targetDomElement);
this.targetDomElement.textContent = '';
}
}
}

View File

@ -1,8 +1,6 @@
const chai = require('chai');
const needle = require('needle');
const { version, revision } = require('../../package.json');
const kibanaServer = process.env.KIBANA_IP || 'localhost';
chai.should();