Chore: Various type improvements (#77877)

* more datasource type fixes

* more type updates
pull/77964/head
Ashley Harrison 2 years ago committed by GitHub
parent 323ee7c38c
commit 40fd80c46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 153
      .betterer.results
  2. 7
      public/app/features/variables/datasource/actions.test.ts
  3. 2
      public/app/features/variables/shared/testing/datasourceVariableBuilder.ts
  4. 2
      public/app/features/variables/shared/testing/optionsVariableBuilder.ts
  5. 14
      public/app/features/variables/state/actions.ts
  6. 2
      public/app/features/variables/system/adapter.ts
  7. 2
      public/app/features/variables/utils.ts
  8. 4
      public/app/plugins/datasource/cloud-monitoring/CloudMonitoringMetricFindQuery.ts
  9. 10
      public/app/plugins/datasource/cloud-monitoring/components/AliasBy.tsx
  10. 2
      public/app/plugins/datasource/cloud-monitoring/components/MQLQueryEditor.tsx
  11. 12
      public/app/plugins/datasource/cloud-monitoring/components/VariableQueryEditor.tsx
  12. 2
      public/app/plugins/datasource/cloud-monitoring/components/VisualMetricQueryEditor.tsx
  13. 6
      public/app/plugins/datasource/cloud-monitoring/datasource.ts
  14. 10
      public/app/plugins/datasource/cloud-monitoring/functions.ts
  15. 4
      public/app/plugins/datasource/cloudwatch/utils/datalinks.ts
  16. 2
      public/app/plugins/datasource/cloudwatch/utils/logsRetry.ts
  17. 16
      public/app/plugins/datasource/elasticsearch/ElasticResponse.ts
  18. 25
      public/app/plugins/datasource/elasticsearch/QueryBuilder.ts
  19. 2
      public/app/plugins/datasource/elasticsearch/components/AddRemove.tsx
  20. 2
      public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.tsx
  21. 2
      public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/state/actions.ts
  22. 2
      public/app/plugins/datasource/elasticsearch/components/QueryEditor/ElasticsearchQueryContext.tsx
  23. 6
      public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/actions.ts
  24. 2
      public/app/plugins/datasource/elasticsearch/datasource.ts
  25. 2
      public/app/plugins/datasource/grafana-testdata-datasource/ConfigEditor.tsx
  26. 4
      public/app/plugins/datasource/grafana-testdata-datasource/QueryEditor.tsx
  27. 12
      public/app/plugins/datasource/grafana-testdata-datasource/components/RandomWalkEditor.tsx
  28. 2
      public/app/plugins/datasource/grafana-testdata-datasource/components/RawFrameEditor.tsx
  29. 3
      public/app/plugins/datasource/grafana-testdata-datasource/nodeGraphUtils.ts
  30. 6
      public/app/plugins/datasource/grafana/components/SearchEditor.tsx
  31. 6
      public/app/plugins/datasource/grafana/datasource.ts
  32. 8
      public/app/plugins/datasource/graphite/components/FunctionEditor.tsx

@ -5387,13 +5387,9 @@ 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/variables/shared/testing/datasourceVariableBuilder.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/variables/shared/testing/optionsVariableBuilder.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, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/features/variables/shared/testing/variableBuilder.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@ -5404,15 +5400,9 @@ exports[`better eslint`] = {
[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.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"]
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/app/features/variables/state/keyedVariablesReducer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5443,13 +5433,12 @@ exports[`better eslint`] = {
"public/app/features/variables/system/adapter.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.", "2"],
[0, 0, 0, "Do not use any type assertions.", "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.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/app/features/variables/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5466,9 +5455,7 @@ exports[`better eslint`] = {
[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, "Do not use any type assertions.", "9"]
[0, 0, 0, "Do not use any type assertions.", "7"]
],
"public/app/features/visualization/data-hover/DataHoverRows.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
@ -5504,8 +5491,7 @@ exports[`better eslint`] = {
],
"public/app/plugins/datasource/cloud-monitoring/CloudMonitoringMetricFindQuery.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, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/annotationSupport.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@ -5514,41 +5500,24 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/cloud-monitoring/components/Aggregation.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/AliasBy.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/components/CloudMonitoringCheatSheet.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/MQLQueryEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/VariableQueryEditor.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, "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, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/VisualMetricQueryEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/datasource.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, "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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"]
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/datasource/cloud-monitoring/functions.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, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/types/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -5604,12 +5573,10 @@ exports[`better eslint`] = {
],
"public/app/plugins/datasource/cloudwatch/utils/datalinks.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.", "1"]
],
"public/app/plugins/datasource/cloudwatch/utils/logsRetry.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"]
],
"public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@ -5639,12 +5606,12 @@ exports[`better eslint`] = {
[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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Do not use any type assertions.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Do not use any type assertions.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[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.", "28"],
@ -5654,17 +5621,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"],
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Unexpected any. Specify a different type.", "36"],
[0, 0, 0, "Unexpected any. Specify a different type.", "37"],
[0, 0, 0, "Unexpected any. Specify a different type.", "38"],
[0, 0, 0, "Unexpected any. Specify a different type.", "39"],
[0, 0, 0, "Unexpected any. Specify a different type.", "40"],
[0, 0, 0, "Unexpected any. Specify a different type.", "41"],
[0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Unexpected any. Specify a different type.", "43"],
[0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Unexpected any. Specify a different type.", "45"]
[0, 0, 0, "Unexpected any. Specify a different type.", "35"]
],
"public/app/plugins/datasource/elasticsearch/LanguageProvider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5688,17 +5645,12 @@ exports[`better eslint`] = {
[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, "Do not use any type assertions.", "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, "Unexpected any. Specify a different type.", "12"]
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/plugins/datasource/elasticsearch/components/AddRemove.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/MetricPicker.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
@ -5715,21 +5667,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "2"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/SettingsEditor/TermsSettingsEditor.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"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/aggregations.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/state/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/BucketAggregationsEditor/state/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/ElasticsearchQueryContext.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@ -5749,11 +5694,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/actions.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/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@ -5797,8 +5737,7 @@ exports[`better eslint`] = {
[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, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/elasticsearch/hooks/useStatelessReducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@ -5810,26 +5749,17 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/ConfigEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/QueryEditor.tsx:5381": [
[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.", "2"],
[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, "Unexpected any. Specify a different type.", "6"]
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/components/RandomWalkEditor.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"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/components/RawFrameEditor.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, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationQueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@ -5847,9 +5777,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/nodeGraphUtils.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, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/grafana-testdata-datasource/runStreams.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -5867,11 +5795,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Styles should be written using objects.", "7"]
],
"public/app/plugins/datasource/grafana/components/SearchEditor.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"]
],
"public/app/plugins/datasource/grafana/components/TimePickerInput.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"],
@ -5890,22 +5813,18 @@ exports[`better eslint`] = {
[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"],
[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.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"]
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"]
],
"public/app/plugins/datasource/graphite/components/AddGraphiteFunction.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/plugins/datasource/graphite/components/FunctionEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/plugins/datasource/graphite/components/FunctionParamEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]

@ -29,7 +29,12 @@ function getTestContext({ sources = [], query, regex }: Args = {}) {
const getListMock = jest.fn().mockReturnValue(sources);
const getDatasourceSrvMock = jest.fn().mockReturnValue({ getList: getListMock });
const dependencies: DataSourceVariableActionDependencies = { getDatasourceSrv: getDatasourceSrvMock };
const datasource = datasourceBuilder().withId('0').withRootStateKey('key').withQuery(query).withRegEx(regex).build();
const datasource = datasourceBuilder()
.withId('0')
.withRootStateKey('key')
.withQuery(query!)
.withRegEx(regex!)
.build();
return { getListMock, getDatasourceSrvMock, dependencies, datasource };
}

@ -10,7 +10,7 @@ export class DatasourceVariableBuilder<
return this;
}
withRegEx(regex: any) {
withRegEx(regex: string) {
this.variable.regex = regex;
return this;
}

@ -35,7 +35,7 @@ export class OptionsVariableBuilder<T extends VariableWithOptions> extends Varia
return this;
}
withQuery(query: any) {
withQuery(query: string) {
this.variable.query = query;
return this;
}

@ -617,7 +617,7 @@ export const variableUpdated = (
};
const node = g.getNode(variableInState.name);
let promises: Array<Promise<any>> = [];
let promises: Array<Promise<void>> = [];
if (node) {
promises = node.getOptimizedInputEdges().map((e) => {
const variable = variables.find((v) => v.name === e.inputNode?.name);
@ -758,8 +758,8 @@ const getVariablesThatNeedRefreshOld = (key: string, state: StoreState): Variabl
const allVariables = getVariablesByKey(key, state);
const variablesThatNeedRefresh = allVariables.filter((variable) => {
if (variable.hasOwnProperty('refresh') && variable.hasOwnProperty('options')) {
const variableWithRefresh = variable as unknown as QueryVariableModel;
if ('refresh' in variable && 'options' in variable) {
const variableWithRefresh = variable;
return variableWithRefresh.refresh === VariableRefresh.onTimeRangeChanged;
}
return false;
@ -828,7 +828,7 @@ export const timeRangeUpdated =
export const templateVarsChangedInUrl =
(key: string, vars: ExtendedUrlQueryMap, events: typeof appEvents = appEvents): ThunkResult<void> =>
async (dispatch, getState) => {
const update: Array<Promise<any>> = [];
const update: Array<Promise<void>> = [];
const dashboard = getState().dashboard.getModel();
const variables = getVariablesByKey(key, getState());
@ -888,7 +888,7 @@ export const templateVarsChangedInUrl =
}
};
export function isVariableUrlValueDifferentFromCurrent(variable: TypedVariableModel, urlValue: any): boolean {
export function isVariableUrlValueDifferentFromCurrent(variable: TypedVariableModel, urlValue: unknown): boolean {
const variableValue = variableAdapters.get(variable.type).getValueForUrl(variable);
let stringUrlValue = ensureStringValues(urlValue);
if (Array.isArray(variableValue) && !Array.isArray(stringUrlValue)) {
@ -1032,12 +1032,12 @@ export const updateOptions =
export const createVariableErrorNotification = (
message: string,
error: any,
error: unknown,
identifier?: KeyedVariableIdentifier
): AppNotification =>
createErrorNotification(
`${identifier ? `Templating [${identifier.id}]` : 'Templating'}`,
`${message} ${error.message}`
error instanceof Error ? `${message} ${error.message}` : `${message}`
);
export const completeVariableLoading =

@ -20,7 +20,7 @@ export const createSystemVariableAdapter = (): VariableAdapter<SystemVariable<an
current: { value: { toString: () => '' } },
state: LoadingState.Done,
},
reducer: (state: any, action: any) => state,
reducer: (state: any) => state,
picker: null as unknown as ComponentType<VariablePickerProps<SystemVariable<any>>>,
editor: null as unknown as ComponentType<VariableEditorProps<SystemVariable<any>>>,
dependsOn: () => {

@ -184,7 +184,7 @@ export function getVariableTypes(): Array<{ label: string; value: VariableType }
}));
}
function getUrlValueForComparison(value: any): any {
function getUrlValueForComparison(value: unknown) {
if (isArray(value)) {
if (value.length === 0) {
value = undefined;

@ -1,7 +1,5 @@
import { isString } from 'lodash';
import { SelectableValue } from '@grafana/data';
import { ALIGNMENT_PERIODS, SELECTORS } from './constants';
import CloudMonitoringDatasource from './datasource';
import {
@ -59,7 +57,7 @@ export default class CloudMonitoringMetricFindQuery {
async handleProjectsQuery() {
const projects = await this.datasource.getProjects();
return (projects as SelectableValue<string>).map((s: { label: string; value: string }) => ({
return projects.map((s) => ({
text: s.label,
value: s.value,
expandable: true,

@ -6,7 +6,7 @@ import { Input } from '@grafana/ui';
export interface Props {
refId: string;
onChange: (alias: any) => void;
onChange: (alias: string) => void;
value?: string;
}
@ -15,14 +15,14 @@ export const AliasBy = ({ refId, value = '', onChange }: Props) => {
const propagateOnChange = debounce(onChange, 1000);
onChange = (e: any) => {
setAlias(e.target.value);
propagateOnChange(e.target.value);
const onInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setAlias(e.currentTarget.value);
propagateOnChange(e.currentTarget.value);
};
return (
<EditorField label="Alias by">
<Input id={`${refId}-alias-by`} value={alias} onChange={onChange} />
<Input id={`${refId}-alias-by`} value={alias} onChange={onInputChange} />
</EditorField>
);
};

@ -9,7 +9,7 @@ export interface Props {
}
export function MQLQueryEditor({ query, onChange, onRunQuery }: React.PropsWithChildren<Props>) {
const onKeyDown = (event: any) => {
const onKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (event.key === 'Enter' && (event.shiftKey || event.ctrlKey)) {
event.preventDefault();
onRunQuery();

@ -66,7 +66,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
const metricDescriptors = await this.props.datasource.getMetricTypes(
this.props.query.projectName || this.props.datasource.getDefaultProject()
);
const services = extractServicesFromMetricDescriptors(metricDescriptors).map((m: any) => ({
const services = extractServicesFromMetricDescriptors(metricDescriptors).map((m) => ({
value: m.service,
label: m.serviceShortName,
}));
@ -87,7 +87,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
const sloServices = await this.props.datasource.getSLOServices(projectName);
const state: any = {
const state = {
services,
selectedService,
metricTypes,
@ -108,7 +108,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
};
async onQueryTypeChange(queryType: string) {
const state: any = {
const state = {
selectedQueryType: queryType,
...(await this.getLabels(this.state.selectedMetricType, this.state.projectName, queryType)),
};
@ -148,7 +148,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
getTemplateSrv().replace(this.state.selectedMetricType),
getTemplateSrv().replace(service)
);
const state: any = {
const state = {
selectedService: service,
metricTypes,
selectedMetricType,
@ -158,7 +158,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
}
async onMetricTypeChange(metricType: string) {
const state: any = {
const state = {
selectedMetricType: metricType,
...(await this.getLabels(metricType, this.state.projectName)),
};
@ -195,7 +195,7 @@ export class CloudMonitoringVariableQueryEditor extends PureComponent<Props, Var
expanded: false,
options: getTemplateSrv()
.getVariables()
.map((v: any) => ({
.map((v) => ({
value: `$${v.name}`,
label: `$${v.name}`,
})),

@ -42,7 +42,7 @@ export function Editor({
aliasBy,
onChangeAliasBy,
}: React.PropsWithChildren<Props>) {
const [labels, setLabels] = useState<{ [k: string]: any }>({});
const [labels, setLabels] = useState<{ [k: string]: string[] }>({});
const [metricDescriptors, setMetricDescriptors] = useState<MetricDescriptor[]>([]);
const [metricDescriptor, setMetricDescriptor] = useState<MetricDescriptor>();
const [metrics, setMetrics] = useState<Array<SelectableValue<string>>>([]);

@ -54,7 +54,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend<
return super.query(request);
}
applyTemplateVariables(target: CloudMonitoringQuery, scopedVars: ScopedVars): Record<string, any> {
applyTemplateVariables(target: CloudMonitoringQuery, scopedVars: ScopedVars) {
const { timeSeriesList, timeSeriesQuery, sloQuery, promQLQuery } = target;
return {
@ -335,9 +335,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend<
}
interpolateVariablesInQueries(queries: CloudMonitoringQuery[], scopedVars: ScopedVars): CloudMonitoringQuery[] {
return queries.map(
(query) => this.applyTemplateVariables(this.migrateQuery(query), scopedVars) as CloudMonitoringQuery
);
return queries.map((query) => this.applyTemplateVariables(this.migrateQuery(query), scopedVars));
}
interpolateFilters(filters: string[], scopedVars: ScopedVars) {

@ -90,7 +90,15 @@ export const getAlignmentPickerData = (
};
export const labelsToGroupedOptions = (groupBys: string[]) => {
const groups = groupBys.reduce((acc: any, curr: string) => {
const groups = groupBys.reduce<
Record<
string,
Array<{
value: string;
label: string;
}>
>
>((acc, curr) => {
const arr = curr.split('.').map(startCase);
const group = (arr.length === 2 ? arr : initial(arr)).join(' ');
const option = {

@ -43,7 +43,7 @@ export async function addDataLinksToLogsResponse(
}
}
async function createInternalXrayLink(datasourceUid: string, region: string) {
async function createInternalXrayLink(datasourceUid: string, region: string): Promise<DataLink | undefined> {
let ds;
try {
ds = await getDataSourceSrv().get(datasourceUid);
@ -60,7 +60,7 @@ async function createInternalXrayLink(datasourceUid: string, region: string) {
datasourceUid: datasourceUid,
datasourceName: ds.name,
},
} as DataLink;
};
}
function createAwsConsoleLink(

@ -27,7 +27,7 @@ export function runWithRetry(
): Observable<{ frames: DataFrame[]; error?: DataQueryError }> {
const startTime = new Date();
let retries = 0;
let timerID: any;
let timerID: ReturnType<typeof setTimeout>;
let subscription: Subscription;
let collected = {};

@ -340,7 +340,7 @@ export class ElasticResponse {
if (target.alias) {
const regex = /\{\{([\s\S]+?)\}\}/g;
return target.alias.replace(regex, (match: any, g1: any, g2: any) => {
return target.alias.replace(regex, (match, g1, g2) => {
const group = g1 || g2;
if (group.indexOf('term ') === 0) {
@ -367,7 +367,7 @@ export class ElasticResponse {
metricName = getScriptValue(agg);
for (const pv of agg.pipelineVariables) {
const appliedAgg: any = find(target.metrics, { id: pv.pipelineAgg });
const appliedAgg = find(target.metrics, { id: pv.pipelineAgg });
if (appliedAgg) {
metricName = metricName.replace('params.' + pv.name, describeMetric(appliedAgg));
}
@ -376,7 +376,7 @@ export class ElasticResponse {
metricName = 'Unset';
}
} else {
const appliedAgg: any = find(target.metrics, { id: series.field });
const appliedAgg = find(target.metrics, { id: series.field });
if (appliedAgg) {
metricName += ' ' + describeMetric(appliedAgg);
} else {
@ -734,7 +734,7 @@ const createEmptyDataFrame = (
name: logMessageField,
type: FieldType.string,
});
series.setParser(f, (v: any) => {
series.setParser(f, (v) => {
return v || '';
});
}
@ -744,7 +744,7 @@ const createEmptyDataFrame = (
name: 'level',
type: FieldType.string,
});
series.setParser(f, (v: any) => {
series.setParser(f, (v) => {
return v || '';
});
}
@ -768,7 +768,7 @@ const createEmptyDataFrame = (
name,
type,
});
series.setParser(f, (v: any) => {
series.setParser(f, (v) => {
return v || '';
});
}
@ -776,7 +776,7 @@ const createEmptyDataFrame = (
return series;
};
const addPreferredVisualisationType = (series: any, type: PreferredVisualisationType) => {
const addPreferredVisualisationType = (series: DataFrame, type: PreferredVisualisationType) => {
let s = series;
s.meta
? (s.meta.preferredVisualisationType = type)
@ -786,7 +786,7 @@ const addPreferredVisualisationType = (series: any, type: PreferredVisualisation
};
const toNameTypePair =
(docs: Array<Record<string, any>>) =>
(docs: Array<Record<string, unknown>>) =>
(propName: string): [string, FieldType] => [
propName,
guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName]),

@ -37,17 +37,18 @@ export class ElasticQueryBuilder {
}
getRangeFilter() {
const filter: any = {};
filter[this.timeField] = {
gte: '$timeFrom',
lte: '$timeTo',
format: 'epoch_millis',
const filter = {
[this.timeField]: {
gte: '$timeFrom',
lte: '$timeTo',
format: 'epoch_millis',
},
};
return filter;
}
buildTermsAgg(aggDef: Terms, queryNode: { terms?: any; aggs?: any }, target: ElasticsearchQuery) {
buildTermsAgg(aggDef: Terms, queryNode: { terms?: any; aggs?: Record<string, unknown> }, target: ElasticsearchQuery) {
queryNode.terms = { field: aggDef.field };
if (!aggDef.settings) {
@ -101,7 +102,7 @@ export class ElasticQueryBuilder {
}
getDateHistogramAgg(aggDef: DateHistogram) {
const esAgg: any = {};
const esAgg: Record<string, unknown> = {};
const settings = aggDef.settings || {};
esAgg.field = aggDef.field || this.timeField;
@ -128,11 +129,11 @@ export class ElasticQueryBuilder {
}
getHistogramAgg(aggDef: Histogram) {
const esAgg: any = {};
const settings = aggDef.settings || {};
esAgg.interval = settings.interval;
esAgg.field = aggDef.field;
esAgg.min_doc_count = settings.min_doc_count || 0;
const esAgg = {
interval: aggDef.settings?.interval,
field: aggDef.field,
min_doc_count: aggDef.settings?.min_doc_count || 0,
};
return esAgg;
}

@ -5,7 +5,7 @@ import { Button } from '@grafana/ui';
interface Props {
index: number;
elements: any[];
elements: unknown[];
onAdd: () => void;
onRemove: () => void;
}

@ -102,7 +102,7 @@ function createOrderByOptionsForExtendedStats(metric: ExtendedStats): Selectable
return metaKeys
.filter((key) => metric.meta?.[key])
.map((key) => {
let method = key as string;
let method: string = key;
// The bucket path for std_deviation_bounds.lower and std_deviation_bounds.upper
// is accessed via std_lower and std_upper, respectively.
if (key === 'std_deviation_bounds_lower') {

@ -15,5 +15,5 @@ export const changeBucketAggregationField = createAction<{
export const changeBucketAggregationSetting = createAction<{
bucketAgg: BucketAggregation;
settingName: string;
newValue: any;
newValue: unknown;
}>('@bucketAggs/change_setting');

@ -91,7 +91,7 @@ const getHook: GetHook = (c) => () => {
throw new Error('use ElasticsearchProvider first.');
}
return contextValue as NonNullable<typeof contextValue>;
return contextValue;
};
export const useQuery = getHook(QueryContext);

@ -9,16 +9,16 @@ export const changeMetricField = createAction<{ id: MetricAggregation['id']; fie
export const changeMetricType = createAction<{ id: MetricAggregation['id']; type: MetricAggregation['type'] }>(
'@metrics/change_type'
);
export const changeMetricAttribute = createAction<{ metric: MetricAggregation; attribute: string; newValue: any }>(
export const changeMetricAttribute = createAction<{ metric: MetricAggregation; attribute: string; newValue: unknown }>(
'@metrics/change_attr'
);
export const changeMetricSetting = createAction<{
metric: MetricAggregationWithSettings;
settingName: string;
newValue: any;
newValue: unknown;
}>('@metrics/change_setting');
export const changeMetricMeta = createAction<{
metric: MetricAggregationWithMeta;
meta: string;
newValue: any;
newValue: unknown;
}>('@metrics/change_meta');

@ -191,7 +191,7 @@ export class ElasticDatasource
* @param url the url to query the index on, for example `/_mapping`.
*/
private requestAllIndices(url: string, range = getDefaultTimeRange()): Observable<any> {
private requestAllIndices(url: string, range = getDefaultTimeRange()) {
let indexList = this.indexPattern.getIndexList(range.from, range.to);
if (!Array.isArray(indexList)) {
indexList = [this.indexPattern.getIndexForToday()];

@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
type Props = DataSourcePluginOptionsEditorProps<any>;
type Props = DataSourcePluginOptionsEditorProps;
/**
* Empty Config Editor -- settings to save

@ -127,7 +127,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
const onInputChange = (e: FormEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value, type } = e.currentTarget;
let newValue: any = value;
let newValue: string | number | boolean = value;
if (type === 'number') {
newValue = Number(value);
@ -142,7 +142,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
const onFieldChange = (field: string) => (e: { target: { name: string; value: string; type: string } }) => {
const { name, value, type } = e.target;
let newValue: any = value;
let newValue: string | number = value;
if (type === 'number') {
newValue = Number(value);

@ -6,7 +6,15 @@ import { InlineField, InlineFieldRow, Input } from '@grafana/ui';
import { EditorProps } from '../QueryEditor';
import { TestData } from '../dataquery.gen';
const randomWalkFields = [
const randomWalkFields: Array<{
label: string;
id: Selector;
placeholder: string;
min?: number;
step?: number;
max?: number;
tooltip?: string;
}> = [
{ label: 'Series count', id: 'seriesCount', placeholder: '1', min: 1, step: 1 },
{ label: 'Start value', id: 'startValue', placeholder: 'auto', step: 1 },
{ label: 'Min', id: 'min', placeholder: 'none', step: 0.1 },
@ -31,7 +39,7 @@ export const RandomWalkEditor = ({ onChange, query }: EditorProps) => {
return (
<InlineFieldRow>
{randomWalkFields.map(({ label, id, min, step, placeholder, tooltip }) => {
const selector = testSelectors?.[id as Selector];
const selector = testSelectors[id];
return (
<InlineField label={label} labelWidth={14} key={id} aria-label={selector} tooltip={tooltip}>
<Input

@ -25,7 +25,7 @@ export const RawFrameEditor = ({ onChange, query }: EditorProps) => {
// Copy paste from panel json
if (isArray(json.series) && json.state) {
data = json.series.map((v: any) => toDataFrameDTO(toDataFrame(v)));
data = json.series.map((v: unknown) => toDataFrameDTO(toDataFrame(v)));
} else {
// Chek if it is a copy of the raw resuls
const v = toDataQueryResponse({ data: json });

@ -11,6 +11,7 @@ import { nodes, edges } from './testData/serviceMapResponse';
export function generateRandomNodes(count = 10) {
const nodes = [];
const edges: string[] = [];
const root = {
id: 'root',
@ -20,7 +21,7 @@ export function generateRandomNodes(count = 10) {
error: 0,
stat1: Math.random(),
stat2: Math.random(),
edges: [] as any[],
edges,
};
nodes.push(root);
const nodesWithoutMaxEdges = [root];

@ -29,7 +29,7 @@ export default function SearchEditor({ value, onChange }: Props) {
setJSON(JSON.stringify({ ...emptySearchQuery, ...value }, null, 2));
}, [value]);
const handleSearchBlur = (e: React.FocusEvent<HTMLInputElement>) => {
const handleSearchBlur = () => {
if (query !== value.query) {
onChange({ ...value, query });
}
@ -39,12 +39,12 @@ export default function SearchEditor({ value, onChange }: Props) {
if (e.key !== 'Enter') {
return;
}
handleSearchBlur(e as any);
handleSearchBlur();
};
const onSaveSearchJSON = (rawSearchJSON: string) => {
try {
const searchQuery = JSON.parse(rawSearchJSON) as SearchQuery;
const searchQuery: SearchQuery = JSON.parse(rawSearchJSON);
onChange(searchQuery);
setQuery(searchQuery.query ?? '');
} catch (ex) {

@ -60,7 +60,7 @@ export class GrafanaDatasource extends DataSourceWithBackend<GrafanaQuery> {
datasource = ref;
}
} else {
datasource = anno.datasource as DataSourceRef;
datasource = anno.datasource;
}
// Filter from streaming query conflicts with filter from annotations
@ -188,7 +188,7 @@ export class GrafanaDatasource extends DataSourceWithBackend<GrafanaQuery> {
);
}
metricFindQuery(options: any) {
metricFindQuery() {
return Promise.resolve([]);
}
@ -232,7 +232,7 @@ export class GrafanaDatasource extends DataSourceWithBackend<GrafanaQuery> {
const delimiter = '__delimiter__';
const tags = [];
for (const t of params.tags) {
const renderedValues = templateSrv.replace(t, {}, (value: any) => {
const renderedValues = templateSrv.replace(t, {}, (value: string | string[]) => {
if (typeof value === 'string') {
return value;
}

@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { Icon, Tooltip, useStyles2 } from '@grafana/ui';
import { Icon, Tooltip, useStyles2, type PopoverContent } from '@grafana/ui';
import { FuncInstance } from '../gfunc';
@ -29,17 +29,17 @@ const getStyles = (theme: GrafanaTheme2) => {
const FunctionEditor = ({ onMoveLeft, onMoveRight, func, ...props }: FunctionEditorProps) => {
const styles = useStyles2(getStyles);
const renderContent = ({ updatePopperPosition }: any) => (
const renderContent: PopoverContent = ({ updatePopperPosition }) => (
<FunctionEditorControls
{...props}
func={func}
onMoveLeft={() => {
onMoveLeft(func);
updatePopperPosition();
updatePopperPosition?.();
}}
onMoveRight={() => {
onMoveRight(func);
updatePopperPosition();
updatePopperPosition?.();
}}
/>
);

Loading…
Cancel
Save