diff --git a/.eslintrc b/.eslintrc index 6688e1bc107..c88e985c2d3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,11 +16,8 @@ "react-hooks/exhaustive-deps": "off", "react/prop-types": "off", "react/no-unescaped-entities": "off", - "react/display-name": "off", - "react/no-deprecated": "off", "react/no-unknown-property": "off", "react/no-children-prop": "off", - "react/no-find-dom-node": "off", "react/no-render-return-value": "off", "no-only-tests/no-only-tests": "error" } diff --git a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx index 227058a4530..e976629d1c6 100644 --- a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx +++ b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx @@ -1,5 +1,4 @@ -import { PureComponent } from 'react'; -import ReactDOM from 'react-dom'; +import React, { PureComponent, createRef } from 'react'; export interface Props { /** @@ -28,6 +27,7 @@ export class ClickOutsideWrapper extends PureComponent { parent: window, useCapture: false, }; + myRef = createRef(); state = { hasEventListener: false, }; @@ -48,7 +48,7 @@ export class ClickOutsideWrapper extends PureComponent { } onOutsideClick = (event: any) => { - const domNode = ReactDOM.findDOMNode(this) as Element; + const domNode = this.myRef.current; if (!domNode || !domNode.contains(event.target)) { this.props.onClick(); @@ -56,6 +56,6 @@ export class ClickOutsideWrapper extends PureComponent { }; render() { - return this.props.children; + return
{this.props.children}
; } } diff --git a/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx b/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx index 91c59ffb417..26e3f64fdee 100644 --- a/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx @@ -19,20 +19,22 @@ export const SeriesColorPickerPopover: FunctionComponent ( - { - if (onToggleAxis) { - onToggleAxis(); - } - }} - /> - ), + tabComponent() { + return ( + { + if (onToggleAxis) { + onToggleAxis(); + } + }} + /> + ); + }, }, }} /> diff --git a/packages/grafana-ui/src/components/ColorPicker/SpectrumPalette.tsx b/packages/grafana-ui/src/components/ColorPicker/SpectrumPalette.tsx index bd22d22b6ad..cc76477cd66 100644 --- a/packages/grafana-ui/src/components/ColorPicker/SpectrumPalette.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/SpectrumPalette.tsx @@ -13,6 +13,7 @@ export interface SpectrumPaletteProps extends Themeable { onChange: (color: string) => void; } +// eslint-disable-next-line react/display-name const renderPointer = (theme: GrafanaTheme) => (props: SpectrumPalettePointerProps) => ( ); diff --git a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx index 6079ac5d3a6..7a584f08f1e 100644 --- a/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx +++ b/packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx @@ -191,6 +191,7 @@ const ContextMenuItemComponent: React.FC = React.memo( ); } ); +ContextMenuItemComponent.displayName = 'ContextMenuItemComponent'; interface ContextMenuGroupProps { group: ContextMenuGroup; diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx index 21e0427b5b2..8cceb55a4c4 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/ButtonSelect.tsx @@ -11,6 +11,7 @@ interface ButtonComponentProps { iconClass?: string; } +// eslint-disable-next-line react/display-name const ButtonComponent = (buttonProps: ButtonComponentProps) => (props: any) => { const { label, className, iconClass } = buttonProps; diff --git a/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx b/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx index da5a5baace5..6b94c5b1d39 100644 --- a/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx +++ b/packages/grafana-ui/src/components/InfoBox/FeatureInfoBox.tsx @@ -28,6 +28,7 @@ export const FeatureInfoBox = React.memo( return ; }) ); +FeatureInfoBox.displayName = 'FeatureInfoBox'; const getFeatureInfoBoxStyles = stylesFactory((theme: GrafanaTheme) => { return { diff --git a/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx index e635a459127..1646f9fde51 100644 --- a/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx +++ b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx @@ -55,6 +55,7 @@ export const InfoBox = React.memo( } ) ); +InfoBox.displayName = 'InfoBox'; const getInfoBoxStyles = stylesFactory((theme: GrafanaTheme, severity: AlertVariant) => ({ wrapper: css` diff --git a/packages/grafana-ui/src/components/MatchersUI/FieldNameByRegexMatcherEditor.tsx b/packages/grafana-ui/src/components/MatchersUI/FieldNameByRegexMatcherEditor.tsx index ecd9f111c28..5192c21ba71 100644 --- a/packages/grafana-ui/src/components/MatchersUI/FieldNameByRegexMatcherEditor.tsx +++ b/packages/grafana-ui/src/components/MatchersUI/FieldNameByRegexMatcherEditor.tsx @@ -15,6 +15,7 @@ export const FieldNameByRegexMatcherEditor = memo>(props return ; }); +FieldNameByRegexMatcherEditor.displayName = 'FieldNameByRegexMatcherEditor'; export const fieldNameByRegexMatcherItem: FieldMatcherUIRegistryItem = { id: FieldMatcherID.byRegexp, diff --git a/packages/grafana-ui/src/components/MatchersUI/FieldNameMatcherEditor.tsx b/packages/grafana-ui/src/components/MatchersUI/FieldNameMatcherEditor.tsx index 1131777d1ad..6fb2d33463f 100644 --- a/packages/grafana-ui/src/components/MatchersUI/FieldNameMatcherEditor.tsx +++ b/packages/grafana-ui/src/components/MatchersUI/FieldNameMatcherEditor.tsx @@ -21,6 +21,7 @@ export const FieldNameMatcherEditor = memo>(props => { const selectedOption = selectOptions.find(v => v.value === options); return ; }); +FieldTypeMatcherEditor.displayName = 'FieldTypeMatcherEditor'; const allTypes: Array> = [ { value: FieldType.number, label: 'Numeric' }, diff --git a/packages/grafana-ui/src/components/MatchersUI/FieldsByFrameRefIdMatcher.tsx b/packages/grafana-ui/src/components/MatchersUI/FieldsByFrameRefIdMatcher.tsx index c80c742411c..01d9e3658ea 100644 --- a/packages/grafana-ui/src/components/MatchersUI/FieldsByFrameRefIdMatcher.tsx +++ b/packages/grafana-ui/src/components/MatchersUI/FieldsByFrameRefIdMatcher.tsx @@ -26,6 +26,8 @@ export const FieldsByFrameRefIdMatcher = memo>(props => { return , - InputGroup: ({ children, className, style }) => ( - - {children} - - ), + Input(props) { + return ; + }, + InputGroup({ children, className, style }) { + return ( + + {children} + + ); + }, }; const getStyles = stylesFactory((theme: GrafanaTheme) => { diff --git a/public/app/features/explore/Wrapper.test.tsx b/public/app/features/explore/Wrapper.test.tsx index 34a26ec7dfd..104b5c0974d 100644 --- a/public/app/features/explore/Wrapper.test.tsx +++ b/public/app/features/explore/Wrapper.test.tsx @@ -28,7 +28,9 @@ type Mock = jest.Mock; jest.mock('react-virtualized-auto-sizer', () => { return { __esModule: true, - default: (props: any) =>
{props.children({ width: 1000 })}
, + default(props: any) { + return
{props.children({ width: 1000 })}
; + }, }; }); @@ -273,11 +275,13 @@ function makeDatasourceSetup({ name = 'loki', id = 1 }: { name?: string; id?: nu }, api: { components: { - QueryEditor: (props: QueryEditorProps) => ( -
- {name} Editor input: {props.query.expr} -
- ), + QueryEditor(props: QueryEditorProps) { + return ( +
+ {name} Editor input: {props.query.expr} +
+ ); + }, }, name: name, query: jest.fn(), diff --git a/public/app/features/search/components/DashboardListPage.tsx b/public/app/features/search/components/DashboardListPage.tsx index 78fff6e26d6..742859d3755 100644 --- a/public/app/features/search/components/DashboardListPage.tsx +++ b/public/app/features/search/components/DashboardListPage.tsx @@ -41,6 +41,7 @@ export const DashboardListPage: FC = memo(({ navModel, uid, url }) => { ); }); +DashboardListPage.displayName = 'DashboardListPage'; const mapStateToProps: MapStateToProps = state => { return { diff --git a/public/app/features/search/components/DashboardSearch.tsx b/public/app/features/search/components/DashboardSearch.tsx index ca7aeb50bcb..ed92d860ec0 100644 --- a/public/app/features/search/components/DashboardSearch.tsx +++ b/public/app/features/search/components/DashboardSearch.tsx @@ -57,6 +57,7 @@ export const DashboardSearch: FC = memo(({ onCloseSearch, params, updateL ); }); +DashboardSearch.displayName = 'DashboardSearch'; export default connectWithRouteParams(DashboardSearch); diff --git a/public/app/features/search/components/SearchCheckbox.tsx b/public/app/features/search/components/SearchCheckbox.tsx index 205fa66bcaf..1877ac9d2d5 100644 --- a/public/app/features/search/components/SearchCheckbox.tsx +++ b/public/app/features/search/components/SearchCheckbox.tsx @@ -28,3 +28,5 @@ const getStyles = stylesFactory(() => ({ } `, })); + +SearchCheckbox.displayName = 'SearchCheckbox'; diff --git a/public/app/features/search/components/SearchWrapper.tsx b/public/app/features/search/components/SearchWrapper.tsx index 1cab70f02a0..d69d43ee887 100644 --- a/public/app/features/search/components/SearchWrapper.tsx +++ b/public/app/features/search/components/SearchWrapper.tsx @@ -40,6 +40,8 @@ export const SearchWrapper: FC = memo(({ search, folder, updateLocation } return isOpen ? : null; }); +SearchWrapper.displayName = 'SearchWrapper'; + const mapStateToProps: MapStateToProps<{}, OwnProps, StoreState> = (state: StoreState) => { const { search, folder } = getLocationQuery(state.location); return { search, folder }; diff --git a/public/app/features/teams/__snapshots__/TeamGroupSync.test.tsx.snap b/public/app/features/teams/__snapshots__/TeamGroupSync.test.tsx.snap index 631f895ccb9..cccf6538e73 100644 --- a/public/app/features/teams/__snapshots__/TeamGroupSync.test.tsx.snap +++ b/public/app/features/teams/__snapshots__/TeamGroupSync.test.tsx.snap @@ -10,7 +10,7 @@ exports[`Render should render component 1`] = ` > External group sync - @@ -18,7 +18,7 @@ exports[`Render should render component 1`] = ` className="icon--has-hover page-sub-heading-icon" name="question-circle" /> - +
@@ -92,7 +92,7 @@ exports[`Render should render groups table 1`] = ` > External group sync - @@ -100,7 +100,7 @@ exports[`Render should render groups table 1`] = ` className="icon--has-hover page-sub-heading-icon" name="question-circle" /> - +
diff --git a/public/app/plugins/datasource/cloud-monitoring/components/Aggregations.test.tsx b/public/app/plugins/datasource/cloud-monitoring/components/Aggregations.test.tsx index d8e2172fa23..a6a9d1ad85d 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/Aggregations.test.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/Aggregations.test.tsx @@ -16,7 +16,9 @@ const props: Props = { } as any, crossSeriesReducer: '', groupBys: [], - children: renderProps =>
, + children(renderProps) { + return
; + }, templateVariableOptions: [], }; diff --git a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.tsx b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.tsx index 278d7bb46f0..4cbc38753c1 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.tsx @@ -42,8 +42,8 @@ const DefaultTarget: State = { export class AnnotationQueryEditor extends React.Component { state: State = DefaultTarget; - async UNSAFE_componentWillMount() { - // Unfortunately, migrations like this need to go componentWillMount. As soon as there's + async UNSAFE_UNSAFE_componentWillMount() { + // Unfortunately, migrations like this need to go UNSAFE_componentWillMount. As soon as there's // migration hook for this module.ts, we can do the migrations there instead. const { target, datasource } = this.props; if (!target.projectName) { diff --git a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx index c595749a435..4317778fa4e 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx @@ -18,10 +18,10 @@ interface State { export class QueryEditor extends PureComponent { state: State = { lastQueryError: '' }; - async UNSAFE_componentWillMount() { + async UNSAFE_UNSAFE_componentWillMount() { const { datasource, query } = this.props; - // Unfortunately, migrations like this need to go componentWillMount. As soon as there's + // Unfortunately, migrations like this need to go UNSAFE_componentWillMount. As soon as there's // migration hook for this module.ts, we can do the migrations there instead. if (!this.props.query.hasOwnProperty('metricQuery')) { const { hide, refId, datasource, key, queryType, maxLines, metric, ...metricQuery } = this.props.query as any; diff --git a/public/app/plugins/datasource/graphite/FunctionEditor.tsx b/public/app/plugins/datasource/graphite/FunctionEditor.tsx index 1c07341f0d4..d178904640a 100644 --- a/public/app/plugins/datasource/graphite/FunctionEditor.tsx +++ b/public/app/plugins/datasource/graphite/FunctionEditor.tsx @@ -13,9 +13,9 @@ const FunctionDescription = React.lazy(async () => { // @ts-ignore const { default: rst2html } = await import(/* webpackChunkName: "rst2html" */ 'rst2html'); return { - default: (props: { description?: string }) => ( -
- ), + default(props: { description?: string }) { + return
; + }, }; }); diff --git a/public/app/plugins/datasource/influxdb/components/InfluxCheatSheet.tsx b/public/app/plugins/datasource/influxdb/components/InfluxCheatSheet.tsx index 8c1479f5b2c..8366fae3049 100644 --- a/public/app/plugins/datasource/influxdb/components/InfluxCheatSheet.tsx +++ b/public/app/plugins/datasource/influxdb/components/InfluxCheatSheet.tsx @@ -8,7 +8,7 @@ const CHEAT_SHEET_ITEMS = [ }, ]; -export default (props: any) => ( +const InfluxCheatSheet = (props: any) => (

InfluxDB Cheat Sheet

{CHEAT_SHEET_ITEMS.map(item => ( @@ -19,3 +19,5 @@ export default (props: any) => ( ))}
); + +export default InfluxCheatSheet; diff --git a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx b/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx index a38f0540d30..c114405e8bf 100644 --- a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx +++ b/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx @@ -25,7 +25,7 @@ const CHEAT_SHEET_ITEMS = [ }, ]; -export default (props: ExploreStartPageProps) => ( +const PromCheatSheet = (props: ExploreStartPageProps) => (

PromQL Cheat Sheet

{CHEAT_SHEET_ITEMS.map((item, index) => ( @@ -44,3 +44,5 @@ export default (props: ExploreStartPageProps) => ( ))}
); + +export default PromCheatSheet; diff --git a/public/app/plugins/panel/annolist/module.tsx b/public/app/plugins/panel/annolist/module.tsx index ed6fcbb5f73..451dab488d3 100644 --- a/public/app/plugins/panel/annolist/module.tsx +++ b/public/app/plugins/panel/annolist/module.tsx @@ -60,7 +60,7 @@ export const plugin = new PanelPlugin(AnnoListPanel) path: 'tags', name: 'Tags', description: '', - editor: props => { + editor(props) { return ; }, }) diff --git a/public/app/plugins/panel/dashlist/module.tsx b/public/app/plugins/panel/dashlist/module.tsx index c70e2f2ca51..98f5505450f 100644 --- a/public/app/plugins/panel/dashlist/module.tsx +++ b/public/app/plugins/panel/dashlist/module.tsx @@ -44,7 +44,7 @@ export const plugin = new PanelPlugin(DashList) name: 'Folder', id: 'folderId', defaultValue: null, - editor: props => { + editor: function RenderFolderPicker(props) { return props.onChange(id)} />; }, }) @@ -54,7 +54,7 @@ export const plugin = new PanelPlugin(DashList) name: 'Tags', description: '', defaultValue: [], - editor: props => { + editor(props) { return ; }, }); diff --git a/public/app/routes/ReactContainer.tsx b/public/app/routes/ReactContainer.tsx index 75dc116551f..bf215a1f707 100644 --- a/public/app/routes/ReactContainer.tsx +++ b/public/app/routes/ReactContainer.tsx @@ -22,6 +22,7 @@ export function WrapInProvider(store: any, Component: any, props: any) { } export const provideModalsContext = (component: any) => { + // eslint-disable-next-line react/display-name return (props: any) => ( <>