Chore: Improve some types (#64675)

* some type fixes

* few more

* more type fixes

* fix the majority of (window as any) calls

* don't make new variable for event

* few more

* MOAR
This commit is contained in:
Ashley Harrison 2023-03-14 09:51:44 +00:00 committed by GitHub
parent aade4b0bd2
commit 53186c14a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 256 additions and 436 deletions

View File

@ -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"]
[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"],
[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"]
[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"]
],

View File

@ -10,7 +10,7 @@ type WithGrafanaRuntime<T> = T & {
};
const hasGrafanaRuntime = <T>(obj: T): obj is WithGrafanaRuntime<T> => {
return typeof (obj as any)?.grafanaRuntime === 'object';
return 'grafanaRuntime' in obj;
};
e2e.benchmark({

View File

@ -88,14 +88,14 @@ e2e.scenario({
},
});
const expectInspectorResultAndClose = (expectCallBack: (keys: any[]) => void) => {
const expectInspectorResultAndClose = (expectCallBack: (keys: JQuery<HTMLElement>) => 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();
};

View File

@ -640,7 +640,7 @@ describe('getLinksSupplier', () => {
},
],
},
display: (v) => ({ numeric: v, text: String(v) }),
display: (v) => ({ numeric: Number(v), text: String(v) }),
},
],
});

View File

@ -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 {
/**

View File

@ -87,10 +87,10 @@ export class Registry<T extends RegistryItem> {
this.initialize();
}
const select = {
const select: RegistrySelectInfo = {
options: [],
current: [],
} as RegistrySelectInfo;
};
const currentOptions: Record<string, SelectableValue<string>> = {};
if (current) {

View File

@ -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<any>, parser: Parser): void => {
private chunk = (results: ParseResult<string[]>, 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) {

View File

@ -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;

View File

@ -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] }
);
}
/**

View File

@ -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);
}

View File

@ -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<T>(ES6Class: T): T {
return new Proxy(ES6Class as any, {
export function makeClassES5Compatible<T extends abstract new (...args: ConstructorParameters<T>) => InstanceType<T>>(
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<T>(ES6Class: T): T {
return Reflect.construct(target, argumentsList, self.constructor);
},
}) as unknown as T;
});
}

View File

@ -1,7 +1,7 @@
import { standardTransformersRegistry } from '../../transformations';
import { DataTransformerInfo } from '../../types';
export const mockTransformationsRegistry = (transformers: Array<DataTransformerInfo<any>>) => {
export const mockTransformationsRegistry = (transformers: DataTransformerInfo[]) => {
standardTransformersRegistry.setInit(() => {
return transformers.map((t) => {
return {

View File

@ -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) };
}

View File

@ -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++) {

View File

@ -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 }),
};
}

View File

@ -34,7 +34,7 @@ export const getMockPlugins = (amount: number): PluginMeta[] => {
});
}
return plugins as any;
return plugins;
};
export function getPanelPlugin(

View File

@ -68,7 +68,7 @@ const ButtonSelectComponent = <T,>(props: Props<T>) => {
{options.map((item) => (
<MenuItem
key={`${item.value}`}
label={(item.label || item.value) as string}
label={item.label ?? String(item.value)}
onClick={() => onChangeInternal(item)}
active={item.value === value?.value}
ariaChecked={item.value === value?.value}

View File

@ -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[] = [
{

View File

@ -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', () => {

View File

@ -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/';
}

View File

@ -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
}

View File

@ -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<Field, 'values'> = {
/*
/*
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,

View File

@ -10,18 +10,20 @@ interface Props extends StandardEditorProps<string, StringFieldConfigSettings> {
export const StringValueEditor = ({ value, onChange, item, suffix }: Props) => {
const Component = item.settings?.useTextarea ? TextArea : Input;
const onValueChange = useCallback(
(e: React.SyntheticEvent) => {
(
e:
| React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>
| React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
let nextValue = value ?? '';
if (e.hasOwnProperty('key')) {
if ('key' in e) {
// handling keyboard event
const evt = e as React.KeyboardEvent<HTMLInputElement>;
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<HTMLInputElement>;
nextValue = evt.currentTarget.value.trim();
// handling blur event
nextValue = e.currentTarget.value.trim();
}
if (nextValue === value) {
return; // no change

View File

@ -22,20 +22,19 @@ export class StringArrayEditor extends React.PureComponent<Props, State> {
onChange(copy);
};
onValueChange = (e: React.SyntheticEvent, idx: number) => {
const evt = e as React.KeyboardEvent<HTMLInputElement>;
if (e.hasOwnProperty('key')) {
if (evt.key !== 'Enter') {
onValueChange = (e: React.KeyboardEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement>, 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 });

View File

@ -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);

View File

@ -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<any, any> {
data: any;
}
export const TagOption = ({ data, className, label, isFocused, innerProps }: ExtendedOptionProps) => {
export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps<any, any>) => {
const styles = useStyles2(getStyles);
return (

View File

@ -33,7 +33,7 @@ export class TimelineChart extends React.Component<TimelineProps> {
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) {

View File

@ -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,

View File

@ -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<UPlotConfigOptions> = (
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,
}),
};

View File

@ -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)
)
);

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -8,14 +8,14 @@ export class PreferencesService {
/**
* Overrides all preferences
*/
update(preferences: UserPreferencesDTO): Promise<any> {
update(preferences: UserPreferencesDTO) {
return backendSrv.put(`/api/${this.resourceUri}/preferences`, preferences);
}
/**
* Updates only provided preferences
*/
patch(preferences: Partial<UserPreferencesDTO>): Promise<any> {
patch(preferences: Partial<UserPreferencesDTO>) {
return backendSrv.patch(`/api/${this.resourceUri}/preferences`, preferences);
}

View File

@ -1,4 +1,4 @@
export const mockSearch = jest.fn<any, any>(() => {
export const mockSearch = jest.fn(() => {
return Promise.resolve([]);
});

View File

@ -41,7 +41,7 @@ export class ApplicationInsightsBackend implements EchoBackend<PageviewEchoEvent
const url = 'https://js.monitor.azure.com/scripts/b/ai.2.min.js';
loadScript(url).then(() => {
const init = new (window as any).Microsoft.ApplicationInsights.ApplicationInsights(applicationInsightsOpts);
(window as any).applicationInsights = init.loadAppInsights();
window.applicationInsights = init.loadAppInsights();
});
}

View File

@ -243,7 +243,7 @@ export function createQueryText(query: DataQuery, dsApi?: DataSourceApi) {
}
export function mapQueriesToHeadings(query: RichHistoryQuery[], sortOrder: SortOrder) {
let mappedQueriesToHeadings: any = {};
let mappedQueriesToHeadings: Record<string, RichHistoryQuery[]> = {};
query.forEach((q) => {
let heading = createQueryHeading(q, sortOrder);

View File

@ -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<Array<[number, number]>>((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]);

View File

@ -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 },

View File

@ -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()}
</Field>
);
}

View File

@ -167,13 +167,13 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
});
};
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();

View File

@ -155,7 +155,7 @@ export function getFieldOverrideCategories(
continue;
}
const onPropertyChange = (value: any) => {
const onPropertyChange = (value: DynamicConfigValue) => {
override.properties[propIdx].value = value;
onOverrideChange(idx, override);
};

View File

@ -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);
},

View File

@ -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;
}

View File

@ -18,7 +18,7 @@ export const RepeatRowSelect: FC<Props> = ({ repeat, onChange, id }) => {
});
const variableOptions = useMemo(() => {
const options = variables.map((item: any) => {
const options: Array<SelectableValue<string | null>> = variables.map((item) => {
return { label: item.name, value: item.name };
});

View File

@ -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;

View File

@ -95,7 +95,7 @@ export class ShareModal extends React.Component<Props, State> {
reportInteraction('grafana_dashboards_share_modal_viewed');
}
onSelectTab = (t: any) => {
onSelectTab: React.ComponentProps<typeof ModalTabsHeader>['onChangeTab'] = (t) => {
this.setState((prevState) => ({ ...prevState, activeTab: t.value }));
};

View File

@ -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;
}

View File

@ -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<Record<string, any>>((acc, value) => {
diffs.reduce<Record<string, Diff[]>>((acc, value) => {
const groupKey: string = value.path[0];
if (!acc[groupKey]) {
acc[groupKey] = [];

View File

@ -10,7 +10,7 @@ export interface Props {
canSave: boolean;
canDelete: boolean;
onDelete: () => void;
onSubmit: (event: any) => void;
onSubmit: (event: React.MouseEvent<HTMLButtonElement>) => void;
onTest: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}

View File

@ -117,7 +117,7 @@ export function EditDataSourceView({
const isAlertManagerDatasource = dsi?.type === 'alertmanager';
const alertingSupported = hasAlertingEnabled || isAlertManagerDatasource;
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
const onSubmit = async (e: React.MouseEvent<HTMLButtonElement> | React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
await onUpdate({ ...dataSource });

View File

@ -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';
};

View File

@ -12,7 +12,7 @@ const fixedColorOption: SelectableValue<string> = {
value: '_____fixed_____',
};
export const ColorDimensionEditor: FC<StandardEditorProps<ColorDimensionConfig, any, any>> = (props) => {
export const ColorDimensionEditor: FC<StandardEditorProps<ColorDimensionConfig>> = (props) => {
const { value, context, onChange } = props;
const defaultColor = 'dark-green';

View File

@ -12,7 +12,7 @@ interface Props {
const IconSelector = ({ value, onChange }: Props) => {
const [icons, setIcons] = useState<SelectableValue[]>(value ? [{ value, label: value }] : []);
const [icon, setIcon] = useState<string>();
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);

View File

@ -40,7 +40,7 @@ export const ResourcePicker = (props: Props) => {
const styles = useStyles2(getStyles);
const theme = useTheme2();
const pickerTriggerRef = createRef<any>();
const pickerTriggerRef = createRef<HTMLDivElement>();
const popoverElement = (
<ResourcePickerPopover onChange={onChange} value={value} mediaType={mediaType} folderName={folderName} />
);

View File

@ -18,7 +18,7 @@ const scalarOptions = [
{ label: 'Clamped', value: ScalarDimensionMode.Clamped, description: 'Use field values, clamped to max and min' },
];
type Props = StandardEditorProps<ScalarDimensionConfig, ScalarDimensionOptions, any>;
type Props = StandardEditorProps<ScalarDimensionConfig, ScalarDimensionOptions>;
export const ScalarDimensionEditor = ({ value, context, onChange, item }: Props) => {
const { settings } = item;

View File

@ -14,9 +14,7 @@ const fixedValueOption: SelectableValue<string> = {
value: '_____fixed_____',
};
export const ScaleDimensionEditor: FC<StandardEditorProps<ScaleDimensionConfig, ScaleDimensionOptions, any>> = (
props
) => {
export const ScaleDimensionEditor: FC<StandardEditorProps<ScaleDimensionConfig, ScaleDimensionOptions>> = (props) => {
const { value, context, onChange, item } = props;
const { settings } = item;
const styles = useStyles2(getStyles);

View File

@ -26,7 +26,7 @@ const dummyStringSettings: StandardEditorsRegistryItem<string, StringFieldConfig
settings: {},
} as any;
type Props = StandardEditorProps<TextDimensionConfig, TextDimensionOptions, any>;
type Props = StandardEditorProps<TextDimensionConfig, TextDimensionOptions>;
export const TextDimensionEditor = ({ value, context, onChange }: Props) => {
const labelWidth = 9;

View File

@ -9,7 +9,7 @@ import { ResourcePicker } from '../ResourcePicker';
import { buildEditRowModels, editModelToSaveModel, ValueMappingsEditorModal } from './ValueMappingsEditorModal';
export interface Props extends StandardEditorProps<ValueMapping[], any, any> {
export interface Props extends StandardEditorProps<ValueMapping[]> {
showIcon?: boolean;
}

View File

@ -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)),

View File

@ -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<LogsContainerProps> {
updateTimeRange({ exploreId, absoluteRange });
};
getLogRowContext = async (row: LogRowModel, options?: any): Promise<any> => {
getLogRowContext = async (row: LogRowModel, options?: any): Promise<DataQueryResponse | []> => {
const { datasourceInstance, logsQueries } = this.props;
if (hasLogsContextSupport(datasourceInstance)) {

View File

@ -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 = {

View File

@ -90,7 +90,7 @@ class UnThemedRichHistory extends PureComponent<RichHistoryProps> {
toggleActiveDatasourceOnly = () =>
this.updateSettings({ activeDatasourceOnly: !this.props.richHistorySettings.activeDatasourceOnly });
componentDidUpdate(prevProps: Readonly<RichHistoryProps>, prevState: Readonly<{}>, snapshot?: any) {
componentDidUpdate(prevProps: Readonly<RichHistoryProps>) {
if (prevProps.richHistory !== this.props.richHistory) {
this.setState({
loading: false,

View File

@ -239,7 +239,7 @@ export function RichHistoryQueriesTab(props: Props) {
{mappedQueriesToHeadings[heading].length} queries
</span>
</div>
{mappedQueriesToHeadings[heading].map((q: RichHistoryQuery) => {
{mappedQueriesToHeadings[heading].map((q) => {
return <RichHistoryCard query={q} key={q.id} exploreId={exploreId} />;
})}
</div>

View File

@ -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<string, TraceSpan> = childrenAreHidden
? new Map(spans.map((s) => [s.spanID, s] as [string, TraceSpan]))
: new Map();
const spansMap: Map<string, TraceSpan> = 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;
}
}

View File

@ -75,9 +75,9 @@ export const getStyles = () => {
export type ScrubberProps = {
isDragging: boolean;
position: number;
onMouseDown: (evt: React.MouseEvent<any>) => void;
onMouseEnter: (evt: React.MouseEvent<any>) => void;
onMouseLeave: (evt: React.MouseEvent<any>) => void;
onMouseDown: (evt: React.MouseEvent<SVGGElement>) => void;
onMouseEnter: (evt: React.MouseEvent<SVGGElement>) => void;
onMouseLeave: (evt: React.MouseEvent<SVGGElement>) => void;
};
export default function Scrubber({ isDragging, onMouseDown, onMouseEnter, onMouseLeave, position }: ScrubberProps) {

View File

@ -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);
}
}

View File

@ -94,7 +94,7 @@ const getStyles = (theme: GrafanaTheme2) => {
export type Props = {
color: string;
onClick?: (evt: React.MouseEvent<any>) => void;
onClick?: (evt: React.MouseEvent<HTMLDivElement>) => void;
viewEnd: number;
viewStart: number;
getViewedBounds: ViewedBoundsFunctionType;

View File

@ -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;
}

View File

@ -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 = '<trace-without-root-span>';

View File

@ -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<number, PanelData | undefined> | 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<Record<number, PanelData | undefined>>((acc, panel) => {
acc[panel.id] = panel.getQueryRunner().getLastResult();
return acc;
}, {} as Record<number, PanelData | undefined>);
}, {});
},
};
}

View File

@ -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)

View File

@ -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.