diff --git a/.betterer.results b/.betterer.results
index da54e902293..ccbc952ec4d 100644
--- a/.betterer.results
+++ b/.betterer.results
@@ -41,8 +41,7 @@ exports[`better eslint`] = {
[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.", "3"],
- [0, 0, 0, "Do not use any type assertions.", "4"]
+ [0, 0, 0, "Do not use any type assertions.", "3"]
],
"packages/grafana-data/src/dataframe/processDataFrame.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -69,12 +68,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"]
],
- "packages/grafana-data/src/datetime/datemath.ts:5381": [
- [0, 0, 0, "Do not use any type assertions.", "0"]
- ],
- "packages/grafana-data/src/datetime/durationutil.ts:5381": [
- [0, 0, 0, "Do not use any type assertions.", "0"]
- ],
"packages/grafana-data/src/datetime/moment_wrapper.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -121,8 +114,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, "Do not use any type assertions.", "6"]
+ [0, 0, 0, "Do not use any type assertions.", "5"]
],
"packages/grafana-data/src/panel/registryFactories.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@@ -150,25 +142,15 @@ exports[`better eslint`] = {
"packages/grafana-data/src/transformations/standardTransformersRegistry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
- "packages/grafana-data/src/transformations/transformDataFrame.ts:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
- ],
"packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.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/transformations/transformers/reduce.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/types/OptionsUIRegistryBuilder.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.", "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.", "3"]
],
"packages/grafana-data/src/types/ScopedVars.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -188,14 +170,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"packages/grafana-data/src/types/app.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, "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"]
- ],
- "packages/grafana-data/src/types/config.ts:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
+ [0, 0, 0, "Do not use any type assertions.", "2"]
],
"packages/grafana-data/src/types/dashboard.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -247,8 +224,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "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, "Unexpected any. Specify a different type.", "23"]
],
"packages/grafana-data/src/types/explore.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -303,8 +279,7 @@ exports[`better eslint`] = {
[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"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "13"]
+ [0, 0, 0, "Unexpected any. Specify a different type.", "12"]
],
"packages/grafana-data/src/types/plugin.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -342,23 +317,7 @@ exports[`better eslint`] = {
[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"],
- [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"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "19"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "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, "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.", "10"]
],
"packages/grafana-data/src/utils/Registry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -374,9 +333,6 @@ exports[`better eslint`] = {
[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"]
- ],
"packages/grafana-data/src/utils/datasource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
@@ -601,9 +557,6 @@ exports[`better eslint`] = {
"packages/grafana-ui/src/components/InfoBox/InfoBox.story.tsx:5381": [
[0, 0, 0, "\'VerticalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
- "packages/grafana-ui/src/components/InfoBox/InfoBox.tsx:5381": [
- [0, 0, 0, "Do not use any type assertions.", "0"]
- ],
"packages/grafana-ui/src/components/JSONFormatter/json_explorer/json_explorer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -828,15 +781,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
- "packages/grafana-ui/src/utils/logger.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"]
- ],
- "packages/grafana-ui/src/utils/storybook/withTheme.tsx:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
- ],
"packages/grafana-ui/src/utils/useAsyncDependency.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@@ -896,15 +840,11 @@ exports[`better eslint`] = {
],
"public/app/core/components/GraphNG/GraphNG.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, "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, "Do not use any type assertions.", "6"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "7"],
- [0, 0, 0, "Do not use any type assertions.", "8"],
- [0, 0, 0, "Do not use any type assertions.", "9"]
+ [0, 0, 0, "Do not use any type assertions.", "4"],
+ [0, 0, 0, "Do not use any type assertions.", "5"]
],
"public/app/core/components/LocalStorageValueProvider/index.tsx:5381": [
[0, 0, 0, "Do not re-export imported variable (\`./LocalStorageValueProvider\`)", "0"]
@@ -2898,9 +2838,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "1"],
- [0, 0, 0, "No untranslated strings. Wrap text with ", "2"]
+ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"],
+ [0, 0, 0, "No untranslated strings. Wrap text with ", "1"]
],
"public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx:5381": [
[0, 0, 0, "\'VerticalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
@@ -4533,9 +4472,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"]
],
- "public/app/features/transformers/standardTransformers.ts:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
- ],
"public/app/features/transformers/suggestionsInput/SuggestionsInput.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5117,9 +5053,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"]
],
- "public/app/plugins/datasource/graphite/components/helpers.ts:5381": [
- [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
- ],
"public/app/plugins/datasource/graphite/datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -5129,9 +5062,9 @@ exports[`better eslint`] = {
[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, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
- [0, 0, 0, "Do not use any type assertions.", "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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
@@ -5145,25 +5078,12 @@ exports[`better eslint`] = {
[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"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "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, "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"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "29"]
+ [0, 0, 0, "Unexpected any. Specify a different type.", "19"]
],
"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.", "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.", "2"]
],
"public/app/plugins/datasource/graphite/graphite_query.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5176,22 +5096,12 @@ exports[`better eslint`] = {
[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"],
- [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.", "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, "Do not use any type assertions.", "10"]
],
"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.", "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, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/graphite/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -5234,12 +5144,10 @@ exports[`better eslint`] = {
[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"],
- [0, 0, 0, "Do not use any type assertions.", "13"]
+ [0, 0, 0, "Do not use any type assertions.", "12"]
],
"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.", "1"]
+ [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/influxdb/influx_series.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5250,10 +5158,7 @@ exports[`better eslint`] = {
[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"],
- [0, 0, 0, "Unexpected any. Specify a different type.", "11"]
+ [0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/plugins/datasource/influxdb/query_part.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
diff --git a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts
index ac928f73f48..bb410406ed9 100644
--- a/packages/grafana-data/src/dataframe/StreamingDataFrame.ts
+++ b/packages/grafana-data/src/dataframe/StreamingDataFrame.ts
@@ -550,8 +550,11 @@ export function parseLabelsFromField(str: string): Labels {
* @internal // not exported in yet
*/
export function getLastStreamingDataFramePacket(frame: DataFrame) {
- const pi = (frame as StreamingDataFrame).packetInfo;
- return pi?.action ? pi : undefined;
+ if (frame instanceof StreamingDataFrame) {
+ const pi = frame.packetInfo;
+ return pi.action;
+ }
+ return undefined;
}
// mutable circular push
diff --git a/packages/grafana-data/src/datetime/datemath.ts b/packages/grafana-data/src/datetime/datemath.ts
index 8ebf5c99269..e95e4575401 100644
--- a/packages/grafana-data/src/datetime/datemath.ts
+++ b/packages/grafana-data/src/datetime/datemath.ts
@@ -1,4 +1,4 @@
-import { includes, isDate } from 'lodash';
+import { isDate } from 'lodash';
import { TimeZone } from '../types/time';
@@ -12,7 +12,11 @@ import {
ISO_8601,
} from './moment_wrapper';
-const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'];
+const units: string[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'] satisfies DurationUnit[];
+
+const isDurationUnit = (value: string): value is DurationUnit => {
+ return units.includes(value);
+};
/**
* Determine if a string contains a relative date time.
@@ -169,11 +173,9 @@ export function parseDateMath(
isFiscal = true;
}
- const unit = unitString as DurationUnit;
+ const unit = unitString;
- if (!includes(units, unit)) {
- return undefined;
- } else {
+ if (isDurationUnit(unit)) {
if (type === 0) {
if (isFiscal) {
roundToFiscal(fiscalYearStartMonth, result, unit, roundUp);
@@ -189,6 +191,8 @@ export function parseDateMath(
} else if (type === 2) {
result.subtract(num, unit);
}
+ } else {
+ return undefined;
}
}
return result;
diff --git a/packages/grafana-data/src/datetime/durationutil.ts b/packages/grafana-data/src/datetime/durationutil.ts
index c8049a641bb..547303134cd 100644
--- a/packages/grafana-data/src/datetime/durationutil.ts
+++ b/packages/grafana-data/src/datetime/durationutil.ts
@@ -1,6 +1,6 @@
import { add, Duration, intervalToDuration, Interval, isAfter } from 'date-fns';
-const durationMap: { [key in Required]: string[] } = {
+const durationMap: Record = {
years: ['y', 'Y', 'years'],
months: ['M', 'months'],
weeks: ['w', 'W', 'weeks'],
@@ -8,7 +8,7 @@ const durationMap: { [key in Required]: string[] } = {
hours: ['h', 'H', 'hours'],
minutes: ['m', 'minutes'],
seconds: ['s', 'S', 'seconds'],
-};
+} satisfies { [key in keyof Duration]: string[] };
/**
* intervalToAbbreviatedDurationString converts interval to readable duration string
@@ -26,7 +26,7 @@ export function intervalToAbbreviatedDurationString(interval: Interval, includeS
}
const duration = intervalToDuration(interval);
- return (Object.entries(duration) as Array<[keyof Duration, number | undefined]>).reduce((str, [unit, value]) => {
+ return Object.entries(duration).reduce((str, [unit, value]) => {
if (value && value !== 0 && !(unit === 'seconds' && !includeSeconds && str)) {
const padding = str !== '' ? ' ' : '';
return str + `${padding}${value}${durationMap[unit][0]}`;
diff --git a/packages/grafana-data/src/panel/PanelPlugin.ts b/packages/grafana-data/src/panel/PanelPlugin.ts
index c4b2e0ed037..cb0325ac65c 100644
--- a/packages/grafana-data/src/panel/PanelPlugin.ts
+++ b/packages/grafana-data/src/panel/PanelPlugin.ts
@@ -94,7 +94,7 @@ export type PanelOptionsSupplier = (
export class PanelPlugin<
TOptions = any,
- TFieldConfigOptions extends object = any,
+ TFieldConfigOptions extends object = {},
> extends GrafanaPlugin {
private _defaults?: TOptions;
private _fieldConfigDefaults: FieldConfigSource = {
diff --git a/packages/grafana-data/src/transformations/standardTransformersRegistry.ts b/packages/grafana-data/src/transformations/standardTransformersRegistry.ts
index 87970a33994..4e5a11d318a 100644
--- a/packages/grafana-data/src/transformations/standardTransformersRegistry.ts
+++ b/packages/grafana-data/src/transformations/standardTransformersRegistry.ts
@@ -16,7 +16,7 @@ export interface TransformerUIProps {
onChange: (options: T) => void;
}
-export interface TransformerRegistryItem extends RegistryItem {
+export interface TransformerRegistryItem extends RegistryItem {
/**
* Object describing transformer configuration
*/
@@ -50,4 +50,4 @@ export enum TransformerCategory {
* Registry of transformation options that can be driven by
* stored configuration files.
*/
-export const standardTransformersRegistry = new Registry>();
+export const standardTransformersRegistry = new Registry();
diff --git a/packages/grafana-data/src/transformations/transformDataFrame.ts b/packages/grafana-data/src/transformations/transformDataFrame.ts
index 810177aa1c2..477801b650e 100644
--- a/packages/grafana-data/src/transformations/transformDataFrame.ts
+++ b/packages/grafana-data/src/transformations/transformDataFrame.ts
@@ -43,11 +43,7 @@ function filterInput(data: DataFrame[], matcher?: FrameMatcher) {
}
const postProcessTransform =
- (
- before: DataFrame[],
- info: TransformerRegistryItem,
- matcher?: FrameMatcher
- ): MonoTypeOperatorFunction =>
+ (before: DataFrame[], info: TransformerRegistryItem, matcher?: FrameMatcher): MonoTypeOperatorFunction =>
(source) =>
source.pipe(
map((after) => {
diff --git a/packages/grafana-data/src/transformations/transformers/reduce.ts b/packages/grafana-data/src/transformations/transformers/reduce.ts
index ad17991d3bd..8a28a35fa11 100644
--- a/packages/grafana-data/src/transformations/transformers/reduce.ts
+++ b/packages/grafana-data/src/transformations/transformers/reduce.ts
@@ -88,7 +88,7 @@ function reduceSeriesToRows(
config: {},
});
- const labels: KeyValue = {};
+ const labels: KeyValue = {};
if (labelsToFields) {
for (const key of distinctLabels) {
labels[key] = new Array(size);
@@ -101,7 +101,7 @@ function reduceSeriesToRows(
}
}
- const calcs: KeyValue = {};
+ const calcs: KeyValue = {};
for (const info of calculators) {
calcs[info.id] = new Array(size);
fields.push({
diff --git a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts
index 54b80c62dec..0ef14d460b7 100644
--- a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts
+++ b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts
@@ -59,11 +59,11 @@ interface OptionsUIRegistryBuilderAPI<
config: OptionEditorConfig
): this;
- addBooleanSwitch?(config: OptionEditorConfig): this;
+ addBooleanSwitch?(config: OptionEditorConfig): this;
- addUnitPicker?(config: OptionEditorConfig): this;
+ addUnitPicker?(config: OptionEditorConfig): this;
- addColorPicker?(config: OptionEditorConfig): this;
+ addColorPicker?(config: OptionEditorConfig): this;
/**
* Enables custom editor definition
diff --git a/packages/grafana-data/src/types/app.ts b/packages/grafana-data/src/types/app.ts
index 6ada93ab099..3b33452bd03 100644
--- a/packages/grafana-data/src/types/app.ts
+++ b/packages/grafana-data/src/types/app.ts
@@ -82,7 +82,7 @@ export class AppPlugin extends GrafanaPlugin extends GrafanaPlugin) => void;
+ onClick?: (event: React.MouseEvent) => void;
shortcut?: string;
href?: string;
subMenu?: PanelMenuItem[];
diff --git a/packages/grafana-data/src/utils/OptionsUIBuilders.ts b/packages/grafana-data/src/utils/OptionsUIBuilders.ts
index c7d9bf83257..b88f633ca5e 100644
--- a/packages/grafana-data/src/utils/OptionsUIBuilders.ts
+++ b/packages/grafana-data/src/utils/OptionsUIBuilders.ts
@@ -30,7 +30,7 @@ import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel
*/
export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder<
TOptions,
- StandardEditorProps,
+ StandardEditorProps,
FieldConfigPropertyItem
> {
addNumberInput(config: FieldConfigEditorConfig) {
@@ -84,7 +84,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addRadio(config: FieldConfigEditorConfig) {
+ addRadio(config: FieldConfigEditorConfig) {
return this.addCustomEditor({
...config,
id: config.path,
@@ -97,7 +97,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addBooleanSwitch(config: FieldConfigEditorConfig) {
+ addBooleanSwitch(config: FieldConfigEditorConfig) {
return this.addCustomEditor({
...config,
id: config.path,
@@ -109,7 +109,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addColorPicker(config: FieldConfigEditorConfig) {
+ addColorPicker(config: FieldConfigEditorConfig) {
return this.addCustomEditor({
...config,
id: config.path,
@@ -121,9 +121,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addUnitPicker(
- config: FieldConfigEditorConfig
- ) {
+ addUnitPicker(config: FieldConfigEditorConfig) {
return this.addCustomEditor({
...config,
id: config.path,
@@ -135,7 +133,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addFieldNamePicker(
+ addFieldNamePicker(
config: FieldConfigEditorConfig
): this {
return this.addCustomEditor({
@@ -149,7 +147,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
});
}
- addGenericEditor(
+ addGenericEditor(
config: FieldConfigEditorConfig, // & any... i give up!
editor: (props: StandardEditorProps) => JSX.Element
): this {
@@ -168,7 +166,7 @@ export class FieldConfigEditorBuilder extends OptionsUIRegistryBuilder
export interface NestedValueAccess {
getValue: (path: string) => any;
onChange: (path: string, value: any) => void;
- getContext?: (parent: StandardEditorContext) => StandardEditorContext;
+ getContext?: (parent: StandardEditorContext) => StandardEditorContext;
}
export interface NestedPanelOptions {
path: string;
@@ -307,7 +305,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addBooleanSwitch(config: PanelOptionsEditorConfig) {
+ addBooleanSwitch(config: PanelOptionsEditorConfig) {
return this.addCustomEditor({
...config,
id: config.path,
@@ -315,7 +313,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addColorPicker(config: PanelOptionsEditorConfig): this {
+ addColorPicker(config: PanelOptionsEditorConfig): this {
return this.addCustomEditor({
...config,
id: config.path,
@@ -324,7 +322,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addTimeZonePicker(config: PanelOptionsEditorConfig): this {
+ addTimeZonePicker(config: PanelOptionsEditorConfig): this {
return this.addCustomEditor({
...config,
id: config.path,
@@ -333,7 +331,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addUnitPicker(
+ addUnitPicker(
config: PanelOptionsEditorConfig
): this {
return this.addCustomEditor({
@@ -343,7 +341,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addFieldNamePicker(
+ addFieldNamePicker(
config: PanelOptionsEditorConfig
): this {
return this.addCustomEditor({
@@ -353,7 +351,7 @@ export class PanelOptionsEditorBuilder extends OptionsUIRegistryBuilde
});
}
- addDashboardPicker(
+ addDashboardPicker(
config: PanelOptionsEditorConfig
): this {
return this.addCustomEditor({
diff --git a/packages/grafana-data/src/utils/dataLinks.ts b/packages/grafana-data/src/utils/dataLinks.ts
index 7f4a71f6aeb..0ca5e4e64f1 100644
--- a/packages/grafana-data/src/utils/dataLinks.ts
+++ b/packages/grafana-data/src/utils/dataLinks.ts
@@ -74,7 +74,7 @@ export function mapInternalLinkToExplore(options: LinkToExploreOptions): LinkMod
/**
* Generates href for internal derived field link.
*/
-function generateInternalHref(
+function generateInternalHref(
datasourceUid: string,
query: T,
range?: TimeRange,
diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts
index 9c06b25cfba..95f175fcca5 100644
--- a/packages/grafana-runtime/src/config.ts
+++ b/packages/grafana-runtime/src/config.ts
@@ -140,7 +140,6 @@ export class GrafanaBootConfig implements GrafanaConfig {
pluginCatalogPreinstalledPlugins: PreinstalledPlugin[] = [];
pluginsCDNBaseURL = '';
expressionsEnabled = false;
- customTheme?: undefined;
awsAllowedAuthProviders: string[] = [];
awsAssumeRoleEnabled = false;
azure: AzureSettings = {
diff --git a/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx
index 8aff84620cf..3132d31add0 100644
--- a/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx
+++ b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx
@@ -30,6 +30,8 @@ export const InfoBox = React.memo(
const styles = useStyles2(getStyles);
return (
+ // component is deprecated so no point fixing this
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
{children}
{url && (
diff --git a/packages/grafana-ui/src/utils/logger.ts b/packages/grafana-ui/src/utils/logger.ts
index e52bb4ba8b9..d9ed2546115 100644
--- a/packages/grafana-ui/src/utils/logger.ts
+++ b/packages/grafana-ui/src/utils/logger.ts
@@ -1,9 +1,11 @@
import { throttle } from 'lodash';
+type Args = Parameters;
+
/**
* @internal
* */
-const throttledLog = throttle((...t: any[]) => {
+const throttledLog = throttle((...t: Args) => {
console.log(...t);
}, 500);
@@ -11,7 +13,7 @@ const throttledLog = throttle((...t: any[]) => {
* @internal
*/
export interface Logger {
- logger: (...t: any[]) => void;
+ logger: (...t: Args) => void;
enable: () => void;
disable: () => void;
isEnabled: () => boolean;
@@ -26,7 +28,7 @@ export const createLogger = (name: string): Logger => {
}
return {
- logger: (id: string, throttle = false, ...t: any[]) => {
+ logger: (id: string, throttle = false, ...t: Args) => {
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' || !loggingEnabled) {
return;
}
diff --git a/packages/grafana-ui/src/utils/storybook/withTheme.tsx b/packages/grafana-ui/src/utils/storybook/withTheme.tsx
index d4abd8965b5..d865769c5ab 100644
--- a/packages/grafana-ui/src/utils/storybook/withTheme.tsx
+++ b/packages/grafana-ui/src/utils/storybook/withTheme.tsx
@@ -35,21 +35,6 @@ const ThemeableStory = ({
);
};
-// Temporary solution. When we update to Storybook V5 we will be able to pass data from decorator to story
-// https://github.com/storybooks/storybook/issues/340#issuecomment-456013702
-export const renderComponentWithTheme = (component: React.ComponentType, props: any) => {
- return (
-
- {(theme) => {
- return React.createElement(component, {
- ...props,
- theme,
- });
- }}
-
- );
-};
-
export const withTheme =
(handleSassThemeChange: SassThemeChangeHandler): Decorator =>
// eslint-disable-next-line react/display-name
diff --git a/public/app/core/components/GraphNG/GraphNG.tsx b/public/app/core/components/GraphNG/GraphNG.tsx
index d2e1e83f4cd..673d7a348d3 100644
--- a/public/app/core/components/GraphNG/GraphNG.tsx
+++ b/public/app/core/components/GraphNG/GraphNG.tsx
@@ -28,7 +28,7 @@ import { preparePlotFrame as defaultPreparePlotFrame } from './utils';
/**
* @internal -- not a public API
*/
-export type PropDiffFn = (prev: T, next: T) => boolean;
+export type PropDiffFn = {}> = (prev: T, next: T) => boolean;
export interface GraphNGProps extends Themeable2 {
frames: DataFrame[];
@@ -61,7 +61,11 @@ export interface GraphNGProps extends Themeable2 {
options?: Record;
}
-function sameProps(prevProps: any, nextProps: any, propsToDiff: Array = []) {
+function sameProps>(
+ prevProps: T,
+ nextProps: T,
+ propsToDiff: Array = []
+) {
for (const propName of propsToDiff) {
if (typeof propName === 'function') {
if (!propName(prevProps, nextProps)) {
diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx
index 8cbeddccbad..7ac97009d96 100644
--- a/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx
+++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx
@@ -21,7 +21,7 @@ interface TransformationEditorProps {
debugMode?: boolean;
index: number;
data: DataFrame[];
- uiConfig: TransformerRegistryItem;
+ uiConfig: TransformerRegistryItem;
configs: TransformationsEditorTransformation[];
onChange: (index: number, config: DataTransformerConfig) => void;
toggleShowDebug: () => void;
diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx
index 594f5f3ab75..f1c5aebeb1b 100644
--- a/public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx
+++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx
@@ -17,8 +17,7 @@ interface TransformationPickerProps {
onSearchKeyDown: KeyboardEventHandler;
onTransformationAdd: Function;
suffix: ReactNode;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- xforms: Array>;
+ xforms: TransformerRegistryItem[];
}
export function TransformationPicker(props: TransformationPickerProps) {
@@ -88,8 +87,7 @@ export function TransformationPicker(props: TransformationPickerProps) {
}
interface TransformationCardProps {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- transform: TransformerRegistryItem;
+ transform: TransformerRegistryItem;
onClick: () => void;
}
diff --git a/public/app/features/dashboard/components/TransformationsEditor/TransformationPickerNg.tsx b/public/app/features/dashboard/components/TransformationsEditor/TransformationPickerNg.tsx
index db78b4e6e4a..15ea4f86720 100644
--- a/public/app/features/dashboard/components/TransformationsEditor/TransformationPickerNg.tsx
+++ b/public/app/features/dashboard/components/TransformationsEditor/TransformationPickerNg.tsx
@@ -32,8 +32,7 @@ interface TransformationPickerNgProps {
onSearchKeyDown: KeyboardEventHandler;
onClose?: () => void;
noTransforms: boolean;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- xforms: Array>;
+ xforms: TransformerRegistryItem[];
search: string;
suffix: ReactNode;
data: DataFrame[];
@@ -160,8 +159,7 @@ function getTransformationPickerStyles(theme: GrafanaTheme2) {
}
interface TransformationsGridProps {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- transformations: Array>;
+ transformations: TransformerRegistryItem[];
showIllustrations?: boolean;
onClick: (id: string) => void;
data: DataFrame[];
diff --git a/public/app/features/transformers/standardTransformers.ts b/public/app/features/transformers/standardTransformers.ts
index 2fbc9fce5db..852c7a7bc34 100644
--- a/public/app/features/transformers/standardTransformers.ts
+++ b/public/app/features/transformers/standardTransformers.ts
@@ -35,7 +35,7 @@ import { rowsToFieldsTransformRegistryItem } from './rowsToFields/RowsToFieldsTr
import { spatialTransformRegistryItem } from './spatial/SpatialTransformerEditor';
import { timeSeriesTableTransformRegistryItem } from './timeSeriesTable/TimeSeriesTableTransformEditor';
-export const getStandardTransformers = (): Array> => {
+export const getStandardTransformers = (): TransformerRegistryItem[] => {
return [
reduceTransformRegistryItem,
filterFieldsByNameTransformRegistryItem,
diff --git a/public/app/plugins/datasource/graphite/components/helpers.ts b/public/app/plugins/datasource/graphite/components/helpers.ts
index 6d2521bb5f2..43d24c8b476 100644
--- a/public/app/plugins/datasource/graphite/components/helpers.ts
+++ b/public/app/plugins/datasource/graphite/components/helpers.ts
@@ -22,7 +22,7 @@ export function mapSegmentsToSelectables(segments: GraphiteSegment[]): Array> {
- const categories: any = {};
+ const categories: Record> = {};
forEach(funcDefs, (funcDef) => {
if (!funcDef.category) {
diff --git a/public/app/plugins/datasource/graphite/datasource.test.ts b/public/app/plugins/datasource/graphite/datasource.test.ts
index f7d9049d9de..849271524eb 100644
--- a/public/app/plugins/datasource/graphite/datasource.test.ts
+++ b/public/app/plugins/datasource/graphite/datasource.test.ts
@@ -55,8 +55,8 @@ describe('graphiteDatasource', () => {
describe('convertResponseToDataFrames', () => {
it('should transform regular result', () => {
- const result = ctx.ds.convertResponseToDataFrames({
- data: {
+ const result = ctx.ds.convertResponseToDataFrames(
+ createFetchResponse({
meta: {
stats: {
'executeplan.cache-hit-partial.count': 5,
@@ -105,8 +105,8 @@ describe('graphiteDatasource', () => {
],
},
],
- },
- });
+ })
+ );
expect(result.data.length).toBe(2);
expect(getFrameDisplayName(result.data[0])).toBe('seriesA');
diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts
index c3215567a12..e3ab7e93dc7 100644
--- a/public/app/plugins/datasource/graphite/datasource.ts
+++ b/public/app/plugins/datasource/graphite/datasource.ts
@@ -21,7 +21,7 @@ import {
toDataFrame,
getSearchFilterScopedVar,
} from '@grafana/data';
-import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';
+import { BackendSrvRequest, FetchResponse, getBackendSrv } from '@grafana/runtime';
import { isVersionGtOrEq, SemVersion } from 'app/core/utils/version';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { getRollupNotice, getRuntimeConsolidationNotice } from 'app/plugins/datasource/graphite/meta';
@@ -267,7 +267,7 @@ export class GraphiteDatasource
}
}
- convertResponseToDataFrames = (result: any): DataQueryResponse => {
+ convertResponseToDataFrames = (result: FetchResponse): DataQueryResponse => {
const data: DataFrame[] = [];
if (!result || !result.data) {
return { data };
@@ -648,7 +648,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
return _map(results.data, (metric) => {
return {
text: metric.text,
@@ -689,7 +689,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
return _map(results.data.results, (metric) => {
return {
text: metric,
@@ -720,7 +720,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
return _map(results.data, (tag) => {
return {
text: tag.tag,
@@ -750,7 +750,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
if (results.data && results.data.values) {
return _map(results.data.values, (value) => {
return {
@@ -833,7 +833,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
if (results.data) {
const semver = new SemVersion(results.data);
return semver.isValid() ? results.data : '';
@@ -880,7 +880,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.doGraphiteRequest(httpOptions).pipe(
- map((results: any) => {
+ map((results: FetchResponse) => {
// Fix for a Graphite bug: https://github.com/graphite-project/graphite-web/issues/2609
// There is a fix for it https://github.com/graphite-project/graphite-web/pull/2612 but
// it was merged to master in July 2020 but it has never been released (the last Graphite
@@ -950,7 +950,7 @@ export class GraphiteDatasource
buildGraphiteParams(options: any, scopedVars?: ScopedVars): string[] {
const graphiteOptions = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
const cleanOptions = [],
- targets: any = {};
+ targets: Record = {};
let target, targetValue, i;
const regex = /\#([A-Z])/g;
const intervalFormatFixRegex = /'(\d+)m'/gi;
@@ -977,7 +977,7 @@ export class GraphiteDatasource
targets[target.refId] = targetValue;
}
- function nestedSeriesRegexReplacer(match: any, g1: string | number) {
+ function nestedSeriesRegexReplacer(match: string, g1: string | number) {
return targets[g1] || match;
}
@@ -1022,7 +1022,7 @@ function supportsFunctionIndex(version: string): boolean {
return isVersionGtOrEq(version, '1.1');
}
-function mapToTags(): OperatorFunction> {
+function mapToTags(): OperatorFunction> {
return pipe(
map((results) => {
if (results.data) {
diff --git a/public/app/plugins/datasource/graphite/gfunc.test.ts b/public/app/plugins/datasource/graphite/gfunc.test.ts
index 1c543b0d020..6330e3b63bf 100644
--- a/public/app/plugins/datasource/graphite/gfunc.test.ts
+++ b/public/app/plugins/datasource/graphite/gfunc.test.ts
@@ -1,10 +1,11 @@
-import gfunc, { FuncInstance } from './gfunc';
+import gfunc, { FuncDefs, FuncInstance } from './gfunc';
describe('gfunc', () => {
- const INDEX = {
+ const INDEX: FuncDefs = {
foo: {
name: 'foo',
params: [],
+ defaultParams: [],
},
};
diff --git a/public/app/plugins/datasource/graphite/gfunc.ts b/public/app/plugins/datasource/graphite/gfunc.ts
index e4351d668a7..c0dc1c04cc6 100644
--- a/public/app/plugins/datasource/graphite/gfunc.ts
+++ b/public/app/plugins/datasource/graphite/gfunc.ts
@@ -1112,7 +1112,7 @@ export class FuncInstance {
function createFuncInstance(
funcDef: FuncDef | string,
options?: { withDefaultParams: boolean },
- idx?: any
+ idx?: FuncDefs | null
): FuncInstance {
if (isString(funcDef)) {
funcDef = getFuncDef(funcDef, idx);
@@ -1120,14 +1120,14 @@ function createFuncInstance(
return new FuncInstance(funcDef, options);
}
-function getFuncDef(name: string, idx?: any): FuncDef {
+function getFuncDef(name: string, idx?: FuncDefs | null): FuncDef {
if (!(idx || index)[name]) {
return { name: name, params: [{ name: '', type: '', multiple: true }], defaultParams: [''], unknown: true };
}
return (idx || index)[name];
}
-function getFuncDefs(graphiteVersion: string, idx?: any): FuncDefs {
+function getFuncDefs(graphiteVersion: string, idx?: FuncDefs | null): FuncDefs {
const funcs: FuncDefs = {};
forEach(idx || index, (funcDef: FuncDef) => {
if (isVersionRelatedFunction(funcDef, graphiteVersion)) {
diff --git a/public/app/plugins/datasource/graphite/graphite_query.ts b/public/app/plugins/datasource/graphite/graphite_query.ts
index 9d2b8960b07..d3009ecb71f 100644
--- a/public/app/plugins/datasource/graphite/graphite_query.ts
+++ b/public/app/plugins/datasource/graphite/graphite_query.ts
@@ -38,7 +38,7 @@ export default class GraphiteQuery {
seriesByTagUsed = false;
checkOtherSegmentsIndex = 0;
removeTagValue: string;
- templateSrv: any;
+ templateSrv: TemplateSrv | undefined;
scopedVars?: ScopedVars;
constructor(datasource: GraphiteDatasource, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) {
@@ -172,7 +172,7 @@ export default class GraphiteQuery {
func.params.push(value);
}
- removeFunction(func: any) {
+ removeFunction(func: FuncInstance) {
this.functions = without(this.functions, func);
}
@@ -184,7 +184,7 @@ export default class GraphiteQuery {
updateModelTarget(targets: any) {
const wrapFunction = (target: string, func: FuncInstance) => {
return func.render(target, (value: string) => {
- return this.templateSrv.replace(value, this.scopedVars);
+ return this.templateSrv ? this.templateSrv.replace(value, this.scopedVars) : value;
});
};
@@ -290,7 +290,7 @@ export default class GraphiteQuery {
}
}
- addTag(tag: { key: any; operator: GraphiteTagOperator; value: string }) {
+ addTag(tag: { key: string; operator: GraphiteTagOperator; value: string }) {
const newTagParam = renderTagString(tag);
this.getSeriesByTagFunc()!.params.push(newTagParam);
this.tags.push(tag);
@@ -307,7 +307,10 @@ export default class GraphiteQuery {
if (tag.key === this.removeTagValue) {
this.removeTag(tagIndex);
if (this.tags.length === 0) {
- this.removeFunction(this.getSeriesByTagFunc());
+ const funcToRemove = this.getSeriesByTagFunc();
+ if (funcToRemove) {
+ this.removeFunction(funcToRemove);
+ }
this.checkOtherSegmentsIndex = 0;
this.seriesByTagUsed = false;
}
@@ -332,7 +335,7 @@ export default class GraphiteQuery {
}
}
-function renderTagString(tag: { key: any; operator?: any; value?: any }) {
+function renderTagString(tag: { key: string; operator?: GraphiteTagOperator; value?: string }) {
return tag.key + tag.operator + tag.value;
}
diff --git a/public/app/plugins/datasource/graphite/lexer.ts b/public/app/plugins/datasource/graphite/lexer.ts
index a587fb8ae24..296336013d1 100644
--- a/public/app/plugins/datasource/graphite/lexer.ts
+++ b/public/app/plugins/datasource/graphite/lexer.ts
@@ -62,7 +62,7 @@ const unicodeLetterTable = [
177972, 177984, 177984, 178205, 178205, 194560, 195101,
];
-const identifierStartTable: any[] = [];
+const identifierStartTable: boolean[] = [];
for (let i = 0; i < 128; i++) {
identifierStartTable[i] =
@@ -207,7 +207,7 @@ export class Lexer {
return /^[0-9a-fA-F]$/.test(str);
}
- const readUnicodeEscapeSequence = bind(function (this: any) {
+ const readUnicodeEscapeSequence = bind(function (this: Lexer) {
index += 1;
if (this.peek(index) !== 'u') {
@@ -234,7 +234,7 @@ export class Lexer {
return null;
}, this);
- const getIdentifierStart = bind(function (this: any) {
+ const getIdentifierStart = bind(function (this: Lexer) {
const chr = this.peek(index);
const code = chr.charCodeAt(0);
@@ -264,7 +264,7 @@ export class Lexer {
return null;
}, this);
- const getIdentifierPart = bind(function (this: any) {
+ const getIdentifierPart = bind(function (this: Lexer) {
const chr = this.peek(index);
const code = chr.charCodeAt(0);
diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts
index 69fe4452405..423b68cf88a 100644
--- a/public/app/plugins/datasource/influxdb/datasource.ts
+++ b/public/app/plugins/datasource/influxdb/datasource.ts
@@ -546,7 +546,7 @@ export default class InfluxDatasource extends DataSourceWithBackend {
+ map((result: FetchResponse) => {
const { data } = result;
if (data) {
data.executedQueryString = q;
diff --git a/public/app/plugins/datasource/influxdb/influx_query_model.ts b/public/app/plugins/datasource/influxdb/influx_query_model.ts
index 2035ea876a4..60e72048df4 100644
--- a/public/app/plugins/datasource/influxdb/influx_query_model.ts
+++ b/public/app/plugins/datasource/influxdb/influx_query_model.ts
@@ -11,7 +11,6 @@ import { DEFAULT_POLICY, InfluxQuery, InfluxQueryTag } from './types';
export default class InfluxQueryModel {
target: InfluxQuery;
selectModels: QueryPart[][] = [];
- queryBuilder: any;
groupByParts: QueryPart[] = [];
templateSrv: any;
scopedVars: ScopedVars | undefined;
diff --git a/public/app/plugins/datasource/influxdb/influx_series.ts b/public/app/plugins/datasource/influxdb/influx_series.ts
index 6addecb190a..d41e9b590ec 100644
--- a/public/app/plugins/datasource/influxdb/influx_series.ts
+++ b/public/app/plugins/datasource/influxdb/influx_series.ts
@@ -110,7 +110,7 @@ export default class InfluxSeries {
let titleCol: any = null;
let timeCol: any = null;
let timeEndCol: any = null;
- const tagsCol: any = [];
+ const tagsCol: string[] = [];
let textCol: any = null;
each(series.columns, (column, index) => {
@@ -152,10 +152,10 @@ export default class InfluxSeries {
// Remove empty values, then split in different tags for comma separated values
tags: flatten(
tagsCol
- .filter((t: any) => {
+ .filter((t) => {
return value[t];
})
- .map((t: any) => {
+ .map((t) => {
return value[t].split(',');
})
),