Chore: Improve typings (#93180)

* fix some any's/type assertions

* fix some more any/type assertions
pull/93206/head
Ashley Harrison 10 months ago committed by GitHub
parent 25ebb5b76f
commit 79a86b9e6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 122
      .betterer.results
  2. 6
      public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx
  3. 4
      public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts
  4. 5
      public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx
  5. 2
      public/app/plugins/datasource/graphite/datasource.ts
  6. 6
      public/app/plugins/datasource/graphite/graphite_query.ts
  7. 4
      public/app/plugins/datasource/influxdb/influx_query_model.ts
  8. 5
      public/app/plugins/datasource/influxdb/influx_series.test.ts
  9. 24
      public/app/plugins/datasource/influxdb/influx_series.ts
  10. 7
      public/app/plugins/datasource/influxdb/migrations.ts
  11. 2
      public/app/plugins/datasource/influxdb/query_part.ts
  12. 5
      public/app/plugins/datasource/loki/streaming.ts
  13. 10
      public/app/plugins/datasource/opentsdb/migrations.ts
  14. 4
      public/app/plugins/datasource/tempo/resultTransformer.ts
  15. 2
      public/app/plugins/panel/barchart/utils.ts
  16. 3
      public/app/plugins/panel/histogram/migrations.ts
  17. 2
      public/app/plugins/panel/live/LiveChannelEditor.tsx
  18. 4
      public/app/plugins/panel/table/migrations.ts
  19. 2
      public/app/plugins/panel/text/TextPanelEditor.tsx
  20. 2
      public/app/plugins/panel/xychart/AutoEditor.tsx
  21. 2
      public/app/plugins/panel/xychart/v2/SeriesEditor.tsx
  22. 2
      public/app/plugins/panel/xychart/v2/migrations.ts
  23. 2
      public/app/plugins/panel/xychart/v2/utils.ts
  24. 8
      public/app/types/appEvent.ts
  25. 18
      public/app/types/events.ts
  26. 4
      public/swagger/K8sNameLookup.tsx
  27. 2
      public/swagger/index.tsx
  28. 4
      public/test/core/redux/reduxTester.ts
  29. 4
      public/test/core/thunk/thunkTester.ts
  30. 7
      public/test/lib/common.ts
  31. 66
      public/test/specs/helpers.ts

@ -6259,8 +6259,7 @@ exports[`better eslint`] = {
], ],
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx:5381": [ "public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"]
[0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/plugins/datasource/grafana-testdata-datasource/components/index.ts:5381": [ "public/app/plugins/datasource/grafana-testdata-datasource/components/index.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`./StreamingClientEditor\`)", "0"], [0, 0, 0, "Do not re-export imported variable (\`./StreamingClientEditor\`)", "0"],
@ -6270,9 +6269,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/webpack.config.ts:5381": [ "public/app/plugins/datasource/grafana-testdata-datasource/webpack.config.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"] [0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
], ],
@ -6321,7 +6317,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "2"] [0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx:5381": [ "public/app/plugins/datasource/graphite/components/MetricTankMetaInspector.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"], [0, 0, 0, "Styles should be written using objects.", "2"],
[0, 0, 0, "Styles should be written using objects.", "3"], [0, 0, 0, "Styles should be written using objects.", "3"],
@ -6330,8 +6326,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "6"], [0, 0, 0, "Styles should be written using objects.", "6"],
[0, 0, 0, "Styles should be written using objects.", "7"], [0, 0, 0, "Styles should be written using objects.", "7"],
[0, 0, 0, "Styles should be written using objects.", "8"], [0, 0, 0, "Styles should be written using objects.", "8"],
[0, 0, 0, "Styles should be written using objects.", "9"], [0, 0, 0, "Styles should be written using objects.", "9"]
[0, 0, 0, "Styles should be written using objects.", "10"]
], ],
"public/app/plugins/datasource/graphite/components/TagsSection.tsx:5381": [ "public/app/plugins/datasource/graphite/components/TagsSection.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
@ -6374,8 +6369,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "26"], [0, 0, 0, "Unexpected any. Specify a different type.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"], [0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"], [0, 0, 0, "Unexpected any. Specify a different type.", "28"],
[0, 0, 0, "Unexpected any. Specify a different type.", "29"], [0, 0, 0, "Unexpected any. Specify a different type.", "29"]
[0, 0, 0, "Unexpected any. Specify a different type.", "30"]
], ],
"public/app/plugins/datasource/graphite/gfunc.ts:5381": [ "public/app/plugins/datasource/graphite/gfunc.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@ -6398,14 +6392,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"], [0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"], [0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"], [0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"], [0, 0, 0, "Unexpected any. Specify a different type.", "16"]
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"]
], ],
"public/app/plugins/datasource/graphite/lexer.ts:5381": [ "public/app/plugins/datasource/graphite/lexer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6474,10 +6465,7 @@ exports[`better eslint`] = {
], ],
"public/app/plugins/datasource/influxdb/influx_query_model.ts:5381": [ "public/app/plugins/datasource/influxdb/influx_query_model.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "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"]
], ],
"public/app/plugins/datasource/influxdb/influx_series.ts:5381": [ "public/app/plugins/datasource/influxdb/influx_series.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6491,17 +6479,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"]
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"]
],
"public/app/plugins/datasource/influxdb/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/plugins/datasource/influxdb/query_part.ts:5381": [ "public/app/plugins/datasource/influxdb/query_part.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6517,8 +6495,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"], [0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"], [0, 0, 0, "Unexpected any. Specify a different type.", "13"]
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
], ],
"public/app/plugins/datasource/influxdb/response_parser.ts:5381": [ "public/app/plugins/datasource/influxdb/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -6631,9 +6608,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"] [0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/plugins/datasource/loki/streaming.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/loki/types.ts:5381": [ "public/app/plugins/datasource/loki/types.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`LokiQueryDirection\`)", "0"], [0, 0, 0, "Do not re-export imported variable (\`LokiQueryDirection\`)", "0"],
[0, 0, 0, "Do not re-export imported variable (\`LokiQueryType\`)", "1"], [0, 0, 0, "Do not re-export imported variable (\`LokiQueryType\`)", "1"],
@ -6670,9 +6644,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "16"], [0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"] [0, 0, 0, "Unexpected any. Specify a different type.", "17"]
], ],
"public/app/plugins/datasource/opentsdb/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/parca/QueryEditor/LabelsEditor.tsx:5381": [ "public/app/plugins/datasource/parca/QueryEditor/LabelsEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"] [0, 0, 0, "Styles should be written using objects.", "1"]
@ -6744,12 +6715,8 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/tempo/resultTransformer.ts:5381": [ "public/app/plugins/datasource/tempo/resultTransformer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
], ],
"public/app/plugins/datasource/tempo/webpack.config.ts:5381": [ "public/app/plugins/datasource/tempo/webpack.config.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"] [0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
@ -6813,9 +6780,6 @@ exports[`better eslint`] = {
"public/app/plugins/panel/barchart/quadtree.ts:5381": [ "public/app/plugins/panel/barchart/quadtree.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/plugins/panel/barchart/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/candlestick/CandlestickPanel.tsx:5381": [ "public/app/plugins/panel/candlestick/CandlestickPanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@ -6953,12 +6917,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Do not use any type assertions.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"] [0, 0, 0, "Do not use any type assertions.", "16"]
], ],
"public/app/plugins/panel/histogram/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [ "public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"]
[0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/plugins/panel/live/LivePanel.tsx:5381": [ "public/app/plugins/panel/live/LivePanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@ -7072,17 +7032,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
], ],
"public/app/plugins/panel/text/TextPanel.tsx:5381": [ "public/app/plugins/panel/text/TextPanel.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"] [0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/plugins/panel/text/TextPanelEditor.tsx:5381": [ "public/app/plugins/panel/text/TextPanelEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"]
[0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/plugins/panel/text/textPanelMigrationHandler.ts:5381": [ "public/app/plugins/panel/text/textPanelMigrationHandler.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -7146,9 +7103,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "5"] [0, 0, 0, "Styles should be written using objects.", "5"]
], ],
"public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [ "public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"]
[0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/plugins/panel/xychart/ManualEditor.tsx:5381": [ "public/app/plugins/panel/xychart/ManualEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
@ -7173,12 +7129,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"]
[0, 0, 0, "Do not use any type assertions.", "4"]
], ],
"public/app/plugins/panel/xychart/v2/migrations.ts:5381": [ "public/app/plugins/panel/xychart/v2/migrations.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/plugins/panel/xychart/v2/scatter.ts:5381": [ "public/app/plugins/panel/xychart/v2/scatter.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@ -7200,9 +7154,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "16"], [0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"] [0, 0, 0, "Do not use any type assertions.", "17"]
], ],
"public/app/plugins/panel/xychart/v2/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/sdk.ts:5381": [ "public/app/plugins/sdk.ts:5381": [
[0, 0, 0, "Do not re-export imported variable (\`loadPluginCss\`)", "0"] [0, 0, 0, "Do not re-export imported variable (\`loadPluginCss\`)", "0"]
], ],
@ -7228,9 +7179,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [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.", "4"]
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
], ],
"public/app/types/dashboard.ts:5381": [ "public/app/types/dashboard.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -7244,11 +7193,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [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.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"], [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.", "8"]
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
], ],
"public/app/types/index.ts:5381": [ "public/app/types/index.ts:5381": [
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"], [0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"],
@ -7292,18 +7237,13 @@ exports[`better eslint`] = {
"public/app/types/unified-alerting-dto.ts:5381": [ "public/app/types/unified-alerting-dto.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"public/swagger/K8sNameLookup.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/swagger/SwaggerPage.tsx:5381": [ "public/swagger/SwaggerPage.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
], ],
"public/swagger/index.tsx:5381": [ "public/swagger/index.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
], ],
"public/swagger/plugins.tsx:5381": [ "public/swagger/plugins.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -7313,8 +7253,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/test/core/thunk/thunkTester.ts:5381": [ "public/test/core/thunk/thunkTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -7322,9 +7261,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [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.", "5"]
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
], ],
"public/test/global-jquery-shim.ts:5381": [ "public/test/global-jquery-shim.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -7338,21 +7275,12 @@ exports[`better eslint`] = {
"public/test/jest-setup.ts:5381": [ "public/test/jest-setup.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/test/lib/common.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/specs/helpers.ts:5381": [ "public/test/specs/helpers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [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, "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, "Unexpected any. Specify a different type.", "10"]
] ]
}` }`
}; };

@ -4,10 +4,12 @@ import { FormEvent, useState, ChangeEvent } from 'react';
import { DataFrameSchema, FieldSchema, GrafanaTheme2 } from '@grafana/data'; import { DataFrameSchema, FieldSchema, GrafanaTheme2 } from '@grafana/data';
import { useStyles2, TextArea, InlineField, Input, FieldSet, InlineSwitch } from '@grafana/ui'; import { useStyles2, TextArea, InlineField, Input, FieldSet, InlineSwitch } from '@grafana/ui';
type Config = Record<string, any>;
interface SchemaFormProps { interface SchemaFormProps {
config: Record<string, any>; config: Config;
schema: DataFrameSchema; schema: DataFrameSchema;
onChange: (config: Record<string, any>) => void; onChange: (config: Config) => void;
} }
const renderInput = (field: FieldSchema, onChange: SchemaFormProps['onChange'], config: SchemaFormProps['config']) => { const renderInput = (field: FieldSchema, onChange: SchemaFormProps['onChange'], config: SchemaFormProps['config']) => {

@ -215,7 +215,9 @@ export function runFetchStream(
}, },
}); });
const processChunk = (value: ReadableStreamReadResult<Uint8Array>): any => { const processChunk = async (
value: ReadableStreamReadResult<Uint8Array>
): Promise<ReadableStreamReadResult<Uint8Array> | undefined> => {
if (value.value) { if (value.value) {
const text = new TextDecoder().decode(value.value); const text = new TextDecoder().decode(value.value);
csv.readCSV(text); csv.readCSV(text);

@ -96,8 +96,9 @@ export class MetricTankMetaInspector extends PureComponent<Props, State> {
const seriesMetas: Record<string, MetricTankSeriesMeta> = {}; const seriesMetas: Record<string, MetricTankSeriesMeta> = {};
for (const series of data) { for (const series of data) {
if (series?.meta?.custom?.seriesMetaList) { const seriesMetaList: MetricTankSeriesMeta[] | undefined = series?.meta?.custom?.seriesMetaList;
for (const metaItem of series.meta.custom.seriesMetaList as MetricTankSeriesMeta[]) { if (seriesMetaList) {
for (const metaItem of seriesMetaList) {
// key is to dedupe as many series will have identitical meta // key is to dedupe as many series will have identitical meta
const key = `${JSON.stringify(metaItem)}`; const key = `${JSON.stringify(metaItem)}`;

@ -494,7 +494,7 @@ export class GraphiteDatasource
} }
metricFindQuery(findQuery: string | GraphiteQuery, optionalOptions?: any): Promise<MetricFindValue[]> { metricFindQuery(findQuery: string | GraphiteQuery, optionalOptions?: any): Promise<MetricFindValue[]> {
const options: any = optionalOptions || {}; const options = optionalOptions || {};
const queryObject = convertToGraphiteQueryObject(findQuery); const queryObject = convertToGraphiteQueryObject(findQuery);
if (queryObject.queryType === GraphiteQueryType.Value || queryObject.queryType === GraphiteQueryType.MetricName) { if (queryObject.queryType === GraphiteQueryType.Value || queryObject.queryType === GraphiteQueryType.MetricName) {

@ -39,9 +39,9 @@ export default class GraphiteQuery {
checkOtherSegmentsIndex = 0; checkOtherSegmentsIndex = 0;
removeTagValue: string; removeTagValue: string;
templateSrv: any; templateSrv: any;
scopedVars: any; scopedVars?: ScopedVars;
constructor(datasource: any, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) { constructor(datasource: GraphiteDatasource, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) {
this.datasource = datasource; this.datasource = datasource;
this.target = target; this.target = target;
this.templateSrv = templateSrv; this.templateSrv = templateSrv;
@ -153,7 +153,7 @@ export default class GraphiteQuery {
} }
} }
updateSegmentValue(segment: any, index: number) { updateSegmentValue(segment: GraphiteSegment, index: number) {
this.segments[index].value = segment.value; this.segments[index].value = segment.value;
} }

@ -122,7 +122,7 @@ export default class InfluxQueryModel {
this.updateProjection(); this.updateProjection();
} }
removeSelectPart(selectParts: any[], part: any) { removeSelectPart(selectParts: QueryPart[], part: QueryPart) {
// if we remove the field remove the whole statement // if we remove the field remove the whole statement
if (part.def.type === 'field') { if (part.def.type === 'field') {
if (this.selectModels.length > 1) { if (this.selectModels.length > 1) {
@ -137,7 +137,7 @@ export default class InfluxQueryModel {
this.updatePersistedParts(); this.updatePersistedParts();
} }
addSelectPart(selectParts: any[], type: string) { addSelectPart(selectParts: QueryPart[], type: string) {
const partModel = queryPart.create({ type: type }); const partModel = queryPart.create({ type: type });
partModel.def.addStrategy(selectParts, partModel, this); partModel.def.addStrategy(selectParts, partModel, this);
this.updatePersistedParts(); this.updatePersistedParts();

@ -266,7 +266,9 @@ describe('when generating timeseries from influxdb response', () => {
describe('with empty tagsColumn', () => { describe('with empty tagsColumn', () => {
const options = { const options = {
alias: '', alias: '',
annotation: {}, annotation: {
refId: '',
},
series: [ series: [
{ {
name: 'logins.count', name: 'logins.count',
@ -290,6 +292,7 @@ describe('when generating timeseries from influxdb response', () => {
alias: '', alias: '',
annotation: { annotation: {
tagsColumn: 'datacenter, source', tagsColumn: 'datacenter, source',
refId: '',
}, },
series: [ series: [
{ {

@ -3,14 +3,22 @@ import { each, map, includes, flatten, keys } from 'lodash';
import { FieldType, QueryResultMeta, TimeSeries, TableData } from '@grafana/data'; import { FieldType, QueryResultMeta, TimeSeries, TableData } from '@grafana/data';
import TableModel from 'app/core/TableModel'; import TableModel from 'app/core/TableModel';
import { InfluxQuery } from './types';
export default class InfluxSeries { export default class InfluxSeries {
refId?: string; refId?: string;
series: any; series: any;
alias: any; alias?: string;
annotation: any; annotation?: InfluxQuery;
meta?: QueryResultMeta; meta?: QueryResultMeta;
constructor(options: { series: any; alias?: any; annotation?: any; meta?: QueryResultMeta; refId?: string }) { constructor(options: {
series: any;
alias?: string;
annotation?: InfluxQuery;
meta?: QueryResultMeta;
refId?: string;
}) {
this.series = options.series; this.series = options.series;
this.alias = options.alias; this.alias = options.alias;
this.annotation = options.annotation; this.annotation = options.annotation;
@ -70,7 +78,7 @@ export default class InfluxSeries {
const regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g; const regex = /\$(\w+)|\[\[([\s\S]+?)\]\]/g;
const segments = series.name.split('.'); const segments = series.name.split('.');
return this.alias.replace(regex, (match: any, g1: any, g2: any) => { return this.alias?.replace(regex, (match, g1, g2) => {
const group = g1 || g2; const group = g1 || g2;
const segIndex = parseInt(group, 10); const segIndex = parseInt(group, 10);
@ -113,19 +121,19 @@ export default class InfluxSeries {
if (column === 'sequence_number') { if (column === 'sequence_number') {
return; return;
} }
if (column === this.annotation.titleColumn) { if (column === this.annotation?.titleColumn) {
titleCol = index; titleCol = index;
return; return;
} }
if (includes((this.annotation.tagsColumn || '').replace(' ', '').split(','), column)) { if (includes((this.annotation?.tagsColumn || '').replace(' ', '').split(','), column)) {
tagsCol.push(index); tagsCol.push(index);
return; return;
} }
if (column === this.annotation.textColumn) { if (column === this.annotation?.textColumn) {
textCol = index; textCol = index;
return; return;
} }
if (column === this.annotation.timeEndColumn) { if (column === this.annotation?.timeEndColumn) {
timeEndCol = index; timeEndCol = index;
return; return;
} }

@ -1,3 +1,5 @@
import { AnnotationQuery, AnnotationSupport } from '@grafana/data';
import { InfluxQuery, InfluxQueryTag } from './types'; import { InfluxQuery, InfluxQueryTag } from './types';
type LegacyAnnotation = { type LegacyAnnotation = {
@ -52,8 +54,9 @@ const migrateLegacyAnnotation = (json: LegacyAnnotation) => {
return target; return target;
}; };
// eslint-ignore-next-line export const prepareAnnotation: AnnotationSupport<InfluxQuery, AnnotationQuery<InfluxQuery>>['prepareAnnotation'] = (
export const prepareAnnotation = (json: any) => { json
) => {
// make sure that any additional target fields are migrated // make sure that any additional target fields are migrated
json.target = json.target && !json.target?.query ? migrateLegacyAnnotation(json) : json.target; json.target = json.target && !json.target?.query ? migrateLegacyAnnotation(json) : json.target;

@ -3,7 +3,7 @@ import { clone, map } from 'lodash';
import { functionRenderer, QueryPart, QueryPartDef, suffixRenderer } from 'app/features/alerting/state/query_part'; import { functionRenderer, QueryPart, QueryPartDef, suffixRenderer } from 'app/features/alerting/state/query_part';
const index: any[] = []; const index: any[] = [];
const categories: any = { const categories = {
Aggregations: [], Aggregations: [],
Selectors: [], Selectors: [],
Transformations: [], Transformations: [],

@ -4,6 +4,7 @@ import {
DataFrameJSON, DataFrameJSON,
DataQueryRequest, DataQueryRequest,
DataQueryResponse, DataQueryResponse,
LiveChannelEvent,
LiveChannelScope, LiveChannelScope,
LoadingState, LoadingState,
StreamingDataFrame, StreamingDataFrame,
@ -43,8 +44,8 @@ export function doLokiChannelStream(
} }
let frame: StreamingDataFrame | undefined = undefined; let frame: StreamingDataFrame | undefined = undefined;
const updateFrame = (msg: any) => { const updateFrame = (msg: LiveChannelEvent<unknown>) => {
if (msg?.message) { if ('message' in msg && msg.message) {
const p: DataFrameJSON = msg.message; const p: DataFrameJSON = msg.message;
if (!frame) { if (!frame) {
frame = StreamingDataFrame.fromDataFrameJSON(p, { frame = StreamingDataFrame.fromDataFrameJSON(p, {

@ -1,4 +1,6 @@
import { LegacyAnnotation } from './types'; import { AnnotationQuery, AnnotationSupport } from '@grafana/data';
import { LegacyAnnotation, OpenTsdbQuery } from './types';
// this becomes the target in the migrated annotations // this becomes the target in the migrated annotations
const migrateLegacyAnnotation = (json: LegacyAnnotation) => { const migrateLegacyAnnotation = (json: LegacyAnnotation) => {
@ -13,8 +15,10 @@ const migrateLegacyAnnotation = (json: LegacyAnnotation) => {
return annotation; return annotation;
}; };
// eslint-ignore-next-line export const prepareAnnotation: AnnotationSupport<
export const prepareAnnotation = (json: any) => { OpenTsdbQuery,
AnnotationQuery<OpenTsdbQuery>
>['prepareAnnotation'] = (json) => {
const resultingTarget = json.target && typeof json.target !== 'string' ? json.target : migrateLegacyAnnotation(json); const resultingTarget = json.target && typeof json.target !== 'string' ? json.target : migrateLegacyAnnotation(json);
json.target = resultingTarget; json.target = resultingTarget;

@ -48,11 +48,11 @@ function getAttributeValue(value: collectorTypes.opentelemetryProto.common.v1.An
} }
if (value.intValue !== undefined) { if (value.intValue !== undefined) {
return Number.parseInt(value.intValue as any, 10); return Number.parseInt(String(value.intValue), 10);
} }
if (value.doubleValue) { if (value.doubleValue) {
return Number.parseFloat(value.doubleValue as any); return Number.parseFloat(String(value.doubleValue));
} }
if (value.arrayValue) { if (value.arrayValue) {

@ -52,7 +52,7 @@ interface BarSeries {
export function prepSeries( export function prepSeries(
frames: DataFrame[], frames: DataFrame[],
fieldConfig: FieldConfigSource<any>, fieldConfig: FieldConfigSource,
stacking: StackingMode, stacking: StackingMode,
theme: GrafanaTheme2, theme: GrafanaTheme2,
xFieldName?: string, xFieldName?: string,

@ -38,11 +38,10 @@ export const changeToHistogramPanelMigrationHandler: PanelTypeChangedHandler = (
return {}; return {};
}; };
function graphToHistogramOptions(angular: any): { function graphToHistogramOptions(graphOptions: GraphOptions): {
fieldConfig: FieldConfigSource; fieldConfig: FieldConfigSource;
options: Options; options: Options;
} { } {
const graphOptions: GraphOptions = angular;
let histogramFieldConfig: HistogramFieldConfig = {}; let histogramFieldConfig: HistogramFieldConfig = {};
const options: Options = { const options: Options = {
legend: { legend: {

@ -15,7 +15,7 @@ import { getManagedChannelInfo } from 'app/features/live/info';
import { LivePanelOptions } from './types'; import { LivePanelOptions } from './types';
type Props = StandardEditorProps<Partial<LiveChannelAddress>, any, LivePanelOptions>; type Props = StandardEditorProps<Partial<LiveChannelAddress>, {}, LivePanelOptions>;
const scopes: Array<SelectableValue<LiveChannelScope>> = [ const scopes: Array<SelectableValue<LiveChannelScope>> = [
{ label: 'Grafana', value: LiveChannelScope.Grafana, description: 'Core grafana live features' }, { label: 'Grafana', value: LiveChannelScope.Grafana, description: 'Core grafana live features' },

@ -75,7 +75,7 @@ const generateThresholds = (thresholds: string[], colors: string[]) => {
}; };
const migrateTransformations = ( const migrateTransformations = (
panel: PanelModel<Partial<Options>> | any, panel: PanelModel<Partial<Options>>,
oldOpts: { columns: any; transform: Transformations } oldOpts: { columns: any; transform: Transformations }
) => { ) => {
const transformations: Transformation[] = panel.transformations ?? []; const transformations: Transformation[] = panel.transformations ?? [];
@ -237,7 +237,7 @@ const migrateDefaults = (prevDefaults: Style) => {
* This is called when the panel changes from another panel * This is called when the panel changes from another panel
*/ */
export const tablePanelChangedHandler = ( export const tablePanelChangedHandler = (
panel: PanelModel<Partial<Options>> | any, panel: PanelModel<Partial<Options>>,
prevPluginId: string, prevPluginId: string,
prevOptions: any prevOptions: any
) => { ) => {

@ -12,7 +12,7 @@ import {
import { Options, TextMode } from './panelcfg.gen'; import { Options, TextMode } from './panelcfg.gen';
export const TextPanelEditor = ({ value, onChange, context }: StandardEditorProps<string, any, Options>) => { export const TextPanelEditor = ({ value, onChange, context }: StandardEditorProps<string, {}, Options>) => {
const language = useMemo(() => context.options?.mode ?? TextMode.Markdown, [context]); const language = useMemo(() => context.options?.mode ?? TextMode.Markdown, [context]);
const styles = useStyles2(getStyles); const styles = useStyles2(getStyles);

@ -19,7 +19,7 @@ interface XYInfo {
yFields: Array<SelectableValue<boolean>>; yFields: Array<SelectableValue<boolean>>;
} }
export const AutoEditor = ({ value, onChange, context }: StandardEditorProps<XYDimensionConfig, any, Options>) => { export const AutoEditor = ({ value, onChange, context }: StandardEditorProps<XYDimensionConfig, {}, Options>) => {
const frameNames = useMemo(() => { const frameNames = useMemo(() => {
if (context?.data?.length) { if (context?.data?.length) {
return context.data.map((f, idx) => ({ return context.data.map((f, idx) => ({

@ -26,7 +26,7 @@ export const SeriesEditor = ({
const style = useStyles2(getStyles); const style = useStyles2(getStyles);
// reset opts when mapping changes (no way to do this in panel opts builder?) // reset opts when mapping changes (no way to do this in panel opts builder?)
const mapping = context.options?.mapping as SeriesMapping; const mapping = context.options?.mapping;
const prevMapping = usePrevious(mapping); const prevMapping = usePrevious(mapping);
const mappingChanged = prevMapping != null && mapping !== prevMapping; const mappingChanged = prevMapping != null && mapping !== prevMapping;

@ -11,7 +11,7 @@ export const xyChartMigrationHandler = (panel: PanelModel): Options => {
return migrateOptions(panel); return migrateOptions(panel);
} }
return panel.options as Options; return panel.options;
}; };
function migrateOptions(panel: PanelModel): Options { function migrateOptions(panel: PanelModel): Options {

@ -40,7 +40,7 @@ export function prepSeries(
mapping: SeriesMapping, mapping: SeriesMapping,
mappedSeries: XYSeriesConfig[], mappedSeries: XYSeriesConfig[],
frames: DataFrame[], frames: DataFrame[],
fieldConfig: FieldConfigSource<any> fieldConfig: FieldConfigSource
) { ) {
cacheFieldDisplayNames(frames); cacheFieldDisplayNames(frames);
decoupleHideFromState(frames, fieldConfig); decoupleHideFromState(frames, fieldConfig);

@ -17,6 +17,10 @@ export interface AppEventEmitter {
} }
export interface AppEventConsumer { export interface AppEventConsumer {
onAppEvent(name: string, callback: (event: IAngularEvent, ...args: any[]) => void, localScope?: any): void; onAppEvent(name: string, callback: (event: IAngularEvent, ...args: unknown[]) => void, localScope?: any): void;
onAppEvent<T>(event: AppEvent<T>, callback: (event: IAngularEvent, ...args: any[]) => void, localScope?: any): void; onAppEvent<T>(
event: AppEvent<T>,
callback: (event: IAngularEvent, ...args: unknown[]) => void,
localScope?: any
): void;
} }

@ -44,20 +44,6 @@ export interface ShowConfirmModalPayload {
onAltAction?: () => void; onAltAction?: () => void;
} }
export interface DataSourceResponse<T> {
data: T;
readonly status: number;
readonly statusText: string;
readonly ok: boolean;
readonly headers: Headers;
readonly redirected: boolean;
readonly type: ResponseType;
readonly url: string;
readonly config: any;
}
type DataSourceResponsePayload = DataSourceResponse<any>;
export interface ToggleKioskModePayload { export interface ToggleKioskModePayload {
exit?: boolean; exit?: boolean;
} }
@ -70,7 +56,7 @@ export interface GraphClickedPayload {
export interface ThresholdChangedPayload { export interface ThresholdChangedPayload {
threshold: any; threshold: any;
handleIndex: any; handleIndex: number;
} }
export interface DashScrollPayload { export interface DashScrollPayload {
@ -85,8 +71,6 @@ export interface PanelChangeViewPayload {}
* Events * Events
*/ */
export const dsRequestResponse = eventFactory<DataSourceResponsePayload>('ds-request-response');
export const dsRequestError = eventFactory<any>('ds-request-error');
export const templateVariableValueUpdated = eventFactory('template-variable-value-updated'); export const templateVariableValueUpdated = eventFactory('template-variable-value-updated');
export const graphClicked = eventFactory<GraphClickedPayload>('graph-click'); export const graphClicked = eventFactory<GraphClickedPayload>('graph-click');

@ -49,12 +49,12 @@ export function K8sNameLookup(props: Props) {
console.log('LIST', url, table); console.log('LIST', url, table);
const options: Array<SelectableValue<string>> = []; const options: Array<SelectableValue<string>> = [];
if (table.rows?.length) { if (table.rows?.length) {
table.rows.forEach((row: any) => { for (const row of table.rows) {
const n = row.object?.metadata?.name; const n = row.object?.metadata?.name;
if (n) { if (n) {
options.push({ label: n, value: n }); options.push({ label: n, value: n });
} }
}); }
} else { } else {
setPlaceholder('No items found'); setPlaceholder('No items found');
} }

@ -29,7 +29,7 @@ const tt = window.trustedTypes;
if (tt?.createPolicy) { if (tt?.createPolicy) {
tt.createPolicy('default', { tt.createPolicy('default', {
createHTML: (string, sink) => DOMPurify.sanitize(string, { RETURN_TRUSTED_TYPE: true }) as unknown as string, createHTML: (string, sink) => DOMPurify.sanitize(string, { RETURN_TRUSTED_TYPE: true }) as unknown as string,
createScriptURL: (url, sink) => textUtil.sanitizeUrl(url) as unknown as string, createScriptURL: (url, sink) => textUtil.sanitizeUrl(url),
createScript: (script, sink) => script, createScript: (script, sink) => script,
}); });
} }

@ -1,5 +1,5 @@
import { AnyAction, configureStore, EnhancedStore, Reducer, Tuple } from '@reduxjs/toolkit'; import { AnyAction, configureStore, EnhancedStore, Reducer, Tuple } from '@reduxjs/toolkit';
import { Middleware, StoreEnhancer, UnknownAction } from 'redux'; import { Middleware, Store, StoreEnhancer, UnknownAction } from 'redux';
import { thunk, ThunkDispatch, ThunkMiddleware } from 'redux-thunk'; import { thunk, ThunkDispatch, ThunkMiddleware } from 'redux-thunk';
import { setStore } from '../../../app/store/store'; import { setStore } from '../../../app/store/store';
@ -79,7 +79,7 @@ export const reduxTester = <State>(args?: ReduxTesterArguments<State>): ReduxTes
preloadedState, preloadedState,
}); });
setStore(store as any); setStore(store as Store<StoreState>);
return instance; return instance;
}; };

@ -9,7 +9,7 @@ export interface ThunkGiven {
} }
export interface ThunkWhen { export interface ThunkWhen {
whenThunkIsDispatched: (...args: any) => Promise<Array<PayloadAction<any>>>; whenThunkIsDispatched: (...args: unknown[]) => Promise<Array<PayloadAction<any>>>;
} }
export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven => { export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven => {
@ -23,7 +23,7 @@ export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven
return instance; return instance;
}; };
const whenThunkIsDispatched = async (...args: any): Promise<Array<PayloadAction<any>>> => { const whenThunkIsDispatched = async (...args: unknown[]): Promise<Array<PayloadAction<any>>> => {
await store.dispatch(thunkUnderTest(...args)); await store.dispatch(thunkUnderTest(...args));
dispatchedActions = store.getActions(); dispatchedActions = store.getActions();

@ -1,7 +0,0 @@
const _global = window as any;
const angularMocks = {
module: _global.module,
inject: _global.inject,
};
export { angularMocks };

@ -1,13 +1,10 @@
import { each, template } from 'lodash'; import { template } from 'lodash';
import { RawTimeRange, PanelPluginMeta, dateMath } from '@grafana/data'; import { RawTimeRange, PanelPluginMeta, dateMath } from '@grafana/data';
import { GrafanaRootScope } from 'app/angular/GrafanaCtrl';
import config from 'app/core/config'; import config from 'app/core/config';
import { ContextSrv } from 'app/core/services/context_srv'; import { ContextSrv } from 'app/core/services/context_srv';
import { PanelModel } from 'app/features/dashboard/state/PanelModel'; import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import { angularMocks } from '../lib/common';
export function ControllerTestContext(this: any) { export function ControllerTestContext(this: any) {
const self = this; const self = this;
@ -30,75 +27,16 @@ export function ControllerTestContext(this: any) {
}; };
this.isUtc = false; this.isUtc = false;
this.providePhase = (mocks: any) => {
return angularMocks.module(($provide: any) => {
$provide.value('contextSrv', self.contextSrv);
$provide.value('datasourceSrv', self.datasourceSrv);
$provide.value('annotationsSrv', self.annotationsSrv);
$provide.value('timeSrv', self.timeSrv);
$provide.value('templateSrv', self.templateSrv);
$provide.value('$element', self.$element);
$provide.value('$sanitize', self.$sanitize);
each(mocks, (value, key) => {
$provide.value(key, value);
});
});
};
this.createPanelController = (Ctrl: any) => { this.createPanelController = (Ctrl: any) => {
return angularMocks.inject(($controller: any, $rootScope: GrafanaRootScope, $browser: any) => { return () => {
self.scope = $rootScope.$new();
self.$browser = $browser;
self.panel = new PanelModel({ type: 'test' }); self.panel = new PanelModel({ type: 'test' });
self.dashboard = { meta: {} }; self.dashboard = { meta: {} };
self.isUtc = false; self.isUtc = false;
self.dashboard.getTimezone = () => { self.dashboard.getTimezone = () => {
return self.isUtc ? 'utc' : 'browser'; return self.isUtc ? 'utc' : 'browser';
}; };
$rootScope.appEvent = jest.fn();
$rootScope.onAppEvent = jest.fn();
$rootScope.colors = [];
for (let i = 0; i < 50; i++) {
$rootScope.colors.push('#' + i);
}
config.panels['test'] = { info: {} } as PanelPluginMeta; config.panels['test'] = { info: {} } as PanelPluginMeta;
self.ctrl = $controller(
Ctrl,
{ $scope: self.scope },
{
panel: self.panel,
dashboard: self.dashboard,
}
);
});
}; };
this.createControllerPhase = (controllerName: string) => {
return angularMocks.inject(($controller: any, $rootScope: GrafanaRootScope, $browser: any) => {
self.scope = $rootScope.$new();
self.$browser = $browser;
self.scope.contextSrv = {};
self.scope.panel = {};
self.scope.dashboard = { meta: {} };
self.scope.dashboardMeta = {};
self.scope.dashboardViewState = DashboardViewStateStub();
self.scope.appEvent = jest.fn();
self.scope.onAppEvent = jest.fn();
$rootScope.colors = [];
for (let i = 0; i < 50; i++) {
$rootScope.colors.push('#' + i);
}
self.scope.skipDataOnInit = true;
self.scope.skipAutoInit = true;
self.controller = $controller(controllerName, {
$scope: self.scope,
});
});
}; };
this.setIsUtc = (isUtc = false) => { this.setIsUtc = (isUtc = false) => {

Loading…
Cancel
Save