diff --git a/.betterer.results b/.betterer.results index 8a0dc3b9dfc..b5af32e93b2 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5,24 +5,8 @@ // exports[`better eslint`] = { value: `{ - "e2e/cypress/support/index.d.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "e2e/utils/flows/addDataSource.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "e2e/utils/support/scenarioContext.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "e2e/utils/support/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "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, "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.", "0"] ], "packages/grafana-data/src/dataframe/ArrayDataFrame.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -732,31 +716,15 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], - "packages/grafana-runtime/src/services/live.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-runtime/src/utils/DataSourceWithBackend.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.", "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"] - ], - "packages/grafana-runtime/src/utils/plugin.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "packages/grafana-runtime/src/utils/queryResponse.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], - "packages/grafana-runtime/src/utils/queryResponse.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.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"] + [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"] + ], + "packages/grafana-runtime/src/utils/queryResponse.ts:5381": [ + [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-schema/src/veneer/common.types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -816,12 +784,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Drawer/Drawer.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], - "packages/grafana-ui/src/components/Forms/FieldArray.story.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/Forms/Legacy/Input/Input.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -871,28 +833,16 @@ exports[`better eslint`] = { "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/JSONFormatter.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "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"] ], - "packages/grafana-ui/src/components/Layout/Layout.story.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"] - ], "packages/grafana-ui/src/components/MatchersUI/FieldValueMatcher.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-ui/src/components/MatchersUI/fieldMatchersUI.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Menu/MenuGroup.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "packages/grafana-ui/src/components/Menu/MenuItem.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/Menu/SubMenu.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] @@ -901,9 +851,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Unexpected any. Specify a different type.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "packages/grafana-ui/src/components/Monaco/CodeEditor.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] @@ -922,11 +870,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"] ], "packages/grafana-ui/src/components/QueryField/QueryField.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] - ], - "packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], "packages/grafana-ui/src/components/Segment/SegmentSelect.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -1040,14 +984,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Tags/Tag.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "packages/grafana-ui/src/components/TimeSeries/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -1556,10 +1492,6 @@ exports[`better eslint`] = { "public/app/core/navigation/GrafanaRouteError.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/core/navigation/__mocks__/routeProps.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/core/navigation/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/e2e/cypress/support/index.d.ts b/e2e/cypress/support/index.d.ts index d01547041ff..40dcf83105e 100644 --- a/e2e/cypress/support/index.d.ts +++ b/e2e/cypress/support/index.d.ts @@ -8,7 +8,7 @@ interface CompareScreenshotsConfig { declare namespace Cypress { interface Chainable { compareScreenshots(config: CompareScreenshotsConfig | string): Chainable; - logToConsole(message: string, optional?: any): void; + logToConsole(message: string, optional?: unknown): void; readProvisions(filePaths: string[]): Chainable; getJSONFilesFromDir(dirPath: string): Chainable; startBenchmarking(testName: string): void; diff --git a/e2e/utils/flows/addDataSource.ts b/e2e/utils/flows/addDataSource.ts index bdc0cc453f5..777ed6caf31 100644 --- a/e2e/utils/flows/addDataSource.ts +++ b/e2e/utils/flows/addDataSource.ts @@ -2,8 +2,6 @@ import { v4 as uuidv4 } from 'uuid'; import { e2e } from '../index'; -import { DeleteDataSourceConfig } from './deleteDataSource'; - export interface AddDataSourceConfig { basicAuth: boolean; basicAuthPassword: string; @@ -96,7 +94,7 @@ export const addDataSource = (config?: Partial) => { return cy.url().then(() => { e2e.getScenarioContext().then(({ addedDataSources }) => { e2e.setScenarioContext({ - addedDataSources: [...addedDataSources, { name } as DeleteDataSourceConfig], + addedDataSources: [...addedDataSources, { name, id: '' }], }); }); diff --git a/e2e/utils/support/scenarioContext.ts b/e2e/utils/support/scenarioContext.ts index eeb09ced3c4..15fcc01ed32 100644 --- a/e2e/utils/support/scenarioContext.ts +++ b/e2e/utils/support/scenarioContext.ts @@ -9,7 +9,6 @@ export interface ScenarioContext { lastAddedDataSource: string; // @todo rename to `lastAddedDataSourceName` lastAddedDataSourceId: string; hasChangedUserPreferences: boolean; - [key: string]: any; } const scenarioContext: ScenarioContext = { @@ -50,9 +49,7 @@ export const setScenarioContext = (newContext: Partial): Cypres .wrap( { setScenarioContext: () => { - Object.entries(newContext).forEach(([key, value]) => { - scenarioContext[key] = value; - }); + Object.assign(scenarioContext, newContext); }, }, { log: false } diff --git a/e2e/utils/support/types.ts b/e2e/utils/support/types.ts index d498dc68bea..193ad190b24 100644 --- a/e2e/utils/support/types.ts +++ b/e2e/utils/support/types.ts @@ -17,7 +17,7 @@ export type TypeSelectors = S extends StringSelector ? E2EFunction : S extends UrlSelector ? E2EVisit & Omit, 'url'> - : S extends Record + : S extends Record ? E2EFunctions : S; @@ -32,7 +32,7 @@ export type E2EFactoryArgs = { selectors: S }; export type CypressOptions = Partial; const processSelectors = (e2eObjects: E2EFunctions, selectors: S): E2EFunctions => { - const logOutput = (data: any) => cy.logToConsole('Retrieving Selector:', data); + const logOutput = (data: unknown) => cy.logToConsole('Retrieving Selector:', data); const keys = Object.keys(selectors); for (let index = 0; index < keys.length; index++) { const key = keys[index]; @@ -80,7 +80,7 @@ const processSelectors = (e2eObjects: E2EFunctions, sele e2eObjects[key] = function (textOrOptions?: string | CypressOptions, options?: CypressOptions) { // the input can only be () if (arguments.length === 0) { - const selector = value(undefined as unknown as string); + const selector = value(''); logOutput(selector); return cy.get(selector); @@ -97,7 +97,7 @@ const processSelectors = (e2eObjects: E2EFunctions, sele logOutput(selector); return cy.get(selector); } - const selector = value(undefined as unknown as string); + const selector = value(''); logOutput(selector); return cy.get(selector, textOrOptions); diff --git a/packages/grafana-runtime/src/services/live.ts b/packages/grafana-runtime/src/services/live.ts index 7d38ff8720e..e3787383995 100644 --- a/packages/grafana-runtime/src/services/live.ts +++ b/packages/grafana-runtime/src/services/live.ts @@ -79,7 +79,7 @@ export interface GrafanaLiveSrv { * * @alpha -- experimental */ - publish(address: LiveChannelAddress, data: unknown): Promise; + publish(address: LiveChannelAddress, data: unknown): Promise; } let singletonInstance: GrafanaLiveSrv; diff --git a/packages/grafana-runtime/src/utils/DataSourceWithBackend.test.ts b/packages/grafana-runtime/src/utils/DataSourceWithBackend.test.ts index c521e5c3633..b1815fcc095 100644 --- a/packages/grafana-runtime/src/utils/DataSourceWithBackend.test.ts +++ b/packages/grafana-runtime/src/utils/DataSourceWithBackend.test.ts @@ -11,6 +11,7 @@ import { createDataFrame, AdHocVariableFilter, ScopedVars, + getDefaultTimeRange, } from '@grafana/data'; import { config } from '../config'; @@ -61,6 +62,15 @@ jest.mock('../services', () => ({ jest.mock('./publicDashboardQueryHandler'); describe('DataSourceWithBackend', () => { + beforeEach(async () => { + jest.useFakeTimers(); + jest.setSystemTime(new Date('2023-10-13')); + }); + + afterEach(() => { + jest.useRealTimers(); + }); + test('check the executed queries', () => { const { mock, ds } = createMockDatasource(); ds.query({ @@ -70,6 +80,7 @@ describe('DataSourceWithBackend', () => { dashboardUID: 'dashA', panelId: 123, filters: [{ key: 'key1', operator: '=', value: 'val1' }], + range: getDefaultTimeRange(), queryGroupId: 'abc', } as DataQueryRequest); @@ -79,6 +90,7 @@ describe('DataSourceWithBackend', () => { expect(args).toMatchInlineSnapshot(` { "data": { + "from": "1697133600000", "queries": [ { "applyTemplateVariablesCalled": true, @@ -111,6 +123,7 @@ describe('DataSourceWithBackend', () => { "refId": "B", }, ], + "to": "1697155200000", }, "headers": { "X-Dashboard-Uid": "dashA", @@ -135,6 +148,7 @@ describe('DataSourceWithBackend', () => { targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: '__expr__' } }], dashboardUID: 'dashA', panelId: 123, + range: getDefaultTimeRange(), queryGroupId: 'abc', } as DataQueryRequest); @@ -144,6 +158,7 @@ describe('DataSourceWithBackend', () => { expect(args).toMatchInlineSnapshot(` { "data": { + "from": "1697133600000", "queries": [ { "applyTemplateVariablesCalled": true, @@ -167,6 +182,7 @@ describe('DataSourceWithBackend', () => { "refId": "B", }, ], + "to": "1697155200000", }, "headers": { "X-Dashboard-Uid": "dashA", @@ -190,6 +206,7 @@ describe('DataSourceWithBackend', () => { ds.query({ maxDataPoints: 10, intervalMs: 5000, + range: getDefaultTimeRange(), targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }], } as DataQueryRequest); @@ -205,6 +222,7 @@ describe('DataSourceWithBackend', () => { targets: [{ refId: 'A' }, { refId: 'B', datasource: { type: 'sample' } }], hideFromInspector: true, dashboardUID: 'dashA', + range: getDefaultTimeRange(), panelId: 123, } as DataQueryRequest); @@ -214,6 +232,7 @@ describe('DataSourceWithBackend', () => { expect(args).toMatchInlineSnapshot(` { "data": { + "from": "1697133600000", "queries": [ { "applyTemplateVariablesCalled": true, @@ -240,6 +259,7 @@ describe('DataSourceWithBackend', () => { "refId": "B", }, ], + "to": "1697155200000", }, "headers": { "X-Dashboard-Uid": "dashA", @@ -353,6 +373,7 @@ describe('DataSourceWithBackend', () => { dashboardUID: 'dashA', panelId: 123, queryGroupId: 'abc', + range: getDefaultTimeRange(), } as DataQueryRequest; ds.query(request); @@ -371,6 +392,7 @@ describe('DataSourceWithBackend', () => { dashboardUID: 'dashA', panelId: 123, queryGroupId: 'abc', + range: getDefaultTimeRange(), } as DataQueryRequest; ds.query(request); diff --git a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts index 0eea64b8899..da8a914251c 100644 --- a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts +++ b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts @@ -190,12 +190,11 @@ class DataSourceWithBackend< return of({ data: [] }); } - const body: any = { queries }; - - if (range) { - body.from = range.from.valueOf().toString(); - body.to = range.to.valueOf().toString(); - } + const body = { + queries, + from: range?.from.valueOf().toString(), + to: range?.to.valueOf().toString(), + }; if (config.featureToggles.queryOverLive) { return getGrafanaLiveSrv().getQueryData({ diff --git a/packages/grafana-runtime/src/utils/plugin.ts b/packages/grafana-runtime/src/utils/plugin.ts index 8f11c6f811e..ce2ab40b5b3 100644 --- a/packages/grafana-runtime/src/utils/plugin.ts +++ b/packages/grafana-runtime/src/utils/plugin.ts @@ -31,10 +31,10 @@ export const SystemJS = window.System; * @param options - plugin styling for light and dark theme. * @public */ -export async function loadPluginCss(options: PluginCssOptions): Promise { +export async function loadPluginCss(options: PluginCssOptions): Promise { try { const cssPath = config.bootData.user.theme === 'light' ? options.light : options.dark; - return await SystemJS.import(cssPath); + return SystemJS.import(cssPath); } catch (err) { console.error(err); } diff --git a/packages/grafana-runtime/src/utils/queryResponse.test.ts b/packages/grafana-runtime/src/utils/queryResponse.test.ts index adec09b9f9d..4b978d3615b 100644 --- a/packages/grafana-runtime/src/utils/queryResponse.test.ts +++ b/packages/grafana-runtime/src/utils/queryResponse.test.ts @@ -262,13 +262,13 @@ describe('Query Response parser', () => { data: { results: { X: { - series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any, + series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }], }, B: { - series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any, + series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }], }, A: { - series: [{ name: 'Requests/s', points: [[13.594958983547151, 1611839862951]] }] as any, + series: [{ target: '', datapoints: [[13.594958983547151, 1611839862951]] }], }, }, }, diff --git a/packages/grafana-runtime/src/utils/queryResponse.ts b/packages/grafana-runtime/src/utils/queryResponse.ts index 19b0d4b9e7f..0b434a69f8a 100644 --- a/packages/grafana-runtime/src/utils/queryResponse.ts +++ b/packages/grafana-runtime/src/utils/queryResponse.ts @@ -73,10 +73,11 @@ export function toDataQueryResponse( } // If the response isn't in a correct shape we just ignore the data and pass empty DataQueryResponse. - if ((res as FetchResponse).data?.results) { - const results = (res as FetchResponse).data.results; + const fetchResponse = res as FetchResponse; + if (fetchResponse.data?.results) { + const results = fetchResponse.data.results; const refIDs = queries?.length ? queries.map((q) => q.refId) : Object.keys(results); - const cachedResponse = isCachedResponse(res as FetchResponse); + const cachedResponse = isCachedResponse(fetchResponse); const data: DataResponse[] = []; for (const refId of refIDs) { @@ -144,7 +145,7 @@ export function toDataQueryResponse( } // When it is not an OK response, make sure the error gets added - if ((res as FetchResponse).status && (res as FetchResponse).status !== 200) { + if (fetchResponse.status && fetchResponse.status !== 200) { if (rsp.state !== LoadingState.Error) { rsp.state = LoadingState.Error; } diff --git a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx index a6dba1060bb..12bc9d9afe9 100644 --- a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx +++ b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx @@ -89,6 +89,9 @@ const ButtonSelectComponent = (props: Props) => { ButtonSelectComponent.displayName = 'ButtonSelect'; +// needed to properly forward the generic type through React.memo +// see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623 +// eslint-disable-next-line @typescript-eslint/consistent-type-assertions export const ButtonSelect = React.memo(ButtonSelectComponent) as typeof ButtonSelectComponent; const getStyles = (theme: GrafanaTheme2) => { diff --git a/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx b/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx index 3a5f134d76b..08a5dea278b 100644 --- a/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx +++ b/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx @@ -9,7 +9,7 @@ import { withStoryContainer } from '../../utils/storybook/withStoryContainer'; import { FieldArray } from './FieldArray'; import mdx from './FieldArray.mdx'; -export default { +const meta: Meta = { title: 'Forms/FieldArray', component: FieldArray, decorators: [withStoryContainer], @@ -25,7 +25,9 @@ export default { containerWidth: { control: { type: 'range', min: 100, max: 500, step: 10 } }, containerHeight: { control: { type: 'range', min: 100, max: 500, step: 10 } }, }, -} as Meta; +}; + +export default meta; export const Simple: Story = (args) => { const defaultValues: FieldValues = { diff --git a/packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx b/packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx index d7b89a29a2a..5a0bb78c353 100644 --- a/packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx +++ b/packages/grafana-ui/src/components/JSONFormatter/JSONFormatter.tsx @@ -7,7 +7,7 @@ interface Props { json: {}; config?: JsonExplorerConfig; open?: number; - onDidRender?: (formattedJson: any) => void; + onDidRender?: (formattedJson: {}) => void; } export class JSONFormatter extends PureComponent { diff --git a/packages/grafana-ui/src/components/Layout/Layout.story.tsx b/packages/grafana-ui/src/components/Layout/Layout.story.tsx index 52d87e40964..1391eb3467a 100644 --- a/packages/grafana-ui/src/components/Layout/Layout.story.tsx +++ b/packages/grafana-ui/src/components/Layout/Layout.story.tsx @@ -8,7 +8,7 @@ import { withStoryContainer } from '../../utils/storybook/withStoryContainer'; import { Layout, LayoutProps } from './Layout'; import mdx from './Layout.mdx'; -export default { +const meta: Meta = { title: 'Layout/Groups', component: Layout, decorators: [withStoryContainer], @@ -56,7 +56,9 @@ export default { }, }, }, -} as Meta; +}; + +export default meta; export const Horizontal: Story = (args) => { return ( diff --git a/packages/grafana-ui/src/components/Menu/MenuGroup.tsx b/packages/grafana-ui/src/components/Menu/MenuGroup.tsx index 305ba6b353a..4241dd2e608 100644 --- a/packages/grafana-ui/src/components/Menu/MenuGroup.tsx +++ b/packages/grafana-ui/src/components/Menu/MenuGroup.tsx @@ -9,7 +9,7 @@ import { useStyles2 } from '../../themes'; import { MenuItemProps } from './MenuItem'; /** @internal */ -export interface MenuItemsGroup { +export interface MenuItemsGroup { /** Label for the menu items group */ label?: string; /** Aria label for accessibility support */ diff --git a/packages/grafana-ui/src/components/Menu/MenuItem.tsx b/packages/grafana-ui/src/components/Menu/MenuItem.tsx index 0b8033b4f5c..74ef322bd43 100644 --- a/packages/grafana-ui/src/components/Menu/MenuItem.tsx +++ b/packages/grafana-ui/src/components/Menu/MenuItem.tsx @@ -14,7 +14,7 @@ import { SubMenu } from './SubMenu'; export type MenuItemElement = HTMLAnchorElement & HTMLButtonElement & HTMLDivElement; /** @internal */ -export interface MenuItemProps { +export interface MenuItemProps { /** Label of the menu item */ label: string; /** Aria label for accessibility support */ diff --git a/packages/grafana-ui/src/components/Modal/ModalsContext.tsx b/packages/grafana-ui/src/components/Modal/ModalsContext.tsx index 274d10b85f2..d2841532942 100644 --- a/packages/grafana-ui/src/components/Modal/ModalsContext.tsx +++ b/packages/grafana-ui/src/components/Modal/ModalsContext.tsx @@ -33,7 +33,7 @@ export class ModalsProvider extends Component, props: any) => { + showModal = (component: React.ComponentType, props: T) => { this.setState({ component, props, diff --git a/packages/grafana-ui/src/components/QueryField/QueryField.tsx b/packages/grafana-ui/src/components/QueryField/QueryField.tsx index cfb9ef7c5ac..040e265df46 100644 --- a/packages/grafana-ui/src/components/QueryField/QueryField.tsx +++ b/packages/grafana-ui/src/components/QueryField/QueryField.tsx @@ -1,7 +1,7 @@ import { css, cx } from '@emotion/css'; import classnames from 'classnames'; import { debounce } from 'lodash'; -import React, { Context, PureComponent } from 'react'; +import React, { PureComponent } from 'react'; import { Value } from 'slate'; import Plain from 'slate-plain-serializer'; import { Editor, EventHook, Plugin } from 'slate-react'; @@ -67,8 +67,8 @@ export class UnThemedQueryField extends PureComponent) { - super(props, context); + constructor(props: QueryFieldProps) { + super(props); this.runOnChangeDebounced = debounce(this.runOnChange, 500); diff --git a/packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx b/packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx index 99fd5e3a37e..918a5af232f 100644 --- a/packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx +++ b/packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx @@ -22,7 +22,12 @@ const loadOptions = (options: T): Promise => new Promise((res) => setTime const loadOptionsErr = (): Promise>> => new Promise((_, rej) => setTimeout(() => rej(Error('Could not find data')), 2000)); -const SegmentFrame = ({ loadOptions, children }: any) => ( +const SegmentFrame = ({ + loadOptions, + children, +}: React.PropsWithChildren<{ + loadOptions: (options: Array>) => Promise>>; +}>) => ( <> {children} diff --git a/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx b/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx index 377f14beba3..ccfea2e4dff 100644 --- a/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx +++ b/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx @@ -174,8 +174,8 @@ export const ThemeDemo = () => { - {Object.keys(t.shadows).map((key) => ( - + {Object.entries(t.shadows).map(([key, value]) => ( + ))} diff --git a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx index 849b7b38656..019671e2b6a 100644 --- a/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx +++ b/packages/grafana-ui/src/components/TimeSeries/TimeSeries.tsx @@ -4,7 +4,7 @@ import { DataFrame, TimeRange } from '@grafana/data'; import { withTheme2 } from '../../themes/ThemeContext'; import { GraphNG, GraphNGProps, PropDiffFn } from '../GraphNG/GraphNG'; -import { PanelContext, PanelContextRoot } from '../PanelChrome/PanelContext'; +import { PanelContextRoot } from '../PanelChrome/PanelContext'; import { hasVisibleLegendSeries, PlotLegend } from '../uPlot/PlotLegend'; import { UPlotConfigBuilder } from '../uPlot/config/UPlotConfigBuilder'; @@ -16,10 +16,10 @@ type TimeSeriesProps = Omit { static contextType = PanelContextRoot; - panelContext: PanelContext = {} as PanelContext; + declare context: React.ContextType; prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => { - const { eventBus, eventsScope, sync } = this.context as PanelContext; + const { eventBus, eventsScope, sync } = this.context; const { theme, timeZone, renderers, tweakAxis, tweakScale } = this.props; return preparePlotConfigBuilder({ diff --git a/public/app/core/navigation/__mocks__/routeProps.ts b/public/app/core/navigation/__mocks__/routeProps.ts index 23eac8bf7ad..b4437ef2d71 100644 --- a/public/app/core/navigation/__mocks__/routeProps.ts +++ b/public/app/core/navigation/__mocks__/routeProps.ts @@ -1,5 +1,6 @@ import { createMemoryHistory } from 'history'; import { merge } from 'lodash'; +import { match } from 'react-router-dom'; import { GrafanaRouteComponentProps } from '../types'; @@ -14,12 +15,12 @@ export function getRouteComponentProps, route: { path: '', component: () => null, }, - queryParams: {} as any, + queryParams: {} as Q, }; return merge(overrides, defaults); diff --git a/public/app/plugins/datasource/influxdb/datasource_backend_mode.test.ts b/public/app/plugins/datasource/influxdb/datasource_backend_mode.test.ts index c1e5d5f0b64..de3c2d3248a 100644 --- a/public/app/plugins/datasource/influxdb/datasource_backend_mode.test.ts +++ b/public/app/plugins/datasource/influxdb/datasource_backend_mode.test.ts @@ -130,7 +130,7 @@ describe('InfluxDataSource Backend Mode', () => { ...queryOptions, targets: [...queryOptions.targets, { ...influxQuery, adhocFilters }], }; - await ctx.ds.query(req); + ctx.ds.query(req); }); it('should add adhocFilters to the tags in the query', () => { @@ -244,6 +244,7 @@ describe('InfluxDataSource Backend Mode', () => { it('should render chained regex variables with floating point number', () => { ds.metricFindQuery(`SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= $maxSED`, { + ...queryOptions, scopedVars: { maxSED: { text: '8.1', value: '8.1' } }, }); const qe = `SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= 8.1`; @@ -253,6 +254,7 @@ describe('InfluxDataSource Backend Mode', () => { it('should render chained regex variables with URL', () => { ds.metricFindQuery('SHOW TAG VALUES WITH KEY = "agent_url" WHERE agent_url =~ /^$var1$/', { + ...queryOptions, scopedVars: { var1: { text: 'https://aaaa-aa-aaa.bbb.ccc.ddd:8443/ggggg', @@ -269,6 +271,7 @@ describe('InfluxDataSource Backend Mode', () => { ds.metricFindQuery( 'SELECT sum("piece_count") FROM "rp"."pdata" WHERE diameter <= $maxSED AND agent_url =~ /^$var1$/', { + ...queryOptions, scopedVars: { var1: { text: 'https://aaaa-aa-aaa.bbb.ccc.ddd:8443/ggggg',