Remove eslint overwrite for src/legacy/core_plugins/kibana (#54222)

* Cleanup code 
* Remove eslint overwrite
This commit is contained in:
Matthias Wilhelm 2020-01-09 11:56:14 +01:00 committed by GitHub
parent ecddfd8842
commit 58f792cee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 22 deletions

View file

@ -82,13 +82,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['src/legacy/core_plugins/kibana/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['src/legacy/core_plugins/tile_map/**/*.{js,ts,tsx}'],
rules: {

View file

@ -91,7 +91,7 @@ export function useEsDocSearch({
useEffect(() => {
requestData();
}, []);
});
return [status, hit, indexPattern];
}

View file

@ -67,11 +67,6 @@ export interface Props {
* Additionally there's a button displayed that allows the user to show/hide more filter fields
*/
export function DiscoverFieldSearch({ onChange, value, types }: Props) {
if (typeof value !== 'string') {
// at initial rendering value is undefined (angular related), this catches the warning
// should be removed once all is react
return null;
}
const searchPlaceholder = i18n.translate('kbn.discover.fieldChooser.searchPlaceHolder', {
defaultMessage: 'Search field names',
});
@ -99,6 +94,12 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
missing: true,
});
if (typeof value !== 'string') {
// at initial rendering value is undefined (angular related), this catches the warning
// should be removed once all is react
return null;
}
const filterBtnAriaLabel = isPopoverOpen
? i18n.translate('kbn.discover.fieldChooser.toggleFieldFilterButtonHideAriaLabel', {
defaultMessage: 'Hide field filter settings',

View file

@ -45,19 +45,19 @@ export function DiscoverIndexPattern({
selectedIndexPattern,
setIndexPattern,
}: DiscoverIndexPatternProps) {
if (!indexPatternList || indexPatternList.length === 0 || !selectedIndexPattern) {
// just in case, shouldn't happen
return null;
}
const options: IndexPatternRef[] = indexPatternList.map(entity => ({
const options: IndexPatternRef[] = (indexPatternList || []).map(entity => ({
id: entity.id,
title: entity.attributes!.title,
}));
const { id: selectedId, attributes } = selectedIndexPattern || {};
const [selected, setSelected] = useState({
id: selectedIndexPattern.id,
title: selectedIndexPattern.attributes!.title,
id: selectedId,
title: attributes?.title || '',
});
if (!selectedId) {
return null;
}
return (
<div className="indexPattern__container">

View file

@ -16,11 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { wrapInI18nContext } from '../../../kibana_services';
import { DiscoverIndexPattern } from './discover_index_pattern';
import { DiscoverIndexPattern, DiscoverIndexPatternProps } from './discover_index_pattern';
/**
* At initial rendering the angular directive the selectedIndexPattern prop is undefined
* This wrapper catches this, had to be introduced to satisfy eslint
*/
export function DiscoverIndexPatternWrapper(props: DiscoverIndexPatternProps) {
if (!props.selectedIndexPattern || !Array.isArray(props.indexPatternList)) {
return null;
}
return <DiscoverIndexPattern {...props} />;
}
export function createIndexPatternSelectDirective(reactDirective: any) {
return reactDirective(wrapInI18nContext(DiscoverIndexPattern), [
return reactDirective(wrapInI18nContext(DiscoverIndexPatternWrapper), [
['indexPatternList', { watchDepth: 'reference' }],
['selectedIndexPattern', { watchDepth: 'reference' }],
['setIndexPattern', { watchDepth: 'reference' }],