diff --git a/.betterer.results b/.betterer.results index 556a784b5dd..3204961fbff 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5,14 +5,6 @@ // exports[`better eslint`] = { value: `{ - "e2e/benchmarks/live/4-20hz-panels.spec.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "e2e/panels-suite/panelEdit_queries.spec.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/dataframe/ArrayDataFrame.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -397,9 +389,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "28"], [0, 0, 0, "Unexpected any. Specify a different type.", "29"] ], - "packages/grafana-data/src/types/displayValue.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/types/explore.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -597,26 +586,18 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "87"] ], "packages/grafana-data/src/utils/Registry.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/src/utils/arrayUtils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "packages/grafana-data/src/utils/csv.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], + [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"], - [0, 0, 0, "Unexpected any. Specify a different type.", "8"], - [0, 0, 0, "Unexpected any. Specify a different type.", "9"], - [0, 0, 0, "Do not use any type assertions.", "10"], - [0, 0, 0, "Unexpected any. Specify a different type.", "11"] + [0, 0, 0, "Do not use any type assertions.", "3"], + [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], "packages/grafana-data/src/utils/dataLinks.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -629,16 +610,11 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"] ], "packages/grafana-data/src/utils/fieldParser.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/src/utils/flotPairs.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-data/src/utils/labels.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "packages/grafana-data/src/utils/location.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -647,24 +623,12 @@ exports[`better eslint`] = { ], "packages/grafana-data/src/utils/logs.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"] - ], - "packages/grafana-data/src/utils/makeClassES5Compatible.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/utils/testdata/testTheme.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "packages/grafana-data/src/utils/tests/mockTransformationsRegistry.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/utils/url.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -690,16 +654,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"] ], - "packages/grafana-data/src/valueFormats/arithmeticFormatters.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "packages/grafana-data/src/valueFormats/dateTimeFormatters.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "packages/grafana-data/src/valueFormats/valueFormats.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "packages/grafana-data/src/vector/AppendedVectors.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -725,8 +679,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-data/test/__mocks__/pluginMocks.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-e2e/cypress/plugins/benchmark/formatting.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -1064,8 +1017,7 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] ], "packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-ui/src/components/Forms/FieldArray.story.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -2215,13 +2167,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "85"], [0, 0, 0, "Unexpected any. Specify a different type.", "86"] ], - "public/app/core/components/OptionsUI/string.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], - "public/app/core/components/OptionsUI/strings.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/core/components/PageNew/SectionNavItem.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], @@ -2238,11 +2183,6 @@ exports[`better eslint`] = { "public/app/core/components/Select/FolderPicker.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "public/app/core/components/Select/ReadonlyFolderPicker/api.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], "public/app/core/components/TagFilter/TagFilter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2254,23 +2194,10 @@ exports[`better eslint`] = { ], "public/app/core/components/TagFilter/TagOption.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "public/app/core/components/TimelineChart/TimelineChart.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/core/components/TimelineChart/timeline.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"] - ], - "public/app/core/components/TimelineChart/utils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + "public/app/core/components/TimelineChart/TimelineChart.tsx:5381": [ + [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/core/components/connectWithCleanUp.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2279,9 +2206,6 @@ exports[`better eslint`] = { "public/app/core/components/modals/AngularModalProxy.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/history/richHistoryLocalStorageUtils.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/navigation/GrafanaRoute.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -2292,37 +2216,18 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "public/app/core/navigation/patch/interceptLinkClicks.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "public/app/core/navigation/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/core/profiler.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/reducers/root.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/core/services/FetchQueue.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "public/app/core/services/PreferencesService.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/services/ResponseQueue.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/core/services/__mocks__/search_srv.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/services/backend_srv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2351,9 +2256,7 @@ exports[`better eslint`] = { ], "public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/core/services/echo/backends/analytics/RudderstackBackend.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2465,9 +2368,6 @@ exports[`better eslint`] = { "public/app/core/utils/richHistory.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/utils/richHistory.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/utils/ticks.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2477,9 +2377,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "5"] ], "public/app/core/utils/tracing.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] + [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/features/admin/OrgRolePicker.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -2844,16 +2742,10 @@ exports[`better eslint`] = { ], "public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "7"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "8"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "9"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "10"] + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"] ], "public/app/features/dashboard/components/AnnotationSettings/AnnotationSettingsEdit.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] @@ -2928,19 +2820,16 @@ exports[`better eslint`] = { ], "public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] ], "public/app/features/dashboard/components/PanelEditor/OverrideCategoryTitle.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"] + [0, 0, 0, "Do not use any type assertions.", "3"] ], "public/app/features/dashboard/components/PanelEditor/VisualizationButton.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], @@ -2950,21 +2839,17 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], "public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"] + [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], "public/app/features/dashboard/components/PanelEditor/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/dashboard/components/PanelEditor/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2974,9 +2859,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/SaveDashboard/SaveDashboardButton.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] @@ -3009,21 +2891,9 @@ exports[`better eslint`] = { "public/app/features/dashboard/components/ShareModal/ShareExport.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dashboard/components/ShareModal/ShareModal.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/ShareModal/ShareSnapshot.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/ShareModal/utils.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] - ], "public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], @@ -3054,8 +2924,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/features/dashboard/containers/DashboardPage.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -3334,9 +3203,8 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], "public/app/features/datasources/components/ButtonRow.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] ], "public/app/features/datasources/components/DataSourceReadOnlyMessage.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] @@ -3371,55 +3239,26 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/features/dimensions/color.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dimensions/editors/ColorDimensionEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dimensions/editors/FolderPickerTab.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/dimensions/editors/IconSelector.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dimensions/editors/ResourceDimensionEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/dimensions/editors/ResourcePicker.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dimensions/editors/ScalarDimensionEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/dimensions/editors/ScaleDimensionEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dimensions/editors/TextDimensionEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dimensions/scale.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/dimensions/text.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/dimensions/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -3440,17 +3279,12 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"] ], "public/app/features/explore/LogsContainer.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/explore/LogsMetaRow.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/explore/QueryRows.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "public/app/features/explore/RichHistory/RichHistory.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/explore/TraceView/TraceView.tsx:5381": [ @@ -3461,34 +3295,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Do not use any type assertions.", "5"] ], - "public/app/features/explore/TraceView/components/ScrollManager.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/Scrubber.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/render-into-canvas.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/features/explore/TraceView/components/TraceTimelineViewer/ListView/index.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBar.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/explore/TraceView/components/TraceTimelineViewer/utils.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/explore/TraceView/components/common/BreakableText.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/explore/TraceView/components/constants/index.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "public/app/features/explore/TraceView/components/demo/trace-generators.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -4028,11 +3840,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ], - "public/app/features/runtime/init.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"] - ], "public/app/features/sandbox/TestStuffPage.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -5396,12 +5203,6 @@ exports[`better eslint`] = { "public/app/plugins/datasource/loki/getDerivedFields.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/plugins/datasource/loki/querySplitting.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"] - ], "public/app/plugins/datasource/loki/querybuilder/binaryScalarOperations.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/e2e/benchmarks/live/4-20hz-panels.spec.ts b/e2e/benchmarks/live/4-20hz-panels.spec.ts index 1531d4cc567..67fb90bd07c 100644 --- a/e2e/benchmarks/live/4-20hz-panels.spec.ts +++ b/e2e/benchmarks/live/4-20hz-panels.spec.ts @@ -10,7 +10,7 @@ type WithGrafanaRuntime = T & { }; const hasGrafanaRuntime = (obj: T): obj is WithGrafanaRuntime => { - return typeof (obj as any)?.grafanaRuntime === 'object'; + return 'grafanaRuntime' in obj; }; e2e.benchmark({ diff --git a/e2e/panels-suite/panelEdit_queries.spec.ts b/e2e/panels-suite/panelEdit_queries.spec.ts index 03479c3703a..da1e8ef66b6 100644 --- a/e2e/panels-suite/panelEdit_queries.spec.ts +++ b/e2e/panels-suite/panelEdit_queries.spec.ts @@ -88,14 +88,14 @@ e2e.scenario({ }, }); -const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) => { +const expectInspectorResultAndClose = (expectCallBack: (keys: JQuery) => void) => { e2e.components.QueryTab.queryInspectorButton().should('be.visible').click(); e2e.components.PanelInspector.Query.refreshButton().should('be.visible').click(); e2e.components.PanelInspector.Query.jsonObjectKeys({ timeout: flakyTimeout }) .should('be.visible') - .within((keys: any) => expectCallBack(keys)); + .within((keys) => expectCallBack(keys)); e2e.components.Drawer.General.close().should('be.visible').click(); }; diff --git a/packages/grafana-data/src/field/fieldOverrides.test.ts b/packages/grafana-data/src/field/fieldOverrides.test.ts index 427dd4ead48..bd7f66666ea 100644 --- a/packages/grafana-data/src/field/fieldOverrides.test.ts +++ b/packages/grafana-data/src/field/fieldOverrides.test.ts @@ -640,7 +640,7 @@ describe('getLinksSupplier', () => { }, ], }, - display: (v) => ({ numeric: v, text: String(v) }), + display: (v) => ({ numeric: Number(v), text: String(v) }), }, ], }); diff --git a/packages/grafana-data/src/types/displayValue.ts b/packages/grafana-data/src/types/displayValue.ts index 65cf2230617..a0de2ccc2d6 100644 --- a/packages/grafana-data/src/types/displayValue.ts +++ b/packages/grafana-data/src/types/displayValue.ts @@ -1,6 +1,6 @@ import { FormattedValue } from '../valueFormats'; -export type DisplayProcessor = (value: any, decimals?: DecimalCount) => DisplayValue; +export type DisplayProcessor = (value: unknown, decimals?: DecimalCount) => DisplayValue; export interface DisplayValue extends FormattedValue { /** diff --git a/packages/grafana-data/src/utils/Registry.ts b/packages/grafana-data/src/utils/Registry.ts index 39a168f3375..ba26da74fdc 100644 --- a/packages/grafana-data/src/utils/Registry.ts +++ b/packages/grafana-data/src/utils/Registry.ts @@ -87,10 +87,10 @@ export class Registry { this.initialize(); } - const select = { + const select: RegistrySelectInfo = { options: [], current: [], - } as RegistrySelectInfo; + }; const currentOptions: Record> = {}; if (current) { diff --git a/packages/grafana-data/src/utils/csv.ts b/packages/grafana-data/src/utils/csv.ts index 6ad8c464fc7..28a02cae94b 100644 --- a/packages/grafana-data/src/utils/csv.ts +++ b/packages/grafana-data/src/utils/csv.ts @@ -34,7 +34,7 @@ export interface CSVParseCallbacks { onHeader: (fields: Field[]) => void; // Called after each row is read - onRow: (row: any[]) => void; + onRow: (row: string[]) => void; } export interface CSVOptions { @@ -73,9 +73,9 @@ export class CSVReader { } // PapaParse callback on each line - private chunk = (results: ParseResult, parser: Parser): void => { + private chunk = (results: ParseResult, parser: Parser): void => { for (let i = 0; i < results.data.length; i++) { - const line: string[] = results.data[i]; + const line = results.data[i]; if (line.length < 1) { continue; } @@ -191,15 +191,18 @@ export class CSVReader { } } -type FieldWriter = (value: any) => string; +type FieldWriter = (value: unknown) => string; -function writeValue(value: any, config: CSVConfig): string { +function writeValue(value: unknown, config: CSVConfig): string { + if (value === null || value === undefined) { + return ''; + } const str = value.toString(); if (str.includes('"')) { // Escape the double quote characters return config.quoteChar + str.replace(/"/gi, '""') + config.quoteChar; } - if (str.includes('\n') || str.includes(config.delimiter)) { + if (str.includes('\n') || (config.delimiter && str.includes(config.delimiter))) { return config.quoteChar + str + config.quoteChar; } return str; @@ -207,13 +210,13 @@ function writeValue(value: any, config: CSVConfig): string { function makeFieldWriter(field: Field, config: CSVConfig): FieldWriter { if (field.display) { - return (value: any) => { + return (value: unknown) => { const displayValue = field.display!(value); return writeValue(formattedValueToString(displayValue), config); }; } - return (value: any) => writeValue(value, config); + return (value: unknown) => writeValue(value, config); } function getHeaderLine(key: string, fields: Field[], config: CSVConfig): string { @@ -229,7 +232,7 @@ function getHeaderLine(key: string, fields: Field[], config: CSVConfig): string line = line + config.delimiter; } - let v: any = fields[i].name; + let v = fields[i].name; if (isType) { v = fields[i].type; } else if (isName) { diff --git a/packages/grafana-data/src/utils/fieldParser.ts b/packages/grafana-data/src/utils/fieldParser.ts index 1763cef86ac..fd1b07ec519 100644 --- a/packages/grafana-data/src/utils/fieldParser.ts +++ b/packages/grafana-data/src/utils/fieldParser.ts @@ -1,7 +1,7 @@ import { guessFieldTypeFromValue } from '../dataframe/processDataFrame'; import { Field, FieldType } from '../types/dataFrame'; -export function makeFieldParser(value: any, field: Field): (value: string) => any { +export function makeFieldParser(value: unknown, field: Field): (value: string) => any { if (!field.type) { if (field.name === 'time' || field.name === 'Time') { field.type = FieldType.time; diff --git a/packages/grafana-data/src/utils/labels.ts b/packages/grafana-data/src/utils/labels.ts index 7ffc8fed750..e4c9709587f 100644 --- a/packages/grafana-data/src/utils/labels.ts +++ b/packages/grafana-data/src/utils/labels.ts @@ -23,14 +23,11 @@ export function parseLabels(labels: string): Labels { * Returns a map labels that are common to the given label sets. */ export function findCommonLabels(labelsSets: Labels[]): Labels { - return labelsSets.reduce((acc, labels) => { - if (!labels) { - throw new Error('Need parsed labels to find common labels.'); - } - if (!acc) { - // Initial set - acc = { ...labels }; - } else { + return labelsSets.reduce( + (acc, labels) => { + if (!labels) { + throw new Error('Need parsed labels to find common labels.'); + } // Remove incoming labels that are missing or not matching in value Object.keys(labels).forEach((key) => { if (acc[key] === undefined || acc[key] !== labels[key]) { @@ -43,9 +40,10 @@ export function findCommonLabels(labelsSets: Labels[]): Labels { delete acc[key]; } }); - } - return acc; - }, undefined as unknown as Labels); + return acc; + }, + { ...labelsSets[0] } + ); } /** diff --git a/packages/grafana-data/src/utils/logs.ts b/packages/grafana-data/src/utils/logs.ts index 93993a0178e..e9ec99fb66c 100644 --- a/packages/grafana-data/src/utils/logs.ts +++ b/packages/grafana-data/src/utils/logs.ts @@ -30,7 +30,7 @@ export function getLogLevel(line: string): LogLevel { if (result) { if (currentIndex === undefined || result.index < currentIndex) { - level = (LogLevel as any)[key]; + level = LogLevel[key as keyof typeof LogLevel]; currentIndex = result.index; } } @@ -40,7 +40,7 @@ export function getLogLevel(line: string): LogLevel { /** @deprecated will be removed in the next major version */ export function getLogLevelFromKey(key: string | number): LogLevel { - const level = (LogLevel as any)[key.toString().toLowerCase()]; + const level = LogLevel[key.toString().toLowerCase() as keyof typeof LogLevel]; if (level) { return level; } @@ -136,7 +136,7 @@ export function calculateLogsLabelStats(rows: LogRowModel[], label: string): Log const rowCount = rowsWithLabel.length; // Get label value counts for eligible rows - const countsByValue = countBy(rowsWithLabel, (row) => (row as LogRowModel).labels[label]); + const countsByValue = countBy(rowsWithLabel, (row) => row.labels[label]); return getSortedCounts(countsByValue, rowCount); } diff --git a/packages/grafana-data/src/utils/makeClassES5Compatible.ts b/packages/grafana-data/src/utils/makeClassES5Compatible.ts index 619f7ce409d..b7a20ace51c 100644 --- a/packages/grafana-data/src/utils/makeClassES5Compatible.ts +++ b/packages/grafana-data/src/utils/makeClassES5Compatible.ts @@ -2,8 +2,10 @@ * @beta * Proxies a ES6 class so that it can be used as a base class for an ES5 class */ -export function makeClassES5Compatible(ES6Class: T): T { - return new Proxy(ES6Class as any, { +export function makeClassES5Compatible) => InstanceType>( + ES6Class: T +): T { + return new Proxy(ES6Class, { // ES5 code will call it like a function using super apply(target, self, argumentsList) { if (typeof Reflect === 'undefined' || !Reflect.construct) { @@ -12,5 +14,5 @@ export function makeClassES5Compatible(ES6Class: T): T { return Reflect.construct(target, argumentsList, self.constructor); }, - }) as unknown as T; + }); } diff --git a/packages/grafana-data/src/utils/tests/mockTransformationsRegistry.ts b/packages/grafana-data/src/utils/tests/mockTransformationsRegistry.ts index 52ddc964cc9..51aeb74eafa 100644 --- a/packages/grafana-data/src/utils/tests/mockTransformationsRegistry.ts +++ b/packages/grafana-data/src/utils/tests/mockTransformationsRegistry.ts @@ -1,7 +1,7 @@ import { standardTransformersRegistry } from '../../transformations'; import { DataTransformerInfo } from '../../types'; -export const mockTransformationsRegistry = (transformers: Array>) => { +export const mockTransformationsRegistry = (transformers: DataTransformerInfo[]) => { standardTransformersRegistry.setInit(() => { return transformers.map((t) => { return { diff --git a/packages/grafana-data/src/valueFormats/arithmeticFormatters.ts b/packages/grafana-data/src/valueFormats/arithmeticFormatters.ts index 33e6856d140..6d404079755 100644 --- a/packages/grafana-data/src/valueFormats/arithmeticFormatters.ts +++ b/packages/grafana-data/src/valueFormats/arithmeticFormatters.ts @@ -42,5 +42,5 @@ export function sci(value: number | null, decimals: DecimalCount): FormattedValu if (value == null) { return { text: '' }; } - return { text: value.toExponential(decimals as number) }; + return { text: value.toExponential(decimals ?? undefined) }; } diff --git a/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts b/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts index 408f85c5e73..fe230f5023b 100644 --- a/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts +++ b/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts @@ -228,7 +228,7 @@ export function toDuration(size: number, decimals: DecimalCount, timeScale: Inte let decimalsCount = 0; if (decimals !== null && decimals !== undefined) { - decimalsCount = decimals as number; + decimalsCount = decimals; } for (let i = 0; i < UNITS.length && decimalsCount >= 0; i++) { diff --git a/packages/grafana-data/src/valueFormats/valueFormats.ts b/packages/grafana-data/src/valueFormats/valueFormats.ts index 5b534972019..f8753bad0e2 100644 --- a/packages/grafana-data/src/valueFormats/valueFormats.ts +++ b/packages/grafana-data/src/valueFormats/valueFormats.ts @@ -127,7 +127,7 @@ export function isBooleanUnit(unit?: string) { } export function booleanValueFormatter(t: string, f: string): ValueFormatter { - return (value: any) => { + return (value) => { return { text: value ? t : f }; }; } @@ -159,7 +159,7 @@ export function locale(value: number, decimals: DecimalCount): FormattedValue { return { text: '' }; } return { - text: value.toLocaleString(undefined, { maximumFractionDigits: decimals as number }), + text: value.toLocaleString(undefined, { maximumFractionDigits: decimals ?? undefined }), }; } diff --git a/packages/grafana-data/test/__mocks__/pluginMocks.ts b/packages/grafana-data/test/__mocks__/pluginMocks.ts index dcf80d0a589..de8b7fe7a50 100644 --- a/packages/grafana-data/test/__mocks__/pluginMocks.ts +++ b/packages/grafana-data/test/__mocks__/pluginMocks.ts @@ -34,7 +34,7 @@ export const getMockPlugins = (amount: number): PluginMeta[] => { }); } - return plugins as any; + return plugins; }; export function getPanelPlugin( diff --git a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx index d16d590b01b..4341e4251b3 100644 --- a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx +++ b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx @@ -68,7 +68,7 @@ const ButtonSelectComponent = (props: Props) => { {options.map((item) => ( onChangeInternal(item)} active={item.value === value?.value} ariaChecked={item.value === value?.value} diff --git a/packages/grafana-ui/src/components/Graph/Graph.test.tsx b/packages/grafana-ui/src/components/Graph/Graph.test.tsx index 36183bba34c..d9e8445d91c 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.test.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.test.tsx @@ -9,7 +9,7 @@ import { VizTooltip } from '../VizTooltip'; import Graph from './Graph'; -const display: DisplayProcessor = (v) => ({ numeric: v, text: String(v), color: 'red' }); +const display: DisplayProcessor = (v) => ({ numeric: Number(v), text: String(v), color: 'red' }); const series: GraphSeriesXY[] = [ { diff --git a/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.test.tsx b/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.test.tsx index 5c550a6590b..6759fed7a46 100644 --- a/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.test.tsx +++ b/packages/grafana-ui/src/components/Graph/GraphTooltip/MultiModeGraphTooltip.test.tsx @@ -11,7 +11,7 @@ import { GraphDimensions } from './types'; let dimensions: GraphDimensions; describe('MultiModeGraphTooltip', () => { - const display: DisplayProcessor = (v) => ({ numeric: v, text: String(v), color: 'red' }); + const display: DisplayProcessor = (v) => ({ numeric: Number(v), text: String(v), color: 'red' }); const theme = createTheme(); describe('when shown when hovering over a datapoint', () => { diff --git a/packages/grafana-ui/src/components/Icon/iconBundle.ts b/packages/grafana-ui/src/components/Icon/iconBundle.ts index 7e1bc30a5a4..cb9a81c0a85 100644 --- a/packages/grafana-ui/src/components/Icon/iconBundle.ts +++ b/packages/grafana-ui/src/components/Icon/iconBundle.ts @@ -187,7 +187,7 @@ export function initIconCache() { // This function needs to be called after index.js loads to give the // application time to modify __webpack_public_path__ with a CDN path - const grafanaPublicPath = typeof window !== 'undefined' && (window as any).__grafana_public_path__; + const grafanaPublicPath = typeof window !== 'undefined' && window.__grafana_public_path__; if (grafanaPublicPath) { iconRoot = grafanaPublicPath + 'img/icons/'; } diff --git a/packages/grafana-ui/src/components/Icon/iconBundle.ts.template b/packages/grafana-ui/src/components/Icon/iconBundle.ts.template index 947387ba9cc..db75ce7d011 100644 --- a/packages/grafana-ui/src/components/Icon/iconBundle.ts.template +++ b/packages/grafana-ui/src/components/Icon/iconBundle.ts.template @@ -24,14 +24,14 @@ export function initIconCache() { // This function needs to be called after index.js loads to give the // application time to modify __webpack_public_path__ with a CDN path - const grafanaPublicPath = typeof window !== 'undefined' && (window as any).__grafana_public_path__; + const grafanaPublicPath = typeof window !== 'undefined' && window.__grafana_public_path__; if (grafanaPublicPath) { iconRoot = grafanaPublicPath + 'img/icons/'; } -// do not edit this list directly -// the list of icons live here: @grafana/ui/components/Icon/cached.json + // do not edit this list directly + // the list of icons live here: @grafana/ui/components/Icon/cached.json //{{cacheItems}} -// do not edit this list directly -// the list of icons live here: @grafana/ui/components/Icon/cached.json + // do not edit this list directly + // the list of icons live here: @grafana/ui/components/Icon/cached.json } diff --git a/packages/grafana-ui/src/components/Table/utils.ts b/packages/grafana-ui/src/components/Table/utils.ts index 051da3e546f..2ba85252a12 100644 --- a/packages/grafana-ui/src/components/Table/utils.ts +++ b/packages/grafana-ui/src/components/Table/utils.ts @@ -166,7 +166,7 @@ export function getColumns( } /* - Build `Field` data for row numbers and prepend to the field array; + Build `Field` data for row numbers and prepend to the field array; this way, on other column's sort, the row numbers will persist in their proper place. */ export function buildFieldsForOptionalRowNums(totalRows: number): Field { @@ -339,12 +339,12 @@ export function getFooterItems( theme2: GrafanaTheme2 ): FooterItem[] { /* - Here, `filterFields` is passed as the `headerGroups[0].headers` array - that was destructured from the `useTable` hook. Unfortunately, since - the `headerGroups` object is data based ONLY on the rendered "non-hidden" - column headers, it will NOT include the Row Number column if it has been + Here, `filterFields` is passed as the `headerGroups[0].headers` array + that was destructured from the `useTable` hook. Unfortunately, since + the `headerGroups` object is data based ONLY on the rendered "non-hidden" + column headers, it will NOT include the Row Number column if it has been toggled off. This will shift the rendering of the footer left 1 column, - creating an off-by-one issue. This is why we test for a `field.id` of "0". + creating an off-by-one issue. This is why we test for a `field.id` of "0". If the condition is truthy, the togglable Row Number column is being rendered, and we can proceed normally. If not, we must add the field data in its place so that the footer data renders in the expected column. @@ -356,26 +356,26 @@ export function getFooterItems( filterFields = [fieldToAdd, ...filterFields]; } - /* - The FooterItems[] are calculated using both the `headerGroups[0].headers` + /* + The FooterItems[] are calculated using both the `headerGroups[0].headers` (filterFields) and `rows` (values) destructured from the useTable() hook. - This cacluation is based on the data from each index in `filterFields` - array as well as the corresponding index in the `values` array. - When the user hides a column through an override, the getColumns() - hook is invoked, removes said hidden column, sends the updated column - data to the useTable() hook, which then builds `headerGroups[0].headers` - without the hidden column. However, it doesn't remove the hidden column - from the `row` data, instead it substututes the hidden column row data - with an `undefined` value. Therefore, the `row` array length never changes, - despite the `headerGroups[0].headers` length changing at every column removal. - This makes all footer reduce calculations AFTER the first hidden column - in the `headerGroups[0].headers` break, since the indexing of both + This cacluation is based on the data from each index in `filterFields` + array as well as the corresponding index in the `values` array. + When the user hides a column through an override, the getColumns() + hook is invoked, removes said hidden column, sends the updated column + data to the useTable() hook, which then builds `headerGroups[0].headers` + without the hidden column. However, it doesn't remove the hidden column + from the `row` data, instead it substututes the hidden column row data + with an `undefined` value. Therefore, the `row` array length never changes, + despite the `headerGroups[0].headers` length changing at every column removal. + This makes all footer reduce calculations AFTER the first hidden column + in the `headerGroups[0].headers` break, since the indexing of both arrays is no longer in parity. - So, here we simply recursively test for the "hidden" columns - from `headerGroups[0].headers`. Each column has an ID property that corresponds - to its own index, therefore if (`filterField.id` !== `String(index)`), - we know there is one or more hidden columns; at which point we update + So, here we simply recursively test for the "hidden" columns + from `headerGroups[0].headers`. Each column has an ID property that corresponds + to its own index, therefore if (`filterField.id` !== `String(index)`), + we know there is one or more hidden columns; at which point we update the index with an ersatz placeholder with just an `id` property. */ addMissingColumnIndex(filterFields); @@ -499,15 +499,15 @@ export function migrateTableDisplayModeToCellOptions(displayMode: TableCellDispl `values` property is omitted, as it will be added at a later time. */ export const defaultRowNumberColumnFieldData: Omit = { - /* + /* Single whitespace as value for `name` property so as to render an empty/invisible column header; without the single whitespace, falsey headers (empty strings) are given a default name of "Value". */ name: ' ', - display: function (value: string) { + display: function (value) { return { numeric: Number(value), - text: value, + text: value != null ? String(value) : '', }; }, type: FieldType.string, diff --git a/public/app/core/components/OptionsUI/string.tsx b/public/app/core/components/OptionsUI/string.tsx index 82436b3460d..ef60d91d0ab 100644 --- a/public/app/core/components/OptionsUI/string.tsx +++ b/public/app/core/components/OptionsUI/string.tsx @@ -10,18 +10,20 @@ interface Props extends StandardEditorProps { export const StringValueEditor = ({ value, onChange, item, suffix }: Props) => { const Component = item.settings?.useTextarea ? TextArea : Input; const onValueChange = useCallback( - (e: React.SyntheticEvent) => { + ( + e: + | React.KeyboardEvent + | React.FocusEvent + ) => { let nextValue = value ?? ''; - if (e.hasOwnProperty('key')) { + if ('key' in e) { // handling keyboard event - const evt = e as React.KeyboardEvent; - if (evt.key === 'Enter' && !item.settings?.useTextarea) { - nextValue = evt.currentTarget.value.trim(); + if (e.key === 'Enter' && !item.settings?.useTextarea) { + nextValue = e.currentTarget.value.trim(); } } else { - // handling form event - const evt = e as React.FormEvent; - nextValue = evt.currentTarget.value.trim(); + // handling blur event + nextValue = e.currentTarget.value.trim(); } if (nextValue === value) { return; // no change diff --git a/public/app/core/components/OptionsUI/strings.tsx b/public/app/core/components/OptionsUI/strings.tsx index 4fd2aa2da81..603cf776459 100644 --- a/public/app/core/components/OptionsUI/strings.tsx +++ b/public/app/core/components/OptionsUI/strings.tsx @@ -22,20 +22,19 @@ export class StringArrayEditor extends React.PureComponent { onChange(copy); }; - onValueChange = (e: React.SyntheticEvent, idx: number) => { - const evt = e as React.KeyboardEvent; - if (e.hasOwnProperty('key')) { - if (evt.key !== 'Enter') { + onValueChange = (e: React.KeyboardEvent | React.FocusEvent, idx: number) => { + if ('key' in e) { + if (e.key !== 'Enter') { return; } } const { value, onChange } = this.props; // Form event, or Enter - const v = evt.currentTarget.value.trim(); + const v = e.currentTarget.value.trim(); if (idx < 0) { if (v) { - evt.currentTarget.value = ''; // reset last value + e.currentTarget.value = ''; // reset last value onChange([...value, v]); } this.setState({ showAdd: false }); diff --git a/public/app/core/components/Select/ReadonlyFolderPicker/api.test.ts b/public/app/core/components/Select/ReadonlyFolderPicker/api.test.ts index 46ab7d3adb8..77ed9b7a26d 100644 --- a/public/app/core/components/Select/ReadonlyFolderPicker/api.test.ts +++ b/public/app/core/components/Select/ReadonlyFolderPicker/api.test.ts @@ -31,7 +31,7 @@ describe('getFoldersAsOptions', () => { describe('and extra folders are passed', () => { it('then extra folders should all appear first in the result', async () => { const args = { query: '', extraFolders: [ALL_FOLDER, GENERAL_FOLDER] }; - const searchHits: any[] = [{ id: 1, title: 'Folder 1' }]; + const searchHits = [{ id: 1, title: 'Folder 1' }] as DashboardSearchHit[]; getTestContext(searchHits); const result = await getFoldersAsOptions(args); @@ -57,7 +57,7 @@ describe('getFoldersAsOptions', () => { describe('and extra folders are passed and extra folders contain query', () => { it('then correct extra folders should all appear first in the result', async () => { const args = { query: 'er', extraFolders: [ALL_FOLDER, GENERAL_FOLDER] }; - const searchHits: any[] = [{ id: 1, title: 'Folder 1' }]; + const searchHits = [{ id: 1, title: 'Folder 1' }] as DashboardSearchHit[]; getTestContext(searchHits); const result = await getFoldersAsOptions(args); @@ -71,7 +71,7 @@ describe('getFoldersAsOptions', () => { describe('and extra folders are passed and extra folders do not contain query', () => { it('then no extra folders should appear first in the result', async () => { const args = { query: '1', extraFolders: [ALL_FOLDER, GENERAL_FOLDER] }; - const searchHits: any[] = [{ id: 1, title: 'Folder 1' }]; + const searchHits = [{ id: 1, title: 'Folder 1' }] as DashboardSearchHit[]; getTestContext(searchHits); const result = await getFoldersAsOptions(args); diff --git a/public/app/core/components/TagFilter/TagOption.tsx b/public/app/core/components/TagFilter/TagOption.tsx index 77b7b83cc6a..fab2dff7cb8 100644 --- a/public/app/core/components/TagFilter/TagOption.tsx +++ b/public/app/core/components/TagFilter/TagOption.tsx @@ -7,12 +7,7 @@ import { useStyles2 } from '@grafana/ui'; import { TagBadge } from './TagBadge'; -// https://github.com/JedWatson/react-select/issues/3038 -interface ExtendedOptionProps extends OptionProps { - data: any; -} - -export const TagOption = ({ data, className, label, isFocused, innerProps }: ExtendedOptionProps) => { +export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps) => { const styles = useStyles2(getStyles); return ( diff --git a/public/app/core/components/TimelineChart/TimelineChart.tsx b/public/app/core/components/TimelineChart/TimelineChart.tsx index 9126adaea70..f10b6825d61 100644 --- a/public/app/core/components/TimelineChart/TimelineChart.tsx +++ b/public/app/core/components/TimelineChart/TimelineChart.tsx @@ -33,7 +33,7 @@ export class TimelineChart extends React.Component { static contextType = PanelContextRoot; panelContext: PanelContext = {} as PanelContext; - getValueColor = (frameIdx: number, fieldIdx: number, value: any) => { + getValueColor = (frameIdx: number, fieldIdx: number, value: unknown) => { const field = this.props.frames[frameIdx].fields[fieldIdx]; if (field.display) { diff --git a/public/app/core/components/TimelineChart/timeline.ts b/public/app/core/components/TimelineChart/timeline.ts index e6f968fcd39..bfad801275f 100644 --- a/public/app/core/components/TimelineChart/timeline.ts +++ b/public/app/core/components/TimelineChart/timeline.ts @@ -47,10 +47,10 @@ export interface TimelineCoreOptions { showValue: VisibilityMode; mergeValues?: boolean; isDiscrete: (seriesIdx: number) => boolean; - getValueColor: (seriesIdx: number, value: any) => string; + getValueColor: (seriesIdx: number, value: unknown) => string; label: (seriesIdx: number) => string; getTimeRange: () => TimeRange; - formatValue?: (seriesIdx: number, value: any) => string; + formatValue?: (seriesIdx: number, value: unknown) => string; getFieldConfig: (seriesIdx: number) => StateTimeLineFieldConfig | StatusHistoryFieldConfig; onHover: (seriesIdx: number, valueIdx: number, rect: Rect) => void; onLeave: () => void; @@ -137,7 +137,7 @@ export function getConfig(opts: TimelineCoreOptions) { strokeWidth: number, seriesIdx: number, valueIdx: number, - value: any, + value: number | null, discrete: boolean ) { // do not render super small boxes @@ -497,6 +497,7 @@ export function getConfig(opts: TimelineCoreOptions) { const yMids: number[] = Array(numSeries).fill(0); const ySplits: number[] = Array(numSeries).fill(0); + const yRange: uPlot.Range.MinMax = [0, 1]; return { cursor, @@ -542,7 +543,8 @@ export function getConfig(opts: TimelineCoreOptions) { } } - return [min, max] as uPlot.Range.MinMax; + const result: uPlot.Range.MinMax = [min, max]; + return result; }, ySplits: (u: uPlot) => { @@ -556,7 +558,7 @@ export function getConfig(opts: TimelineCoreOptions) { }, yValues: (u: uPlot, splits: number[]) => splits.map((v, i) => label(i + 1)), - yRange: [0, 1] as uPlot.Range.MinMax, + yRange, // pathbuilders drawPaths, diff --git a/public/app/core/components/TimelineChart/utils.ts b/public/app/core/components/TimelineChart/utils.ts index d13700390e6..861be4f3985 100644 --- a/public/app/core/components/TimelineChart/utils.ts +++ b/public/app/core/components/TimelineChart/utils.ts @@ -60,7 +60,7 @@ interface UPlotConfigOptions { showValue: VisibilityMode; alignValue?: TimelineValueAlignment; mergeValues?: boolean; - getValueColor: (frameIdx: number, fieldIdx: number, value: any) => string; + getValueColor: (frameIdx: number, fieldIdx: number, value: unknown) => string; } /** @@ -113,7 +113,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn = ( return !(mode && field.display && mode.startsWith('continuous-')); }; - const getValueColorFn = (seriesIdx: number, value: any) => { + const getValueColorFn = (seriesIdx: number, value: unknown) => { const field = frame.fields[seriesIdx]; if ( @@ -404,9 +404,9 @@ export function mergeThresholdValues(field: Field, theme: GrafanaTheme2): Field }, type: FieldType.string, values: new ArrayVector(vals), - display: (value: string) => ({ - text: value, - color: textToColor.get(value), + display: (value) => ({ + text: String(value), + color: textToColor.get(String(value)), numeric: NaN, }), }; diff --git a/public/app/core/history/richHistoryLocalStorageUtils.ts b/public/app/core/history/richHistoryLocalStorageUtils.ts index 2d68dce099b..3803f201169 100644 --- a/public/app/core/history/richHistoryLocalStorageUtils.ts +++ b/public/app/core/history/richHistoryLocalStorageUtils.ts @@ -57,7 +57,7 @@ function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchFilter: const listOfMatchingQueries = query.queries.filter((query) => // Remove fields in which we don't want to be searching - Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value: any) => + Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value) => value?.toString().includes(searchFilter) ) ); diff --git a/public/app/core/navigation/patch/interceptLinkClicks.ts b/public/app/core/navigation/patch/interceptLinkClicks.ts index 95cefccc6a4..623df472362 100644 --- a/public/app/core/navigation/patch/interceptLinkClicks.ts +++ b/public/app/core/navigation/patch/interceptLinkClicks.ts @@ -3,7 +3,7 @@ import { locationService, navigationLogger } from '@grafana/runtime'; import { config } from 'app/core/config'; export function interceptLinkClicks(e: MouseEvent) { - const anchor = getParentAnchor(e.target as HTMLElement); + const anchor = e.target instanceof HTMLElement ? getParentAnchor(e.target) : null; // Ignore if opening new tab or already default prevented if (e.ctrlKey || e.metaKey || e.defaultPrevented) { @@ -48,7 +48,7 @@ function getParentAnchor(element: HTMLElement | null): HTMLElement | null { if (element.tagName.toUpperCase() === 'A') { return element; } - element = element.parentNode as HTMLElement; + element = element.parentElement; } return null; diff --git a/public/app/core/profiler.ts b/public/app/core/profiler.ts index a83be82c536..b9dbc852f65 100644 --- a/public/app/core/profiler.ts +++ b/public/app/core/profiler.ts @@ -1,3 +1,9 @@ +declare global { + interface Window { + panelsRendered?: number; + } +} + export class Profiler { panelsRendered = 0; enabled?: boolean = undefined; @@ -9,7 +15,7 @@ export class Profiler { // this window variable is used by backend rendering tools to know // all panels have completed rendering - (window as any).panelsRendered = this.panelsRendered; + window.panelsRendered = this.panelsRendered; } } diff --git a/public/app/core/services/FetchQueue.ts b/public/app/core/services/FetchQueue.ts index d72b98d6143..9915b197042 100644 --- a/public/app/core/services/FetchQueue.ts +++ b/public/app/core/services/FetchQueue.ts @@ -35,7 +35,7 @@ export class FetchQueue { const { id, state, options } = entry; if (!this.state[id]) { - this.state[id] = { state: FetchStatus.Pending, options: {} as BackendSrvRequest }; + this.state[id] = { state: FetchStatus.Pending, options: { url: '' } }; } if (state === FetchStatus.Done) { diff --git a/public/app/core/services/PreferencesService.ts b/public/app/core/services/PreferencesService.ts index ea636f7daea..22b187e6c03 100644 --- a/public/app/core/services/PreferencesService.ts +++ b/public/app/core/services/PreferencesService.ts @@ -8,14 +8,14 @@ export class PreferencesService { /** * Overrides all preferences */ - update(preferences: UserPreferencesDTO): Promise { + update(preferences: UserPreferencesDTO) { return backendSrv.put(`/api/${this.resourceUri}/preferences`, preferences); } /** * Updates only provided preferences */ - patch(preferences: Partial): Promise { + patch(preferences: Partial) { return backendSrv.patch(`/api/${this.resourceUri}/preferences`, preferences); } diff --git a/public/app/core/services/__mocks__/search_srv.ts b/public/app/core/services/__mocks__/search_srv.ts index 6c6c60b47f6..491e53b69c4 100644 --- a/public/app/core/services/__mocks__/search_srv.ts +++ b/public/app/core/services/__mocks__/search_srv.ts @@ -1,4 +1,4 @@ -export const mockSearch = jest.fn(() => { +export const mockSearch = jest.fn(() => { return Promise.resolve([]); }); diff --git a/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts b/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts index e822c65d9db..433d4582aff 100644 --- a/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts +++ b/public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts @@ -41,7 +41,7 @@ export class ApplicationInsightsBackend implements EchoBackend { const init = new (window as any).Microsoft.ApplicationInsights.ApplicationInsights(applicationInsightsOpts); - (window as any).applicationInsights = init.loadAppInsights(); + window.applicationInsights = init.loadAppInsights(); }); } diff --git a/public/app/core/utils/richHistory.ts b/public/app/core/utils/richHistory.ts index 6feb06819b7..0e6a8f28b18 100644 --- a/public/app/core/utils/richHistory.ts +++ b/public/app/core/utils/richHistory.ts @@ -243,7 +243,7 @@ export function createQueryText(query: DataQuery, dsApi?: DataSourceApi) { } export function mapQueriesToHeadings(query: RichHistoryQuery[], sortOrder: SortOrder) { - let mappedQueriesToHeadings: any = {}; + let mappedQueriesToHeadings: Record = {}; query.forEach((q) => { let heading = createQueryHeading(q, sortOrder); diff --git a/public/app/core/utils/tracing.ts b/public/app/core/utils/tracing.ts index 63f2f1d83cd..c0e94787628 100644 --- a/public/app/core/utils/tracing.ts +++ b/public/app/core/utils/tracing.ts @@ -5,7 +5,7 @@ import { FieldType, MutableDataFrame, NodeGraphDataFrameFieldNames as Fields } f export function getNonOverlappingDuration(ranges: Array<[number, number]>): number { ranges.sort((a, b) => a[0] - b[0]); - const mergedRanges = ranges.reduce((acc, range) => { + const mergedRanges = ranges.reduce>((acc, range) => { if (!acc.length) { return [range]; } @@ -23,8 +23,8 @@ export function getNonOverlappingDuration(ranges: Array<[number, number]>): numb } // We know there is overlap and current range ends later than previous so we can just extend the range - return [...acc.slice(0, -1), [prevStart, end]] as Array<[number, number]>; - }, [] as Array<[number, number]>); + return [...acc.slice(0, -1), [prevStart, end]]; + }, []); return mergedRanges.reduce((acc, range) => { return acc + (range[1] - range[0]); diff --git a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx index b88b3d683a6..6ec2c6552c9 100644 --- a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx +++ b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx @@ -21,7 +21,7 @@ import { import { LibraryElementDTO } from '../../../library-panels/types'; import { DashboardModel, PanelModel } from '../../state'; -export type PanelPluginInfo = { id: any; defaults: { gridPos: { w: any; h: any }; title: any } }; +export type PanelPluginInfo = { id: number; defaults: { gridPos: { w: number; h: number }; title: string } }; export interface OwnProps { panel: PanelModel; @@ -88,7 +88,7 @@ export const AddPanelWidgetUnconnected = ({ panel, dashboard }: Props) => { const onPasteCopiedPanel = (panelPluginInfo: PanelPluginInfo) => { const { gridPos } = panel; - const newPanel: any = { + const newPanel = { type: panelPluginInfo.id, title: 'Panel Title', gridPos: { @@ -124,7 +124,7 @@ export const AddPanelWidgetUnconnected = ({ panel, dashboard }: Props) => { }; const onCreateNewRow = () => { - const newRow: any = { + const newRow = { type: 'row', title: 'Row title', gridPos: { x: 0, y: 0 }, diff --git a/public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx b/public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx index 80f39987675..aa0c4fb63ae 100644 --- a/public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx @@ -13,7 +13,7 @@ export interface OptionsPaneItemProps { value?: any; description?: string; popularRank?: number; - render: () => React.ReactNode; + render: () => React.ReactElement; skipField?: boolean; showIf?: () => boolean; overrides?: OptionPaneItemOverrideInfo[]; @@ -94,7 +94,7 @@ export class OptionsPaneItemDescriptor { key={key} aria-label={selectors.components.PanelEditor.OptionsPane.fieldLabel(key)} > - {render() as React.ReactElement} + {render()} ); } diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx index f6ba01a7ede..ee23bce4524 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx @@ -167,13 +167,13 @@ export class PanelEditorUnconnected extends PureComponent { }); }; - onPanelOptionsChanged = (options: any) => { + onPanelOptionsChanged = (options: PanelModel['options']) => { // we do not need to trigger force update here as the function call below // fires PanelOptionsChangedEvent which we subscribe to above this.props.panel.updateOptions(options); }; - onPanelConfigChanged = (configKey: keyof PanelModel, value: any) => { + onPanelConfigChanged = (configKey: keyof PanelModel, value: unknown) => { this.props.panel.setProperty(configKey, value); this.props.panel.render(); this.forceUpdate(); diff --git a/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx b/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx index 93b40a518f5..b4c63f426f9 100644 --- a/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx +++ b/public/app/features/dashboard/components/PanelEditor/getFieldOverrideElements.tsx @@ -155,7 +155,7 @@ export function getFieldOverrideCategories( continue; } - const onPropertyChange = (value: any) => { + const onPropertyChange = (value: DynamicConfigValue) => { override.properties[propIdx].value = value; onOverrideChange(idx, override); }; diff --git a/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx b/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx index 5301e05c07f..49a86abe58f 100644 --- a/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx +++ b/public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx @@ -82,8 +82,8 @@ export function getVisualizationOptions(props: OptionPaneRenderProps): OptionsPa }; const access: NestedValueAccess = { - getValue: (path: string) => lodashGet(currentOptions, path), - onChange: (path: string, value: any) => { + getValue: (path) => lodashGet(currentOptions, path), + onChange: (path, value) => { const newOptions = setOptionImmutably(currentOptions, path, value); onPanelOptionsChanged(newOptions); }, diff --git a/public/app/features/dashboard/components/PanelEditor/types.ts b/public/app/features/dashboard/components/PanelEditor/types.ts index 39d8f6409bd..9de5e5fba73 100644 --- a/public/app/features/dashboard/components/PanelEditor/types.ts +++ b/public/app/features/dashboard/components/PanelEditor/types.ts @@ -56,8 +56,8 @@ export interface OptionPaneRenderProps { data?: PanelData; dashboard: DashboardModel; instanceState: any; - onPanelConfigChange: (configKey: keyof PanelModel, value: any) => void; - onPanelOptionsChanged: (options: any) => void; + onPanelConfigChange: (configKey: keyof PanelModel, value: unknown) => void; + onPanelOptionsChanged: (options: PanelModel['options']) => void; onFieldConfigsChange: (config: FieldConfigSource) => void; } diff --git a/public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx b/public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx index 208732b6508..129613330f7 100644 --- a/public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx +++ b/public/app/features/dashboard/components/RepeatRowSelect/RepeatRowSelect.tsx @@ -18,7 +18,7 @@ export const RepeatRowSelect: FC = ({ repeat, onChange, id }) => { }); const variableOptions = useMemo(() => { - const options = variables.map((item: any) => { + const options: Array> = variables.map((item) => { return { label: item.name, value: item.name }; }); diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx index 71a9c3c0f0c..c1cd7654610 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx @@ -43,16 +43,6 @@ function mockLocationHref(href: string) { }; } -function setUTCTimeZone() { - (window as any).Intl.DateTimeFormat = () => { - return { - resolvedOptions: () => { - return { timeZone: 'UTC' }; - }, - }; - }; -} - const mockUid = 'abc123'; jest.mock('@grafana/runtime', () => { const original = jest.requireActual('@grafana/runtime'); @@ -80,7 +70,13 @@ describe('ShareModal', () => { beforeEach(() => { const defaultTimeRange = getDefaultTimeRange(); - setUTCTimeZone(); + jest.spyOn(window.Intl, 'DateTimeFormat').mockImplementation(() => { + return { + resolvedOptions: () => { + return { timeZone: 'UTC' }; + }, + } as Intl.DateTimeFormat; + }); mockLocationHref('http://server/#!/test'); config.rendererAvailable = true; config.bootData.user.orgId = 1; diff --git a/public/app/features/dashboard/components/ShareModal/ShareModal.tsx b/public/app/features/dashboard/components/ShareModal/ShareModal.tsx index 357effdee2f..d661526076d 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareModal.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareModal.tsx @@ -95,7 +95,7 @@ export class ShareModal extends React.Component { reportInteraction('grafana_dashboards_share_modal_viewed'); } - onSelectTab = (t: any) => { + onSelectTab: React.ComponentProps['onChangeTab'] = (t) => { this.setState((prevState) => ({ ...prevState, activeTab: t.value })); }; diff --git a/public/app/features/dashboard/components/ShareModal/utils.ts b/public/app/features/dashboard/components/ShareModal/utils.ts index fb350ce464a..3b959103193 100644 --- a/public/app/features/dashboard/components/ShareModal/utils.ts +++ b/public/app/features/dashboard/components/ShareModal/utils.ts @@ -121,11 +121,11 @@ export function getLocalTimeZone() { const utcOffset = '&tz=UTC' + encodeURIComponent(dateTime().format('Z')); // Older browser does not the internationalization API - if (!(window as any).Intl) { + if (!window.Intl) { return utcOffset; } - const dateFormat = (window as any).Intl.DateTimeFormat(); + const dateFormat = window.Intl.DateTimeFormat(); if (!dateFormat.resolvedOptions) { return utcOffset; } diff --git a/public/app/features/dashboard/components/VersionHistory/utils.ts b/public/app/features/dashboard/components/VersionHistory/utils.ts index 1dfeffda3de..3733926c3eb 100644 --- a/public/app/features/dashboard/components/VersionHistory/utils.ts +++ b/public/app/features/dashboard/components/VersionHistory/utils.ts @@ -54,7 +54,7 @@ export const jsonDiff = (lhs: any, rhs: any): Diffs => { const sortByLineNumber = (diffs: Diff[]) => sortBy(diffs, 'startLineNumber'); const groupByPath = (diffs: Diff[]) => - diffs.reduce>((acc, value) => { + diffs.reduce>((acc, value) => { const groupKey: string = value.path[0]; if (!acc[groupKey]) { acc[groupKey] = []; diff --git a/public/app/features/datasources/components/ButtonRow.tsx b/public/app/features/datasources/components/ButtonRow.tsx index c4de895d609..773d81d7697 100644 --- a/public/app/features/datasources/components/ButtonRow.tsx +++ b/public/app/features/datasources/components/ButtonRow.tsx @@ -10,7 +10,7 @@ export interface Props { canSave: boolean; canDelete: boolean; onDelete: () => void; - onSubmit: (event: any) => void; + onSubmit: (event: React.MouseEvent) => void; onTest: (event: React.MouseEvent) => void; } diff --git a/public/app/features/datasources/components/EditDataSource.tsx b/public/app/features/datasources/components/EditDataSource.tsx index 128e18b1a84..011b36cc76d 100644 --- a/public/app/features/datasources/components/EditDataSource.tsx +++ b/public/app/features/datasources/components/EditDataSource.tsx @@ -117,7 +117,7 @@ export function EditDataSourceView({ const isAlertManagerDatasource = dsi?.type === 'alertmanager'; const alertingSupported = hasAlertingEnabled || isAlertManagerDatasource; - const onSubmit = async (e: React.FormEvent) => { + const onSubmit = async (e: React.MouseEvent | React.FormEvent) => { e.preventDefault(); await onUpdate({ ...dataSource }); diff --git a/public/app/features/dimensions/color.ts b/public/app/features/dimensions/color.ts index 344e0d58b47..af99e40c6c4 100644 --- a/public/app/features/dimensions/color.ts +++ b/public/app/features/dimensions/color.ts @@ -48,7 +48,7 @@ export function getColorDimensionForField( } const disp = getDisplayProcessor({ field, theme }); - const getColor = (value: any): string => { + const getColor = (value: unknown): string => { return disp(value).color ?? '#ccc'; }; diff --git a/public/app/features/dimensions/editors/ColorDimensionEditor.tsx b/public/app/features/dimensions/editors/ColorDimensionEditor.tsx index 03b71cf2e3f..23a20198103 100644 --- a/public/app/features/dimensions/editors/ColorDimensionEditor.tsx +++ b/public/app/features/dimensions/editors/ColorDimensionEditor.tsx @@ -12,7 +12,7 @@ const fixedColorOption: SelectableValue = { value: '_____fixed_____', }; -export const ColorDimensionEditor: FC> = (props) => { +export const ColorDimensionEditor: FC> = (props) => { const { value, context, onChange } = props; const defaultColor = 'dark-green'; diff --git a/public/app/features/dimensions/editors/IconSelector.tsx b/public/app/features/dimensions/editors/IconSelector.tsx index 84e2841a481..6f383e6ad06 100644 --- a/public/app/features/dimensions/editors/IconSelector.tsx +++ b/public/app/features/dimensions/editors/IconSelector.tsx @@ -12,7 +12,7 @@ interface Props { const IconSelector = ({ value, onChange }: Props) => { const [icons, setIcons] = useState(value ? [{ value, label: value }] : []); const [icon, setIcon] = useState(); - const iconRoot = (window as any).__grafana_public_path__ + 'img/icons/unicons/'; + const iconRoot = window.__grafana_public_path__ + 'img/icons/unicons/'; const onChangeIcon = (value: string) => { onChange(value); setIcon(value); diff --git a/public/app/features/dimensions/editors/ResourcePicker.tsx b/public/app/features/dimensions/editors/ResourcePicker.tsx index ecfb63f3ef4..e8cee91e027 100644 --- a/public/app/features/dimensions/editors/ResourcePicker.tsx +++ b/public/app/features/dimensions/editors/ResourcePicker.tsx @@ -40,7 +40,7 @@ export const ResourcePicker = (props: Props) => { const styles = useStyles2(getStyles); const theme = useTheme2(); - const pickerTriggerRef = createRef(); + const pickerTriggerRef = createRef(); const popoverElement = ( ); diff --git a/public/app/features/dimensions/editors/ScalarDimensionEditor.tsx b/public/app/features/dimensions/editors/ScalarDimensionEditor.tsx index d06e59b57b9..f3ed210ccb0 100644 --- a/public/app/features/dimensions/editors/ScalarDimensionEditor.tsx +++ b/public/app/features/dimensions/editors/ScalarDimensionEditor.tsx @@ -18,7 +18,7 @@ const scalarOptions = [ { label: 'Clamped', value: ScalarDimensionMode.Clamped, description: 'Use field values, clamped to max and min' }, ]; -type Props = StandardEditorProps; +type Props = StandardEditorProps; export const ScalarDimensionEditor = ({ value, context, onChange, item }: Props) => { const { settings } = item; diff --git a/public/app/features/dimensions/editors/ScaleDimensionEditor.tsx b/public/app/features/dimensions/editors/ScaleDimensionEditor.tsx index 46f49946c77..80550e5c5bb 100644 --- a/public/app/features/dimensions/editors/ScaleDimensionEditor.tsx +++ b/public/app/features/dimensions/editors/ScaleDimensionEditor.tsx @@ -14,9 +14,7 @@ const fixedValueOption: SelectableValue = { value: '_____fixed_____', }; -export const ScaleDimensionEditor: FC> = ( - props -) => { +export const ScaleDimensionEditor: FC> = (props) => { const { value, context, onChange, item } = props; const { settings } = item; const styles = useStyles2(getStyles); diff --git a/public/app/features/dimensions/editors/TextDimensionEditor.tsx b/public/app/features/dimensions/editors/TextDimensionEditor.tsx index b10d2f36bb5..12b6304f270 100644 --- a/public/app/features/dimensions/editors/TextDimensionEditor.tsx +++ b/public/app/features/dimensions/editors/TextDimensionEditor.tsx @@ -26,7 +26,7 @@ const dummyStringSettings: StandardEditorsRegistryItem; +type Props = StandardEditorProps; export const TextDimensionEditor = ({ value, context, onChange }: Props) => { const labelWidth = 9; diff --git a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx index 46020d3f21d..120bcb43d04 100644 --- a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx +++ b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx @@ -9,7 +9,7 @@ import { ResourcePicker } from '../ResourcePicker'; import { buildEditRowModels, editModelToSaveModel, ValueMappingsEditorModal } from './ValueMappingsEditorModal'; -export interface Props extends StandardEditorProps { +export interface Props extends StandardEditorProps { showIcon?: boolean; } diff --git a/public/app/features/dimensions/text.ts b/public/app/features/dimensions/text.ts index 5a7db09529d..0c0ad19e55b 100644 --- a/public/app/features/dimensions/text.ts +++ b/public/app/features/dimensions/text.ts @@ -28,7 +28,7 @@ export function getTextDimensionForField( } if (mode === TextDimensionMode.Template) { - const disp = (v: any) => { + const disp = (v: unknown) => { return `TEMPLATE[${config.fixed} // ${v}]`; }; if (!field) { @@ -56,7 +56,7 @@ export function getTextDimensionForField( }; } - let disp = (v: any) => formattedValueToString(field.display!(v)); + let disp = (v: unknown) => formattedValueToString(field.display!(v)); return { field, get: (i) => disp(field.values.get(i)), diff --git a/public/app/features/explore/LogsContainer.tsx b/public/app/features/explore/LogsContainer.tsx index 2ecaa763537..ec88df6d6e2 100644 --- a/public/app/features/explore/LogsContainer.tsx +++ b/public/app/features/explore/LogsContainer.tsx @@ -13,6 +13,7 @@ import { SplitOpen, DataFrame, SupplementaryQueryType, + DataQueryResponse, } from '@grafana/data'; import { Collapse } from '@grafana/ui'; import { StoreState } from 'app/types'; @@ -49,7 +50,7 @@ class LogsContainer extends PureComponent { updateTimeRange({ exploreId, absoluteRange }); }; - getLogRowContext = async (row: LogRowModel, options?: any): Promise => { + getLogRowContext = async (row: LogRowModel, options?: any): Promise => { const { datasourceInstance, logsQueries } = this.props; if (hasLogsContextSupport(datasourceInstance)) { diff --git a/public/app/features/explore/QueryRows.test.tsx b/public/app/features/explore/QueryRows.test.tsx index 22983d9f0c9..007b946a2da 100644 --- a/public/app/features/explore/QueryRows.test.tsx +++ b/public/app/features/explore/QueryRows.test.tsx @@ -2,7 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; import { Provider } from 'react-redux'; -import { setDataSourceSrv } from '@grafana/runtime'; +import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime'; import { DataQuery } from '@grafana/schema'; import { configureStore } from 'app/store/configureStore'; import { ExploreId, ExploreState } from 'app/types'; @@ -46,7 +46,7 @@ function setup(queries: DataQuery[]) { get(uid?: string) { return Promise.resolve(uid ? datasources[uid] || defaultDs : defaultDs); }, - } as any); + } as DataSourceSrv); const leftState = makeExplorePaneState(); const initialState: ExploreState = { diff --git a/public/app/features/explore/RichHistory/RichHistory.tsx b/public/app/features/explore/RichHistory/RichHistory.tsx index 4af66b8b33b..5e2e549203d 100644 --- a/public/app/features/explore/RichHistory/RichHistory.tsx +++ b/public/app/features/explore/RichHistory/RichHistory.tsx @@ -90,7 +90,7 @@ class UnThemedRichHistory extends PureComponent { toggleActiveDatasourceOnly = () => this.updateSettings({ activeDatasourceOnly: !this.props.richHistorySettings.activeDatasourceOnly }); - componentDidUpdate(prevProps: Readonly, prevState: Readonly<{}>, snapshot?: any) { + componentDidUpdate(prevProps: Readonly) { if (prevProps.richHistory !== this.props.richHistory) { this.setState({ loading: false, diff --git a/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx b/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx index c3f5a990bf9..bab5804e96a 100644 --- a/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryQueriesTab.tsx @@ -239,7 +239,7 @@ export function RichHistoryQueriesTab(props: Props) { {mappedQueriesToHeadings[heading].length} queries - {mappedQueriesToHeadings[heading].map((q: RichHistoryQuery) => { + {mappedQueriesToHeadings[heading].map((q) => { return ; })} diff --git a/public/app/features/explore/TraceView/components/ScrollManager.tsx b/public/app/features/explore/TraceView/components/ScrollManager.tsx index 85fc84f9333..e996b3b5dd3 100644 --- a/public/app/features/explore/TraceView/components/ScrollManager.tsx +++ b/public/app/features/explore/TraceView/components/ScrollManager.tsx @@ -157,9 +157,7 @@ export default class ScrollManager { const _collapsed = xrs.getCollapsedChildren(); const childrenAreHidden = _collapsed ? new Set(_collapsed) : null; // use empty Map as fallback to make flow happy - const spansMap: Map = childrenAreHidden - ? new Map(spans.map((s) => [s.spanID, s] as [string, TraceSpan])) - : new Map(); + const spansMap: Map = childrenAreHidden ? new Map(spans.map((s) => [s.spanID, s])) : new Map(); const boundary = direction < 0 ? -1 : spans.length; let nextSpanIndex: number | undefined; for (let i = fullViewSpanIndex + direction; i !== boundary; i += direction) { @@ -268,7 +266,7 @@ export default class ScrollManager { destroy() { this._trace = undefined; - this._scroller = undefined as any; + this._scroller = undefined; this._accessors = undefined; } } diff --git a/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/Scrubber.tsx b/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/Scrubber.tsx index 077eb2a9f2d..5cf5d5f178b 100644 --- a/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/Scrubber.tsx +++ b/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/Scrubber.tsx @@ -75,9 +75,9 @@ export const getStyles = () => { export type ScrubberProps = { isDragging: boolean; position: number; - onMouseDown: (evt: React.MouseEvent) => void; - onMouseEnter: (evt: React.MouseEvent) => void; - onMouseLeave: (evt: React.MouseEvent) => void; + onMouseDown: (evt: React.MouseEvent) => void; + onMouseEnter: (evt: React.MouseEvent) => void; + onMouseLeave: (evt: React.MouseEvent) => void; }; export default function Scrubber({ isDragging, onMouseDown, onMouseEnter, onMouseLeave, position }: ScrubberProps) { diff --git a/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/render-into-canvas.tsx b/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/render-into-canvas.tsx index a6fe5f0cebb..e339120e0fe 100644 --- a/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/render-into-canvas.tsx +++ b/public/app/features/explore/TraceView/components/TracePageHeader/SpanGraph/render-into-canvas.tsx @@ -39,22 +39,24 @@ export default function renderIntoCanvas( const itemHeight = Math.min(MAX_ITEM_HEIGHT, Math.max(MIN_ITEM_HEIGHT, cHeight / items.length)); const itemYChange = cHeight / items.length; - const ctx = canvas.getContext('2d', { alpha: false }) as CanvasRenderingContext2D; - ctx.fillStyle = bgColor; - ctx.fillRect(0, 0, cWidth, cHeight); - for (let i = 0; i < items.length; i++) { - const { valueWidth, valueOffset, serviceName } = items[i]; - const x = (valueOffset / totalValueWidth) * cWidth; - let width = (valueWidth / totalValueWidth) * cWidth; - if (width < MIN_ITEM_WIDTH) { - width = MIN_ITEM_WIDTH; + const ctx = canvas.getContext('2d', { alpha: false }); + if (ctx) { + ctx.fillStyle = bgColor; + ctx.fillRect(0, 0, cWidth, cHeight); + for (let i = 0; i < items.length; i++) { + const { valueWidth, valueOffset, serviceName } = items[i]; + const x = (valueOffset / totalValueWidth) * cWidth; + let width = (valueWidth / totalValueWidth) * cWidth; + if (width < MIN_ITEM_WIDTH) { + width = MIN_ITEM_WIDTH; + } + let fillStyle = fillCache.get(serviceName); + if (!fillStyle) { + fillStyle = `rgba(${getFillColor(serviceName).concat(ITEM_ALPHA).join()})`; + fillCache.set(serviceName, fillStyle); + } + ctx.fillStyle = fillStyle; + ctx.fillRect(x, i * itemYChange, width, itemHeight); } - let fillStyle = fillCache.get(serviceName); - if (!fillStyle) { - fillStyle = `rgba(${getFillColor(serviceName).concat(ITEM_ALPHA).join()})`; - fillCache.set(serviceName, fillStyle); - } - ctx.fillStyle = fillStyle; - ctx.fillRect(x, i * itemYChange, width, itemHeight); } } diff --git a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBar.tsx b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBar.tsx index ebf46d12f1b..c00a5d9be8d 100644 --- a/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBar.tsx +++ b/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBar.tsx @@ -94,7 +94,7 @@ const getStyles = (theme: GrafanaTheme2) => { export type Props = { color: string; - onClick?: (evt: React.MouseEvent) => void; + onClick?: (evt: React.MouseEvent) => void; viewEnd: number; viewStart: number; getViewedBounds: ViewedBoundsFunctionType; diff --git a/public/app/features/explore/TraceView/components/TraceTimelineViewer/utils.tsx b/public/app/features/explore/TraceView/components/TraceTimelineViewer/utils.tsx index bdd9a5887e8..ee195495589 100644 --- a/public/app/features/explore/TraceView/components/TraceTimelineViewer/utils.tsx +++ b/public/app/features/explore/TraceView/components/TraceTimelineViewer/utils.tsx @@ -57,7 +57,7 @@ export function createViewedBoundsFunc(viewRange: { min: number; max: number; vi * items. * @returns {boolean} True if a match was found. */ -export function spanHasTag(key: string, value: any, span: TraceSpan) { +export function spanHasTag(key: string, value: unknown, span: TraceSpan) { if (!Array.isArray(span.tags) || !span.tags.length) { return false; } diff --git a/public/app/features/explore/TraceView/components/constants/index.tsx b/public/app/features/explore/TraceView/components/constants/index.tsx index 15726a21be1..d6515888f51 100644 --- a/public/app/features/explore/TraceView/components/constants/index.tsx +++ b/public/app/features/explore/TraceView/components/constants/index.tsx @@ -12,5 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. -export const FALLBACK_DAG_MAX_NUM_SERVICES = 100 as 100; +export const FALLBACK_DAG_MAX_NUM_SERVICES = 100; export const FALLBACK_TRACE_NAME = ''; diff --git a/public/app/features/runtime/init.ts b/public/app/features/runtime/init.ts index 1d6058a1196..5ae3e02dce7 100644 --- a/public/app/features/runtime/init.ts +++ b/public/app/features/runtime/init.ts @@ -1,7 +1,19 @@ -import { PanelData } from '@grafana/data'; +import { PanelData, RawTimeRange } from '@grafana/data'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv'; +import { DashboardModel } from '../dashboard/state'; + +declare global { + interface Window { + grafanaRuntime?: { + getDashboardSaveModel: () => DashboardModel | undefined; + getDashboardTimeRange: () => { from: number; to: number; raw: RawTimeRange }; + getPanelData: () => Record | undefined; + }; + } +} + /** * This will setup features that are accessible through the root window location * @@ -10,7 +22,7 @@ import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv'; * @internal and subject to change */ export function initWindowRuntime() { - (window as any).grafanaRuntime = { + window.grafanaRuntime = { /** Get info for the current dashboard. This will include the migrated dashboard JSON */ getDashboardSaveModel: () => { const d = getDashboardSrv().getCurrent(); @@ -36,10 +48,10 @@ export function initWindowRuntime() { if (!d) { return undefined; } - return d.panels.reduce((acc, panel) => { + return d.panels.reduce>((acc, panel) => { acc[panel.id] = panel.getQueryRunner().getLastResult(); return acc; - }, {} as Record); + }, {}); }, }; } diff --git a/public/app/plugins/datasource/loki/querySplitting.ts b/public/app/plugins/datasource/loki/querySplitting.ts index 73f1a5e3ac2..3f0df310c25 100644 --- a/public/app/plugins/datasource/loki/querySplitting.ts +++ b/public/app/plugins/datasource/loki/querySplitting.ts @@ -10,12 +10,18 @@ import { getRangeChunks as getMetricRangeChunks } from './metricTimeSplit'; import { combineResponses, isLogsQuery } from './queryUtils'; import { LokiQuery, LokiQueryType } from './types'; +declare global { + interface Window { + lokiChunkDuration: number; + } +} + /** * Purposely exposing it to support doing tests without needing to update the repo. * TODO: remove. * Hardcoded to 1 day. */ -(window as any).lokiChunkDuration = 24 * 60 * 60 * 1000; +window.lokiChunkDuration = 24 * 60 * 60 * 1000; export function partitionTimeRange( isLogsQuery: boolean, @@ -35,7 +41,7 @@ export function partitionTimeRange( const safeStep = Math.ceil((end - start) / 11000); const step = Math.max(intervalMs * resolution, safeStep); - const duration: number = (window as any).lokiChunkDuration; + const duration = window.lokiChunkDuration; const ranges = isLogsQuery ? getLogsRangeChunks(start, end, duration) diff --git a/public/app/plugins/panel/barchart/utils.ts b/public/app/plugins/panel/barchart/utils.ts index 5ea2ae98c6c..db3f459fe14 100644 --- a/public/app/plugins/panel/barchart/utils.ts +++ b/public/app/plugins/panel/barchart/utils.ts @@ -316,13 +316,13 @@ function getRotationPadding( ): Padding { const values = frame.fields[0].values; const fontSize = UPLOT_AXIS_FONT_SIZE; - const displayProcessor = frame.fields[0].display ?? ((v) => v); + const displayProcessor = frame.fields[0].display; + const getProcessedValue = (i: number) => { + return displayProcessor ? displayProcessor(values.get(i)) : values.get(i); + }; let maxLength = 0; for (let i = 0; i < values.length; i++) { - let size = measureText( - shortenValue(formattedValueToString(displayProcessor(values.get(i))), valueMaxLength), - fontSize - ); + let size = measureText(shortenValue(formattedValueToString(getProcessedValue(i)), valueMaxLength), fontSize); maxLength = size.width > maxLength ? size.width : maxLength; } @@ -331,7 +331,7 @@ function getRotationPadding( rotateLabel > 0 ? Math.cos((rotateLabel * Math.PI) / 180) * measureText( - shortenValue(formattedValueToString(displayProcessor(values.get(values.length - 1))), valueMaxLength), + shortenValue(formattedValueToString(getProcessedValue(values.length - 1)), valueMaxLength), fontSize ).width : 0; @@ -340,8 +340,7 @@ function getRotationPadding( const paddingLeft = rotateLabel < 0 ? Math.cos((rotateLabel * -1 * Math.PI) / 180) * - measureText(shortenValue(formattedValueToString(displayProcessor(values.get(0))), valueMaxLength), fontSize) - .width + measureText(shortenValue(formattedValueToString(getProcessedValue(0)), valueMaxLength), fontSize).width : 0; // Add padding to the bottom to avoid clipping the rotated labels.