From 9852b24d619f1cb5b15b2314798ab800676e1210 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Mon, 17 Jul 2023 15:58:22 +0100 Subject: [PATCH] Chore: Upgrade prettier to v3 (#71764) * Update dependency prettier to v3 (#71586) * Update dependency prettier to v3 * run prettier * ignore prettier update in legacy select scss * update command line arg --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ashley Harrison * unplug prettier --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .yarn/sdks/prettier/package.json | 2 +- e2e/cloud-plugins-suite/azure-monitor.spec.ts | 60 +++++++++++--- package.json | 13 ++- packages/grafana-data/src/events/EventBus.ts | 6 +- .../grafana-data/src/panel/PanelPlugin.ts | 2 +- .../src/types/OptionsUIRegistryBuilder.ts | 4 +- packages/grafana-data/src/types/datasource.ts | 16 ++-- packages/grafana-data/src/types/variables.ts | 8 +- .../grafana-data/src/vector/SortedVector.ts | 5 +- .../src/utils/DataSourceWithBackend.ts | 2 +- .../grafana-toolkit/src/cli/tasks/task.ts | 5 +- .../ConfirmButton/ConfirmButton.tsx | 13 ++- .../Forms/Legacy/Select/_Select.scss | 1 + .../Forms/RadioButtonList/RadioButtonDot.tsx | 4 +- .../src/components/Forms/commonStyles.ts | 11 ++- .../grafana-ui/src/components/Input/Input.tsx | 54 ++++++------ .../src/components/Menu/utils.test.ts | 2 +- .../PanelContainer/PanelContainer.tsx | 11 ++- .../components/Typeahead/TypeaheadItem.tsx | 7 +- .../transitions/SlideOutTransition.tsx | 8 +- .../utils/storybook/withStoryContainer.tsx | 4 +- .../src/utils/storybook/withTheme.tsx | 3 +- .../components/form_dropdown/form_dropdown.ts | 7 +- public/app/angular/components/switch.ts | 5 +- public/app/angular/diff-view.ts | 6 +- public/app/angular/panel/query_ctrl.ts | 5 +- public/app/angular/services/AngularLoader.ts | 5 +- .../AppChrome/SectionNav/SectionNavItem.tsx | 4 +- .../components/CloseButton/CloseButton.tsx | 11 ++- .../components/RolePicker/RolePickerInput.tsx | 4 +- public/app/core/components/help/HelpModal.tsx | 7 +- .../history/richHistoryLocalStorageUtils.ts | 4 +- public/app/core/services/keybindingSrv.ts | 5 +- .../alert-groups/AlertGroupHeader.tsx | 19 +++-- .../notification-policies/Modals.tsx | 2 +- .../receivers/editor/autocomplete.ts | 5 +- .../receivers/form/GrafanaReceiverForm.tsx | 2 +- .../components/rule-editor/QueryOptions.tsx | 6 +- .../rules/RuleDetailsDataSources.tsx | 19 +++-- .../rules/state-history/LogRecordViewer.tsx | 4 +- .../components/silences/SilencesTable.tsx | 17 ++-- .../unified/hooks/useURLSearchParams.ts | 2 +- .../unified/state/AlertingQueryRunner.ts | 5 +- .../features/alerting/unified/utils/rules.ts | 23 +++--- .../features/auth-config/ErrorContainer.tsx | 8 +- .../app/features/canvas/runtime/element.tsx | 6 +- public/app/features/canvas/runtime/frame.tsx | 6 +- public/app/features/canvas/runtime/root.tsx | 6 +- .../Forms/ConfigureCorrelationSourceForm.tsx | 6 +- .../AddPanelWidget/AddPanelWidget.tsx | 12 +-- .../AutoRefreshIntervals.test.tsx | 10 +-- .../PanelEditor/DynamicConfigValueEditor.tsx | 45 +++++----- .../dashboard/state/PanelModel.test.ts | 2 +- .../datasources/state/actions.test.ts | 8 +- .../datasources/state/reducers.test.ts | 2 +- .../features/explore/FeatureTogglePage.tsx | 7 +- .../explore/RichHistory/RichHistoryCard.tsx | 15 ++-- .../features/explore/TraceView/TraceView.tsx | 4 +- public/app/features/plugins/admin/helpers.ts | 11 ++- .../features/query/state/PanelQueryRunner.ts | 2 +- public/app/features/storage/RootView.tsx | 4 +- .../OrganizeFieldsTransformerEditor.tsx | 11 ++- public/app/features/transformers/utils.ts | 23 +++--- .../editor/getVariableQueryEditor.tsx | 4 +- public/app/features/variables/guard.ts | 20 ++--- .../app/features/variables/inspect/utils.ts | 82 ++++++++++--------- .../app/features/variables/query/actions.ts | 31 +++---- .../testing/datasourceVariableBuilder.ts | 2 +- public/app/features/variables/types.ts | 2 +- .../plugins/datasource/alertmanager/types.ts | 2 +- .../query-runner/CloudWatchRequest.ts | 5 +- .../elasticsearch/ElasticResponse.ts | 11 ++- .../datasource/elasticsearch/IndexPattern.ts | 5 +- .../plugins/datasource/graphite/datasource.ts | 5 +- .../CompletionDataProvider.ts | 5 +- .../datasource/mysql/sqlCompletionProvider.ts | 63 +++++++------- .../plugins/datasource/opentsdb/datasource.ts | 5 +- .../prometheus/metric_find_query.ts | 5 +- .../querybuilder/binaryScalarOperations.ts | 17 ++-- .../querybuilder/components/LabelFilters.tsx | 8 +- .../panel/annolist/AnnoListPanel.test.tsx | 2 +- public/app/plugins/panel/barchart/quadtree.ts | 8 +- public/app/plugins/panel/table-old/editor.ts | 5 +- public/app/plugins/panel/table-old/module.ts | 7 +- .../plugins/annotations/AnnotationTooltip.tsx | 4 +- public/sass/base/_grafana_icons.scss | 3 +- public/sass/base/font-awesome/_path.scss | 3 +- public/sass/components/_scrollbar.scss | 20 +++-- public/sass/components/_slate_editor.scss | 7 +- public/sass/components/_tagsinput.scss | 4 +- public/test/matchers/utils.ts | 4 +- public/test/mocks/datasource_srv.ts | 5 +- yarn.lock | 15 ++-- 93 files changed, 575 insertions(+), 380 deletions(-) diff --git a/.yarn/sdks/prettier/package.json b/.yarn/sdks/prettier/package.json index f2362f14d65..3c1bb0be150 100644 --- a/.yarn/sdks/prettier/package.json +++ b/.yarn/sdks/prettier/package.json @@ -1,6 +1,6 @@ { "name": "prettier", - "version": "2.8.4-sdk", + "version": "3.0.0-sdk", "main": "./index.js", "type": "commonjs" } diff --git a/e2e/cloud-plugins-suite/azure-monitor.spec.ts b/e2e/cloud-plugins-suite/azure-monitor.spec.ts index 98a2e0de423..5fceb7bbb4a 100644 --- a/e2e/cloud-plugins-suite/azure-monitor.spec.ts +++ b/e2e/cloud-plugins-suite/azure-monitor.spec.ts @@ -92,26 +92,62 @@ const addAzureMonitorVariable = ( .type(`${type.replace('Azure', '').trim()}{enter}`); switch (type) { case AzureQueryType.ResourceGroupsQuery: - e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`); + e2eSelectors.variableEditor.subscription + .input() + .find('input') + .type(`${options?.subscription}{enter}`); break; case AzureQueryType.LocationsQuery: - e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`); + e2eSelectors.variableEditor.subscription + .input() + .find('input') + .type(`${options?.subscription}{enter}`); break; case AzureQueryType.NamespacesQuery: - e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`); - e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`); + e2eSelectors.variableEditor.subscription + .input() + .find('input') + .type(`${options?.subscription}{enter}`); + e2eSelectors.variableEditor.resourceGroup + .input() + .find('input') + .type(`${options?.resourceGroup}{enter}`); break; case AzureQueryType.ResourceNamesQuery: - e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`); - e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`); - e2eSelectors.variableEditor.namespace.input().find('input').type(`${options?.namespace}{enter}`); - e2eSelectors.variableEditor.region.input().find('input').type(`${options?.region}{enter}`); + e2eSelectors.variableEditor.subscription + .input() + .find('input') + .type(`${options?.subscription}{enter}`); + e2eSelectors.variableEditor.resourceGroup + .input() + .find('input') + .type(`${options?.resourceGroup}{enter}`); + e2eSelectors.variableEditor.namespace + .input() + .find('input') + .type(`${options?.namespace}{enter}`); + e2eSelectors.variableEditor.region + .input() + .find('input') + .type(`${options?.region}{enter}`); break; case AzureQueryType.MetricNamesQuery: - e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`); - e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`); - e2eSelectors.variableEditor.namespace.input().find('input').type(`${options?.namespace}{enter}`); - e2eSelectors.variableEditor.resource.input().find('input').type(`${options?.resource}{enter}`); + e2eSelectors.variableEditor.subscription + .input() + .find('input') + .type(`${options?.subscription}{enter}`); + e2eSelectors.variableEditor.resourceGroup + .input() + .find('input') + .type(`${options?.resourceGroup}{enter}`); + e2eSelectors.variableEditor.namespace + .input() + .find('input') + .type(`${options?.namespace}{enter}`); + e2eSelectors.variableEditor.resource + .input() + .find('input') + .type(`${options?.resource}{enter}`); break; } e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().click(); diff --git a/package.json b/package.json index 98ca3278735..9052a6f5716 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "packages:pack": "mkdir -p ./npm-artifacts && lerna exec --no-private -- yarn pack --out \"../../npm-artifacts/%s-%v.tgz\"", "packages:typecheck": "lerna run typecheck", "precommit": "yarn run lint-staged", - "prettier:check": "prettier --check --list-different=false --loglevel=warn \"**/*.{ts,tsx,scss,md,mdx}\"", - "prettier:checkDocs": "prettier --check --list-different=false --loglevel=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx}\"", + "prettier:check": "prettier --check --list-different=false --log-level=warn \"**/*.{ts,tsx,scss,md,mdx}\"", + "prettier:checkDocs": "prettier --check --list-different=false --log-level=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx}\"", "prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx}\" --write", "start": "yarn themes:generate && yarn dev --watch", "start:noTsCheck": "yarn start --env noTsCheck=1", @@ -223,7 +223,7 @@ "postcss-loader": "7.3.3", "postcss-reporter": "7.0.5", "postcss-scss": "4.0.6", - "prettier": "2.8.4", + "prettier": "3.0.0", "react-refresh": "0.14.0", "react-select-event": "5.5.1", "react-simple-compat": "1.2.3", @@ -450,5 +450,10 @@ "engines": { "node": ">= 18" }, - "packageManager": "yarn@3.6.0" + "packageManager": "yarn@3.6.0", + "dependenciesMeta": { + "prettier@3.0.0": { + "unplugged": true + } + } } diff --git a/packages/grafana-data/src/events/EventBus.ts b/packages/grafana-data/src/events/EventBus.ts index 4296d98c668..2caf8a5c807 100644 --- a/packages/grafana-data/src/events/EventBus.ts +++ b/packages/grafana-data/src/events/EventBus.ts @@ -113,7 +113,11 @@ class ScopedEventBus implements EventBus { filterConfig: EventFilterOptions; // The path is not yet exposed, but can be used to indicate nested groups and support faster filtering - constructor(public path: string[], private eventBus: EventBus, filter?: EventFilterOptions) { + constructor( + public path: string[], + private eventBus: EventBus, + filter?: EventFilterOptions + ) { this.filterConfig = filter ?? { onlyLocal: false }; } diff --git a/packages/grafana-data/src/panel/PanelPlugin.ts b/packages/grafana-data/src/panel/PanelPlugin.ts index 150c53e7895..c0860426f7d 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 = any, > extends GrafanaPlugin { private _defaults?: TOptions; private _fieldConfigDefaults: FieldConfigSource = { diff --git a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts index 72bc00abfac..0765f1987a3 100644 --- a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts +++ b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts @@ -33,7 +33,7 @@ export interface OptionsEditorItem export interface OptionsUIRegistryBuilderAPI< TOptions, TEditorProps, - T extends OptionsEditorItem + T extends OptionsEditorItem, > { addNumberInput?( config: OptionEditorConfig @@ -80,7 +80,7 @@ export interface OptionsUIRegistryBuilderAPI< export abstract class OptionsUIRegistryBuilder< TOptions, TEditorProps, - T extends OptionsEditorItem + T extends OptionsEditorItem, > implements OptionsUIRegistryBuilderAPI { private properties: T[] = []; diff --git a/packages/grafana-data/src/types/datasource.ts b/packages/grafana-data/src/types/datasource.ts index 9a33ca35d5a..a2d839736c4 100644 --- a/packages/grafana-data/src/types/datasource.ts +++ b/packages/grafana-data/src/types/datasource.ts @@ -18,7 +18,7 @@ import { DataSourceRef, WithAccessControlMetadata } from '.'; export interface DataSourcePluginOptionsEditorProps< JSONData extends DataSourceJsonData = DataSourceJsonData, - SecureJSONData = {} + SecureJSONData = {}, > { options: DataSourceSettings; onOptionsChange: (options: DataSourceSettings) => void; @@ -34,7 +34,7 @@ export class DataSourcePlugin< DSType extends DataSourceApi, TQuery extends DataQuery = DataSourceQueryType, TOptions extends DataSourceJsonData = DataSourceOptionsType, - TSecureOptions = {} + TSecureOptions = {}, > extends GrafanaPlugin> { components: DataSourcePluginComponents = {}; @@ -155,7 +155,7 @@ export interface DataSourcePluginComponents< DSType extends DataSourceApi, TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData, - TSecureOptions = {} + TSecureOptions = {}, > { QueryCtrl?: any; AnnotationsQueryCtrl?: any; @@ -176,7 +176,7 @@ export interface DataSourcePluginComponents< export interface DataSourceConstructor< DSType extends DataSourceApi, TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > { new (instanceSettings: DataSourceInstanceSettings, ...args: any[]): DSType; } @@ -197,7 +197,7 @@ type VariableSupport = {} + TQueryImportConfiguration extends Record = {}, > { /** * Set in constructor @@ -375,7 +375,7 @@ abstract class DataSourceApi< export interface MetadataInspectorProps< DSType extends DataSourceApi, TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > { datasource: DSType; @@ -387,7 +387,7 @@ export interface QueryEditorProps< DSType extends DataSourceApi, TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData, - TVQuery extends DataQuery = TQuery + TVQuery extends DataQuery = TQuery, > { datasource: DSType; query: TVQuery; @@ -419,7 +419,7 @@ export enum ExploreMode { export type ExploreQueryFieldProps< DSType extends DataSourceApi, TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > = QueryEditorProps; export interface QueryEditorHelpProps { diff --git a/packages/grafana-data/src/types/variables.ts b/packages/grafana-data/src/types/variables.ts index f8d8666c09e..43978fe69a8 100644 --- a/packages/grafana-data/src/types/variables.ts +++ b/packages/grafana-data/src/types/variables.ts @@ -32,7 +32,7 @@ export enum VariableSupportType { export abstract class VariableSupportBase< DSType extends DataSourceApi, TQuery extends DataQuery = DataSourceQueryType, - TOptions extends DataSourceJsonData = DataSourceOptionsType + TOptions extends DataSourceJsonData = DataSourceOptionsType, > { abstract getType(): VariableSupportType; @@ -50,7 +50,7 @@ export abstract class VariableSupportBase< export abstract class StandardVariableSupport< DSType extends DataSourceApi, TQuery extends DataQuery = DataSourceQueryType, - TOptions extends DataSourceJsonData = DataSourceOptionsType + TOptions extends DataSourceJsonData = DataSourceOptionsType, > extends VariableSupportBase { getType(): VariableSupportType { return VariableSupportType.Standard; @@ -69,7 +69,7 @@ export abstract class CustomVariableSupport< DSType extends DataSourceApi, VariableQuery extends DataQuery = any, TQuery extends DataQuery = DataSourceQueryType, - TOptions extends DataSourceJsonData = DataSourceOptionsType + TOptions extends DataSourceJsonData = DataSourceOptionsType, > extends VariableSupportBase { getType(): VariableSupportType { return VariableSupportType.Custom; @@ -87,7 +87,7 @@ export abstract class CustomVariableSupport< export abstract class DataSourceVariableSupport< DSType extends DataSourceApi, TQuery extends DataQuery = DataSourceQueryType, - TOptions extends DataSourceJsonData = DataSourceOptionsType + TOptions extends DataSourceJsonData = DataSourceOptionsType, > extends VariableSupportBase { getType(): VariableSupportType { return VariableSupportType.Datasource; diff --git a/packages/grafana-data/src/vector/SortedVector.ts b/packages/grafana-data/src/vector/SortedVector.ts index 5e3dd5176ba..8ed64671688 100644 --- a/packages/grafana-data/src/vector/SortedVector.ts +++ b/packages/grafana-data/src/vector/SortedVector.ts @@ -9,7 +9,10 @@ import { vectorToArray } from './vectorToArray'; * @deprecated use a simple Arrays */ export class SortedVector extends FunctionalVector { - constructor(private source: Vector, private order: number[]) { + constructor( + private source: Vector, + private order: number[] + ) { super(); return makeArrayIndexableVector(this); } diff --git a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts index 482427e5187..5e9c758c2a3 100644 --- a/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts +++ b/packages/grafana-runtime/src/utils/DataSourceWithBackend.ts @@ -113,7 +113,7 @@ export interface HealthCheckResult { */ class DataSourceWithBackend< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { constructor(instanceSettings: DataSourceInstanceSettings) { super(instanceSettings); diff --git a/packages/grafana-toolkit/src/cli/tasks/task.ts b/packages/grafana-toolkit/src/cli/tasks/task.ts index 4524508bd83..73973c8b50f 100644 --- a/packages/grafana-toolkit/src/cli/tasks/task.ts +++ b/packages/grafana-toolkit/src/cli/tasks/task.ts @@ -3,7 +3,10 @@ export type TaskRunner = (options: T) => Promise; export class Task { options: TOptions = {} as any; - constructor(public name: string, public runner: TaskRunner) {} + constructor( + public name: string, + public runner: TaskRunner + ) {} setName = (name: string) => { this.name = name; }; diff --git a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx index 18ce89de782..aa806566705 100644 --- a/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx +++ b/packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx @@ -164,7 +164,9 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => { `, buttonHide: css` opacity: 0; - transition: opacity 0.1s ease, visibility 0 0.1s; + transition: + opacity 0.1s ease, + visibility 0 0.1s; visibility: hidden; z-index: 0; `, @@ -178,14 +180,19 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => { confirmButtonShow: css` z-index: 1; opacity: 1; - transition: opacity 0.08s ease-out, transform 0.1s ease-out; + transition: + opacity 0.08s ease-out, + transform 0.1s ease-out; transform: translateX(0); pointer-events: all; `, confirmButtonHide: css` opacity: 0; visibility: hidden; - transition: opacity 0.12s ease-in, transform 0.14s ease-in, visibility 0s 0.12s; + transition: + opacity 0.12s ease-in, + transform 0.14s ease-in, + visibility 0s 0.12s; transform: translateX(100px); `, disabled: css` diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/_Select.scss b/packages/grafana-ui/src/components/Forms/Legacy/Select/_Select.scss index 62028ed1dd4..ace4fcc36e6 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/_Select.scss +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/_Select.scss @@ -11,6 +11,7 @@ $select-input-bg-disabled: $input-bg-disabled; @mixin select-control-focus() { border-color: $input-border-focus; outline: none; + // prettier-ignore $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px $input-box-shadow-focus; @include box-shadow($shadow); } diff --git a/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonDot.tsx b/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonDot.tsx index 78761cc4e77..55e6ce11a24 100644 --- a/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonDot.tsx +++ b/packages/grafana-ui/src/components/Forms/RadioButtonList/RadioButtonDot.tsx @@ -75,7 +75,9 @@ const getStyles = (theme: GrafanaTheme2) => ({ :focus { outline: none !important; - box-shadow: 0 0 0 1px ${theme.colors.background.canvas}, 0 0 0 3px ${theme.colors.primary.main}; + box-shadow: + 0 0 0 1px ${theme.colors.background.canvas}, + 0 0 0 3px ${theme.colors.primary.main}; } `, label: css` diff --git a/packages/grafana-ui/src/components/Forms/commonStyles.ts b/packages/grafana-ui/src/components/Forms/commonStyles.ts index ddc3399a740..d4ae7e92eef 100644 --- a/packages/grafana-ui/src/components/Forms/commonStyles.ts +++ b/packages/grafana-ui/src/components/Forms/commonStyles.ts @@ -33,15 +33,20 @@ export const sharedInputStyle = (theme: GrafanaTheme2, invalid = false) => { &:-webkit-autofill, &:-webkit-autofill:hover { /* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */ - box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0), inset 0 0 0 100px ${background}!important; + box-shadow: + inset 0 0 0 1px rgba(255, 255, 255, 0), + inset 0 0 0 100px ${background}!important; -webkit-text-fill-color: ${textColor} !important; border-color: ${autoFillBorder}; } &:-webkit-autofill:focus { /* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */ - box-shadow: 0 0 0 2px ${theme.colors.background.primary}, 0 0 0px 4px ${theme.colors.primary.main}, - inset 0 0 0 1px rgba(255, 255, 255, 0), inset 0 0 0 100px ${background}!important; + box-shadow: + 0 0 0 2px ${theme.colors.background.primary}, + 0 0 0px 4px ${theme.colors.primary.main}, + inset 0 0 0 1px rgba(255, 255, 255, 0), + inset 0 0 0 100px ${background}!important; -webkit-text-fill-color: ${textColor} !important; } diff --git a/packages/grafana-ui/src/components/Input/Input.tsx b/packages/grafana-ui/src/components/Input/Input.tsx index fdbf6f666f8..7eb170c228c 100644 --- a/packages/grafana-ui/src/components/Input/Input.tsx +++ b/packages/grafana-ui/src/components/Input/Input.tsx @@ -100,35 +100,33 @@ export const getInputStyles = stylesFactory(({ theme, invalid = false, width }: return { // Wraps inputWrapper and addons - wrapper: cx( - css` - label: input-wrapper; - display: flex; - width: ${width ? `${theme.spacing(width)}` : '100%'}; - height: ${theme.spacing(theme.components.height.md)}; - border-radius: ${theme.shape.borderRadius()}; - &:hover { - > .prefix, - .suffix, - .input { - border-color: ${invalid ? theme.colors.error.border : theme.colors.primary.border}; - } - - // only show number buttons on hover - input[type='number'] { - -moz-appearance: number-input; - -webkit-appearance: number-input; - appearance: textfield; - } - - input[type='number']::-webkit-inner-spin-button, - input[type='number']::-webkit-outer-spin-button { - -webkit-appearance: inner-spin-button !important; - opacity: 1; - } + wrapper: cx(css` + label: input-wrapper; + display: flex; + width: ${width ? `${theme.spacing(width)}` : '100%'}; + height: ${theme.spacing(theme.components.height.md)}; + border-radius: ${theme.shape.borderRadius()}; + &:hover { + > .prefix, + .suffix, + .input { + border-color: ${invalid ? theme.colors.error.border : theme.colors.primary.border}; } - ` - ), + + // only show number buttons on hover + input[type='number'] { + -moz-appearance: number-input; + -webkit-appearance: number-input; + appearance: textfield; + } + + input[type='number']::-webkit-inner-spin-button, + input[type='number']::-webkit-outer-spin-button { + -webkit-appearance: inner-spin-button !important; + opacity: 1; + } + } + `), // Wraps input and prefix/suffix inputWrapper: css` label: input-inputWrapper; diff --git a/packages/grafana-ui/src/components/Menu/utils.test.ts b/packages/grafana-ui/src/components/Menu/utils.test.ts index 11ab59f1d6c..6960813bea1 100644 --- a/packages/grafana-ui/src/components/Menu/utils.test.ts +++ b/packages/grafana-ui/src/components/Menu/utils.test.ts @@ -8,7 +8,7 @@ describe('utils', () => { getBoundingClientRect: () => ({ right }), }, getBoundingClientRect: () => ({ width }), - } as HTMLElement); + }) as HTMLElement; Object.defineProperty(window, 'innerWidth', { value: 1000 }); diff --git a/packages/grafana-ui/src/components/PanelContainer/PanelContainer.tsx b/packages/grafana-ui/src/components/PanelContainer/PanelContainer.tsx index 7add88dc4cc..fe2ed4bc149 100644 --- a/packages/grafana-ui/src/components/PanelContainer/PanelContainer.tsx +++ b/packages/grafana-ui/src/components/PanelContainer/PanelContainer.tsx @@ -16,9 +16,8 @@ export const PanelContainer = ({ children, className, ...props }: Props) => { ); }; -const getStyles = (theme: GrafanaTheme2) => - css` - background-color: ${theme.components.panel.background}; - border: 1px solid ${theme.components.panel.borderColor}; - border-radius: ${theme.shape.radius.default}; - `; +const getStyles = (theme: GrafanaTheme2) => css` + background-color: ${theme.components.panel.background}; + border: 1px solid ${theme.components.panel.borderColor}; + border-radius: ${theme.shape.radius.default}; +`; diff --git a/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx b/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx index 89750758c0a..b9cab738685 100644 --- a/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx +++ b/packages/grafana-ui/src/components/Typeahead/TypeaheadItem.tsx @@ -36,8 +36,11 @@ const getStyles = (theme: GrafanaTheme2) => ({ display: block; white-space: nowrap; cursor: pointer; - transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), - background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1); + transition: + color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1); `, typeaheadItemSelected: css` diff --git a/packages/grafana-ui/src/components/transitions/SlideOutTransition.tsx b/packages/grafana-ui/src/components/transitions/SlideOutTransition.tsx index 4bdac36eb2c..ff0dbee6034 100644 --- a/packages/grafana-ui/src/components/transitions/SlideOutTransition.tsx +++ b/packages/grafana-ui/src/components/transitions/SlideOutTransition.tsx @@ -15,7 +15,9 @@ const getStyles = stylesFactory((duration: number, measurement: 'width' | 'heigh label: enterActive; ${measurement}: ${size}px; opacity: 1; - transition: opacity ${duration}ms ease-out, ${measurement} ${duration}ms ease-out; + transition: + opacity ${duration}ms ease-out, + ${measurement} ${duration}ms ease-out; `, exit: css` label: exit; @@ -26,7 +28,9 @@ const getStyles = stylesFactory((duration: number, measurement: 'width' | 'heigh label: exitActive; opacity: 0; ${measurement}: 0; - transition: opacity ${duration}ms ease-out, ${measurement} ${duration}ms ease-out; + transition: + opacity ${duration}ms ease-out, + ${measurement} ${duration}ms ease-out; `, }; }); diff --git a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx index baed4477e01..c600c4673f5 100644 --- a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx +++ b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx @@ -17,7 +17,9 @@ const StoryContainer = ({ width, height, showBoundaries, children }: React.Props css` background-color: white; background-size: 30px 30px; - background-position: 0 0, 15px 15px; + background-position: + 0 0, + 15px 15px; background-image: linear-gradient( 45deg, ${checkColor} 25%, diff --git a/packages/grafana-ui/src/utils/storybook/withTheme.tsx b/packages/grafana-ui/src/utils/storybook/withTheme.tsx index 447b6b38a55..45cec079dd5 100644 --- a/packages/grafana-ui/src/utils/storybook/withTheme.tsx +++ b/packages/grafana-ui/src/utils/storybook/withTheme.tsx @@ -52,5 +52,4 @@ export const renderComponentWithTheme = (component: React.ComponentType, pr export const withTheme = (handleSassThemeChange: SassThemeChangeHandler): DecoratorFn => // eslint-disable-next-line react/display-name - (story) => - {story()}; + (story) => {story()}; diff --git a/public/app/angular/components/form_dropdown/form_dropdown.ts b/public/app/angular/components/form_dropdown/form_dropdown.ts index 3637a2f0487..dc3716615bd 100644 --- a/public/app/angular/components/form_dropdown/form_dropdown.ts +++ b/public/app/angular/components/form_dropdown/form_dropdown.ts @@ -41,7 +41,12 @@ export class FormDropdownCtrl { static $inject = ['$scope', '$element', '$sce', 'templateSrv']; - constructor(private $scope: any, $element: JQLite, private $sce: ISCEService, private templateSrv: any) { + constructor( + private $scope: any, + $element: JQLite, + private $sce: ISCEService, + private templateSrv: any + ) { this.inputElement = $element.find('input').first(); this.linkElement = $element.find('a').first(); this.linkMode = true; diff --git a/public/app/angular/components/switch.ts b/public/app/angular/components/switch.ts index 341dbcb8943..d67531ba174 100644 --- a/public/app/angular/components/switch.ts +++ b/public/app/angular/components/switch.ts @@ -39,7 +39,10 @@ export class SwitchCtrl { static $inject = ['$scope', '$timeout']; - constructor($scope: any, private $timeout: any) { + constructor( + $scope: any, + private $timeout: any + ) { this.show = true; this.id = $scope.$id; } diff --git a/public/app/angular/diff-view.ts b/public/app/angular/diff-view.ts index 23fc8280fad..fa7a0a06b7c 100644 --- a/public/app/angular/diff-view.ts +++ b/public/app/angular/diff-view.ts @@ -42,7 +42,11 @@ coreModule.directive('diffDelta', delta); export class LinkJSONCtrl { static $inject = ['$scope', '$rootScope', '$anchorScroll']; - constructor(private $scope: any, private $rootScope: GrafanaRootScope, private $anchorScroll: any) {} + constructor( + private $scope: any, + private $rootScope: GrafanaRootScope, + private $anchorScroll: any + ) {} goToLine(line: number) { let unbind: () => void; diff --git a/public/app/angular/panel/query_ctrl.ts b/public/app/angular/panel/query_ctrl.ts index 1a02ba248bf..ac8dd17b895 100644 --- a/public/app/angular/panel/query_ctrl.ts +++ b/public/app/angular/panel/query_ctrl.ts @@ -10,7 +10,10 @@ export class QueryCtrl { error?: string | null; isLastQuery: boolean; - constructor(public $scope: any, public $injector: auto.IInjectorService) { + constructor( + public $scope: any, + public $injector: auto.IInjectorService + ) { this.panelCtrl = this.panelCtrl ?? $scope.ctrl.panelCtrl; this.target = this.target ?? $scope.ctrl.target; this.datasource = this.datasource ?? $scope.ctrl.datasource; diff --git a/public/app/angular/services/AngularLoader.ts b/public/app/angular/services/AngularLoader.ts index a006bbd14ce..4244eebdd2b 100644 --- a/public/app/angular/services/AngularLoader.ts +++ b/public/app/angular/services/AngularLoader.ts @@ -8,7 +8,10 @@ import coreModule from 'app/angular/core_module'; export class AngularLoader implements AngularLoaderInterface { static $inject = ['$compile', '$rootScope']; - constructor(private $compile: any, private $rootScope: GrafanaRootScope) {} + constructor( + private $compile: any, + private $rootScope: GrafanaRootScope + ) {} load(elem: any, scopeProps: any, template: string): AngularComponent { const scope = this.$rootScope.$new(); diff --git a/public/app/core/components/AppChrome/SectionNav/SectionNavItem.tsx b/public/app/core/components/AppChrome/SectionNav/SectionNavItem.tsx index d7e0579adfc..7865ac56343 100644 --- a/public/app/core/components/AppChrome/SectionNav/SectionNavItem.tsx +++ b/public/app/core/components/AppChrome/SectionNav/SectionNavItem.tsx @@ -56,9 +56,7 @@ export function SectionNavItem({ item, isSectionRoot = false }: Props) { {item.text} {item.tabSuffix && } - {children?.map((child, index) => ( - - ))} + {children?.map((child, index) => )} ); } diff --git a/public/app/core/components/CloseButton/CloseButton.tsx b/public/app/core/components/CloseButton/CloseButton.tsx index f00aa961b6d..77b40669936 100644 --- a/public/app/core/components/CloseButton/CloseButton.tsx +++ b/public/app/core/components/CloseButton/CloseButton.tsx @@ -24,9 +24,8 @@ export const CloseButton = ({ onClick, 'aria-label': ariaLabel, style }: Props) ); }; -const getStyles = (theme: GrafanaTheme2) => - css` - position: absolute; - right: ${theme.spacing(0.5)}; - top: ${theme.spacing(1)}; - `; +const getStyles = (theme: GrafanaTheme2) => css` + position: absolute; + right: ${theme.spacing(0.5)}; + top: ${theme.spacing(1)}; +`; diff --git a/public/app/core/components/RolePicker/RolePickerInput.tsx b/public/app/core/components/RolePicker/RolePickerInput.tsx index c3e6a4e2089..cfd357601ea 100644 --- a/public/app/core/components/RolePicker/RolePickerInput.tsx +++ b/public/app/core/components/RolePicker/RolePickerInput.tsx @@ -101,9 +101,7 @@ export const RolesLabel = ({ showBuiltInRole, numberOfRoles, appliedRoles }: Rol - {appliedRoles?.map((role) => ( -

{role.displayName}

- ))} + {appliedRoles?.map((role) =>

{role.displayName}

)} } > diff --git a/public/app/core/components/help/HelpModal.tsx b/public/app/core/components/help/HelpModal.tsx index d78d3d74c4c..7761c3e4d6e 100644 --- a/public/app/core/components/help/HelpModal.tsx +++ b/public/app/core/components/help/HelpModal.tsx @@ -140,7 +140,12 @@ function getStyles(theme: GrafanaTheme2) { text-align: center; margin-right: ${theme.spacing(0.5)}; padding: 3px 5px; - font: 11px Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font: + 11px Consolas, + 'Liberation Mono', + Menlo, + Courier, + monospace; line-height: 10px; vertical-align: middle; border: solid 1px ${theme.colors.border.medium}; diff --git a/public/app/core/history/richHistoryLocalStorageUtils.ts b/public/app/core/history/richHistoryLocalStorageUtils.ts index 7f58de9a860..f5ff6da8150 100644 --- a/public/app/core/history/richHistoryLocalStorageUtils.ts +++ b/public/app/core/history/richHistoryLocalStorageUtils.ts @@ -57,8 +57,8 @@ function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchFilter: const listOfMatchingQueries = query.queries.filter((query) => // Remove fields in which we don't want to be searching - Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value) => - value?.toString().includes(searchFilter) + Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some( + (value) => value?.toString().includes(searchFilter) ) ); diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index 5874414764f..8a836dc2d90 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -29,7 +29,10 @@ import { toggleTheme } from './theme'; import { withFocusedPanel } from './withFocusedPanelId'; export class KeybindingSrv { - constructor(private locationService: LocationService, private chromeService: AppChromeService) {} + constructor( + private locationService: LocationService, + private chromeService: AppChromeService + ) {} clearAndInitGlobalBindings(route: RouteDescriptor) { Mousetrap.reset(); diff --git a/public/app/features/alerting/unified/components/alert-groups/AlertGroupHeader.tsx b/public/app/features/alerting/unified/components/alert-groups/AlertGroupHeader.tsx index 421bc369b53..6a4b7a2ca22 100644 --- a/public/app/features/alerting/unified/components/alert-groups/AlertGroupHeader.tsx +++ b/public/app/features/alerting/unified/components/alert-groups/AlertGroupHeader.tsx @@ -13,14 +13,17 @@ interface Props { export const AlertGroupHeader = ({ group }: Props) => { const textStyles = useStyles2(getNotificationsTextColors); const total = group.alerts.length; - const countByStatus = group.alerts.reduce((statusObj, alert) => { - if (statusObj[alert.status.state]) { - statusObj[alert.status.state] += 1; - } else { - statusObj[alert.status.state] = 1; - } - return statusObj; - }, {} as Record); + const countByStatus = group.alerts.reduce( + (statusObj, alert) => { + if (statusObj[alert.status.state]) { + statusObj[alert.status.state] += 1; + } else { + statusObj[alert.status.state] = 1; + } + return statusObj; + }, + {} as Record + ); return (
diff --git a/public/app/features/alerting/unified/components/notification-policies/Modals.tsx b/public/app/features/alerting/unified/components/notification-policies/Modals.tsx index f6c01c0b24c..7719426d6ad 100644 --- a/public/app/features/alerting/unified/components/notification-policies/Modals.tsx +++ b/public/app/features/alerting/unified/components/notification-policies/Modals.tsx @@ -206,7 +206,7 @@ const useDeletePolicyModal = (handleDelete: (route: RouteWithID) => void, loadin const useAlertGroupsModal = (): [ JSX.Element, (alertGroups: AlertmanagerGroup[], matchers?: ObjectMatcher[]) => void, - () => void + () => void, ] => { const [showModal, setShowModal] = useState(false); const [alertGroups, setAlertGroups] = useState([]); diff --git a/public/app/features/alerting/unified/components/receivers/editor/autocomplete.ts b/public/app/features/alerting/unified/components/receivers/editor/autocomplete.ts index a844123d5d8..97e4db27e20 100644 --- a/public/app/features/alerting/unified/components/receivers/editor/autocomplete.ts +++ b/public/app/features/alerting/unified/components/receivers/editor/autocomplete.ts @@ -63,7 +63,10 @@ function isInsideGoExpression(model: editor.ITextModel, position: Position) { } export class CompletionProvider { - constructor(private readonly monaco: Monaco, private readonly range: IRange) {} + constructor( + private readonly monaco: Monaco, + private readonly range: IRange + ) {} getSnippetsSuggestions = (): languages.ProviderResult => { return this.getCompletionsFromDefinitions(getSnippetsSuggestions(this.monaco)); diff --git a/public/app/features/alerting/unified/components/receivers/form/GrafanaReceiverForm.tsx b/public/app/features/alerting/unified/components/receivers/form/GrafanaReceiverForm.tsx index e68361c2be0..bc45af1f128 100644 --- a/public/app/features/alerting/unified/components/receivers/form/GrafanaReceiverForm.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/GrafanaReceiverForm.tsx @@ -59,7 +59,7 @@ export const GrafanaReceiverForm = ({ existing, alertManagerSourceName, config } // transform receiver DTO to form values const [existingValue, id2original] = useMemo((): [ ReceiverFormValues | undefined, - Record + Record, ] => { if (!existing || !grafanaNotifiers.result) { return [undefined, {}]; diff --git a/public/app/features/alerting/unified/components/rule-editor/QueryOptions.tsx b/public/app/features/alerting/unified/components/rule-editor/QueryOptions.tsx index 7f3c8661fb5..0e135599e12 100644 --- a/public/app/features/alerting/unified/components/rule-editor/QueryOptions.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/QueryOptions.tsx @@ -62,7 +62,11 @@ export const QueryOptions = ({
- {dateTime(timeRange?.from).locale('en').fromNow(true)} + + {dateTime(timeRange?.from) + .locale('en') + .fromNow(true)} + {queryOptions.maxDataPoints && , MD {queryOptions.maxDataPoints}}
diff --git a/public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx b/public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx index 0734db52c61..c3cfa95dfa3 100644 --- a/public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx +++ b/public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx @@ -27,16 +27,19 @@ export function RuleDetailsDataSources(props: Props): JSX.Element | null { if (isGrafanaRulerRule(rule.rulerRule)) { const { data } = rule.rulerRule.grafana_alert; - const unique = data.reduce((dataSources, query) => { - const ds = getDataSourceSrv().getInstanceSettings(query.datasourceUid); + const unique = data.reduce( + (dataSources, query) => { + const ds = getDataSourceSrv().getInstanceSettings(query.datasourceUid); - if (!ds || ds.uid === ExpressionDatasourceUID) { + if (!ds || ds.uid === ExpressionDatasourceUID) { + return dataSources; + } + + dataSources[ds.name] = { name: ds.name, icon: ds.meta.info.logos.small }; return dataSources; - } - - dataSources[ds.name] = { name: ds.name, icon: ds.meta.info.logos.small }; - return dataSources; - }, {} as Record); + }, + {} as Record + ); return Object.values(unique); } diff --git a/public/app/features/alerting/unified/components/rules/state-history/LogRecordViewer.tsx b/public/app/features/alerting/unified/components/rules/state-history/LogRecordViewer.tsx index d167d8c507a..eaa8cd9bc05 100644 --- a/public/app/features/alerting/unified/components/rules/state-history/LogRecordViewer.tsx +++ b/public/app/features/alerting/unified/components/rules/state-history/LogRecordViewer.tsx @@ -181,7 +181,9 @@ const getStyles = (theme: GrafanaTheme2) => ({ background: transparent; outline: 1px solid transparent; - transition: background 150ms, outline 150ms; + transition: + background 150ms, + outline 150ms; padding: ${theme.spacing(1)} ${theme.spacing(1.5)}; `, }); diff --git a/public/app/features/alerting/unified/components/silences/SilencesTable.tsx b/public/app/features/alerting/unified/components/silences/SilencesTable.tsx index 3d456e17e53..5ea21ded2a3 100644 --- a/public/app/features/alerting/unified/components/silences/SilencesTable.tsx +++ b/public/app/features/alerting/unified/components/silences/SilencesTable.tsx @@ -148,14 +148,15 @@ const useFilteredSilences = (silences: Silence[], expired = false) => { } if (queryString) { const matchers = parseMatchers(queryString); - const matchersMatch = matchers.every((matcher) => - silence.matchers?.some( - ({ name, value, isEqual, isRegex }) => - matcher.name === name && - matcher.value === value && - matcher.isEqual === isEqual && - matcher.isRegex === isRegex - ) + const matchersMatch = matchers.every( + (matcher) => + silence.matchers?.some( + ({ name, value, isEqual, isRegex }) => + matcher.name === name && + matcher.value === value && + matcher.isEqual === isEqual && + matcher.isRegex === isRegex + ) ); if (!matchersMatch) { return false; diff --git a/public/app/features/alerting/unified/hooks/useURLSearchParams.ts b/public/app/features/alerting/unified/hooks/useURLSearchParams.ts index f67cecda4bb..3203c883afc 100644 --- a/public/app/features/alerting/unified/hooks/useURLSearchParams.ts +++ b/public/app/features/alerting/unified/hooks/useURLSearchParams.ts @@ -5,7 +5,7 @@ import { locationService } from '@grafana/runtime'; export function useURLSearchParams(): [ URLSearchParams, - (searchValues: Record, replace?: boolean) => void + (searchValues: Record, replace?: boolean) => void, ] { const { search } = useLocation(); const queryParams = useMemo(() => new URLSearchParams(search), [search]); diff --git a/public/app/features/alerting/unified/state/AlertingQueryRunner.ts b/public/app/features/alerting/unified/state/AlertingQueryRunner.ts index b8aa462e620..62fd898c836 100644 --- a/public/app/features/alerting/unified/state/AlertingQueryRunner.ts +++ b/public/app/features/alerting/unified/state/AlertingQueryRunner.ts @@ -35,7 +35,10 @@ export class AlertingQueryRunner { private subscription?: Unsubscribable; private lastResult: Record; - constructor(private backendSrv = getBackendSrv(), private dataSourceSrv = getDataSourceSrv()) { + constructor( + private backendSrv = getBackendSrv(), + private dataSourceSrv = getDataSourceSrv() + ) { this.subject = new ReplaySubject(1); this.lastResult = {}; } diff --git a/public/app/features/alerting/unified/utils/rules.ts b/public/app/features/alerting/unified/utils/rules.ts index 5cc7210935b..1a94e098e7c 100644 --- a/public/app/features/alerting/unified/utils/rules.ts +++ b/public/app/features/alerting/unified/utils/rules.ts @@ -169,17 +169,20 @@ export function getFirstActiveAt(promRule?: AlertingRule) { if (!promRule?.alerts) { return null; } - return promRule.alerts.reduce((prev, alert) => { - const isNotNormal = - mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal; - if (alert.activeAt && isNotNormal) { - const activeAt = new Date(alert.activeAt); - if (prev === null || prev.getTime() > activeAt.getTime()) { - return activeAt; + return promRule.alerts.reduce( + (prev, alert) => { + const isNotNormal = + mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal; + if (alert.activeAt && isNotNormal) { + const activeAt = new Date(alert.activeAt); + if (prev === null || prev.getTime() > activeAt.getTime()) { + return activeAt; + } } - } - return prev; - }, null as Date | null); + return prev; + }, + null as Date | null + ); } /** diff --git a/public/app/features/auth-config/ErrorContainer.tsx b/public/app/features/auth-config/ErrorContainer.tsx index fbb039896f0..e237aa629f0 100644 --- a/public/app/features/auth-config/ErrorContainer.tsx +++ b/public/app/features/auth-config/ErrorContainer.tsx @@ -26,16 +26,12 @@ export const ErrorContainerUnconnected = ({ error, warning, resetError, resetWar
{error && ( resetError()}> - {error.errors?.map((e, i) => ( -
{e}
- ))} + {error.errors?.map((e, i) =>
{e}
)}
)} {warning && ( resetWarning()} severity="warning"> - {warning.errors?.map((e, i) => ( -
{e}
- ))} + {warning.errors?.map((e, i) =>
{e}
)}
)}
diff --git a/public/app/features/canvas/runtime/element.tsx b/public/app/features/canvas/runtime/element.tsx index 94f8b41cfcd..74852198ae9 100644 --- a/public/app/features/canvas/runtime/element.tsx +++ b/public/app/features/canvas/runtime/element.tsx @@ -36,7 +36,11 @@ export class ElementState implements LayerElement { // Calculated data?: any; // depends on the type - constructor(public item: CanvasElementItem, public options: CanvasElementOptions, public parent?: FrameState) { + constructor( + public item: CanvasElementItem, + public options: CanvasElementOptions, + public parent?: FrameState + ) { const fallbackName = `Element ${Date.now()}`; if (!options) { this.options = { type: item.id, name: fallbackName }; diff --git a/public/app/features/canvas/runtime/frame.tsx b/public/app/features/canvas/runtime/frame.tsx index fd1cc9c8dfd..0d8ef5ee588 100644 --- a/public/app/features/canvas/runtime/frame.tsx +++ b/public/app/features/canvas/runtime/frame.tsx @@ -36,7 +36,11 @@ export class FrameState extends ElementState { elements: ElementState[] = []; scene: Scene; - constructor(public options: CanvasFrameOptions, scene: Scene, public parent?: FrameState) { + constructor( + public options: CanvasFrameOptions, + scene: Scene, + public parent?: FrameState + ) { super(frameItemDummy, options, parent); this.scene = scene; diff --git a/public/app/features/canvas/runtime/root.tsx b/public/app/features/canvas/runtime/root.tsx index 9faebe93379..955d1db57e1 100644 --- a/public/app/features/canvas/runtime/root.tsx +++ b/public/app/features/canvas/runtime/root.tsx @@ -6,7 +6,11 @@ import { FrameState } from './frame'; import { Scene } from './scene'; export class RootElement extends FrameState { - constructor(public options: CanvasFrameOptions, public scene: Scene, private changeCallback: () => void) { + constructor( + public options: CanvasFrameOptions, + public scene: Scene, + private changeCallback: () => void + ) { super(options, scene); this.sizeStyle = { diff --git a/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx b/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx index e44fd529290..f692b547d02 100644 --- a/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx +++ b/public/app/features/correlations/Forms/ConfigureCorrelationSourceForm.tsx @@ -37,9 +37,9 @@ export const ConfigureCorrelationSourceForm = () => { return ( <>

Define what data source will display the correlation, and what data will replace previously defined variables. diff --git a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx index 4966670094d..a1020e1a613 100644 --- a/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx +++ b/public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx @@ -232,10 +232,10 @@ const getStyles = (theme: GrafanaTheme2) => { const pulsate = keyframes` 0% {box-shadow: 0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main};} 50% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${tinycolor( - theme.colors.primary.main - ) - .darken(20) - .toHexString()};} + theme.colors.primary.main + ) + .darken(20) + .toHexString()};} 100% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${theme.colors.primary.main};} `; @@ -249,7 +249,9 @@ const getStyles = (theme: GrafanaTheme2) => { overflow: hidden; outline: 2px dotted transparent; outline-offset: 2px; - box-shadow: 0 0 0 2px black, 0 0 0px 4px #1f60c4; + box-shadow: + 0 0 0 2px black, + 0 0 0px 4px #1f60c4; animation: ${pulsate} 2s ease infinite; `, actionsWrapper: css` diff --git a/public/app/features/dashboard/components/DashboardSettings/AutoRefreshIntervals.test.tsx b/public/app/features/dashboard/components/DashboardSettings/AutoRefreshIntervals.test.tsx index 27bc5ba5cb9..5ab5d6638a6 100644 --- a/public/app/features/dashboard/components/DashboardSettings/AutoRefreshIntervals.test.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/AutoRefreshIntervals.test.tsx @@ -100,7 +100,7 @@ describe('getValidIntervals', () => { getTimeSrv: () => ({ getValidIntervals: (intervals: string[]) => intervals, - } as unknown as TimeSrv), + }) as unknown as TimeSrv, }; const result = getValidIntervals(emptyIntervals, dependencies); @@ -116,7 +116,7 @@ describe('getValidIntervals', () => { getTimeSrv: () => ({ getValidIntervals: (intervals: string[]) => intervals, - } as unknown as TimeSrv), + }) as unknown as TimeSrv, }; const result = getValidIntervals(duplicateIntervals, dependencies); @@ -132,7 +132,7 @@ describe('getValidIntervals', () => { getTimeSrv: () => ({ getValidIntervals: (intervals: string[]) => intervals, - } as unknown as TimeSrv), + }) as unknown as TimeSrv, }; const result = getValidIntervals(duplicateIntervals, dependencies); @@ -149,7 +149,7 @@ describe('validateIntervals', () => { getTimeSrv: () => ({ getValidIntervals: (intervals: string[]) => intervals, - } as unknown as TimeSrv), + }) as unknown as TimeSrv, }; const result = validateIntervals(defaultIntervals, dependencies); @@ -166,7 +166,7 @@ describe('validateIntervals', () => { getValidIntervals: () => { throw new Error('Some error'); }, - } as unknown as TimeSrv), + }) as unknown as TimeSrv, }; const result = validateIntervals(defaultIntervals, dependencies); diff --git a/public/app/features/dashboard/components/PanelEditor/DynamicConfigValueEditor.tsx b/public/app/features/dashboard/components/PanelEditor/DynamicConfigValueEditor.tsx index d4c28d49211..bd31fb439a8 100644 --- a/public/app/features/dashboard/components/PanelEditor/DynamicConfigValueEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/DynamicConfigValueEditor.tsx @@ -53,30 +53,29 @@ export const DynamicConfigValueEditor = ({ /* eslint-disable react/display-name */ const renderLabel = (includeDescription = true, includeCounter = false) => - (isExpanded = false) => - ( - - - {!isSystemOverride && ( -

- -
+ (isExpanded = false) => ( + + - ); + + {!isSystemOverride && ( +
+ +
+ )} + + ); /* eslint-enable react/display-name */ if (isCollapsible) { diff --git a/public/app/features/dashboard/state/PanelModel.test.ts b/public/app/features/dashboard/state/PanelModel.test.ts index d4c1ddac190..67eed4ed7cf 100644 --- a/public/app/features/dashboard/state/PanelModel.test.ts +++ b/public/app/features/dashboard/state/PanelModel.test.ts @@ -499,7 +499,7 @@ describe('PanelModel', () => { describe('destroy', () => { it('Should still preserve last query result', () => { model.getQueryRunner().useLastResultFrom({ - getLastResult: () => ({} as PanelData), + getLastResult: () => ({}) as PanelData, } as PanelQueryRunner); model.destroy(); diff --git a/public/app/features/datasources/state/actions.test.ts b/public/app/features/datasources/state/actions.test.ts index 6749ad8a230..dc88dc9bee9 100644 --- a/public/app/features/datasources/state/actions.test.ts +++ b/public/app/features/datasources/state/actions.test.ts @@ -50,7 +50,7 @@ const getBackendSrvMock = () => }), }), withNoBackendCache: jest.fn().mockImplementationOnce((cb) => cb()), - } as any); + }) as any; const failDataSourceTest = async (error: object) => { const dependencies: TestDataSourceDependencies = { @@ -61,7 +61,7 @@ const failDataSourceTest = async (error: object) => { throw error; }), }), - } as any), + }) as any, getBackendSrv: getBackendSrvMock, }; const state = { @@ -223,7 +223,7 @@ describe('testDataSource', () => { type: 'cloudwatch', uid: 'CW1234', }), - } as any), + }) as any, getBackendSrv: getBackendSrvMock, }; const state = { @@ -258,7 +258,7 @@ describe('testDataSource', () => { type: 'azure-monitor', uid: 'azM0nit0R', }), - } as any), + }) as any, getBackendSrv: getBackendSrvMock, }; const result = { diff --git a/public/app/features/datasources/state/reducers.test.ts b/public/app/features/datasources/state/reducers.test.ts index 078b28fbe24..ff8c49a4bbe 100644 --- a/public/app/features/datasources/state/reducers.test.ts +++ b/public/app/features/datasources/state/reducers.test.ts @@ -37,7 +37,7 @@ const mockPlugin = () => pinned: true, type: PluginType.datasource, module: 'path/to/module', - } as PluginMeta); + }) as PluginMeta; describe('dataSourcesReducer', () => { describe('when dataSourcesLoaded is dispatched', () => { diff --git a/public/app/features/explore/FeatureTogglePage.tsx b/public/app/features/explore/FeatureTogglePage.tsx index a10df73f183..254da695d93 100644 --- a/public/app/features/explore/FeatureTogglePage.tsx +++ b/public/app/features/explore/FeatureTogglePage.tsx @@ -7,10 +7,9 @@ import { Page } from 'app/core/components/Page/Page'; export default function FeatureTogglePage() { const styles = useStyles2( - (theme: GrafanaTheme2) => - css` - margin-top: ${theme.spacing(2)}; - ` + (theme: GrafanaTheme2) => css` + margin-top: ${theme.spacing(2)}; + ` ); return ( diff --git a/public/app/features/explore/RichHistory/RichHistoryCard.tsx b/public/app/features/explore/RichHistory/RichHistoryCard.tsx index 6cb7d708d8e..ca78122403e 100644 --- a/public/app/features/explore/RichHistory/RichHistoryCard.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryCard.tsx @@ -403,14 +403,13 @@ const Query = ({ query, showDsInfo = false }: QueryProps) => { ); }; -const getDsInfoStyles = (size: 'sm' | 'md') => (theme: GrafanaTheme2) => - css` - display: flex; - align-items: center; - font-size: ${theme.typography[size === 'sm' ? 'bodySmall' : 'body'].fontSize}; - font-weight: ${theme.typography.fontWeightMedium}; - white-space: nowrap; - `; +const getDsInfoStyles = (size: 'sm' | 'md') => (theme: GrafanaTheme2) => css` + display: flex; + align-items: center; + font-size: ${theme.typography[size === 'sm' ? 'bodySmall' : 'body'].fontSize}; + font-weight: ${theme.typography.fontWeightMedium}; + white-space: nowrap; +`; function DatasourceInfo({ dsApi, size }: { dsApi?: DataSourceApi; size: 'sm' | 'md' }) { const getStyles = useCallback((theme: GrafanaTheme2) => getDsInfoStyles(size)(theme), [size]); diff --git a/public/app/features/explore/TraceView/TraceView.tsx b/public/app/features/explore/TraceView/TraceView.tsx index f3afe636b0b..8a4ba0d38ba 100644 --- a/public/app/features/explore/TraceView/TraceView.tsx +++ b/public/app/features/explore/TraceView/TraceView.tsx @@ -264,8 +264,8 @@ function useFocusSpanLink(options: { }) ); - const query = useSelector((state) => - state.explore.panes[options.exploreId]?.queries.find((query) => query.refId === options.refId) + const query = useSelector( + (state) => state.explore.panes[options.exploreId]?.queries.find((query) => query.refId === options.refId) ); const createFocusSpanLink = (traceId: string, spanId: string) => { diff --git a/public/app/features/plugins/admin/helpers.ts b/public/app/features/plugins/admin/helpers.ts index eda9ad37d8e..e9460d2ded4 100644 --- a/public/app/features/plugins/admin/helpers.ts +++ b/public/app/features/plugins/admin/helpers.ts @@ -223,10 +223,13 @@ export const sortPlugins = (plugins: CatalogPlugin[], sortBy: Sorters) => { }; function groupErrorsByPluginId(errors: PluginError[] = []): Record { - return errors.reduce((byId, error) => { - byId[error.pluginId] = error; - return byId; - }, {} as Record); + return errors.reduce( + (byId, error) => { + byId[error.pluginId] = error; + return byId; + }, + {} as Record + ); } function getPluginSignature(options: { diff --git a/public/app/features/query/state/PanelQueryRunner.ts b/public/app/features/query/state/PanelQueryRunner.ts index ea3f01d0ded..6fde35c5cd8 100644 --- a/public/app/features/query/state/PanelQueryRunner.ts +++ b/public/app/features/query/state/PanelQueryRunner.ts @@ -44,7 +44,7 @@ import { runRequest } from './runRequest'; export interface QueryRunnerOptions< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > { datasource: DataSourceRef | DataSourceApi | null; queries: TQuery[]; diff --git a/public/app/features/storage/RootView.tsx b/public/app/features/storage/RootView.tsx index 0a2cecdd7fe..62bda7bb4e1 100644 --- a/public/app/features/storage/RootView.tsx +++ b/public/app/features/storage/RootView.tsx @@ -72,9 +72,7 @@ export function RootView({ root, onPathChange }: Props) { {s.config.description} {s.config.git?.remote && {s.config.git?.remote}} - {s.notice?.map((notice) => ( - - ))} + {s.notice?.map((notice) => )} diff --git a/public/app/features/transformers/editors/OrganizeFieldsTransformerEditor.tsx b/public/app/features/transformers/editors/OrganizeFieldsTransformerEditor.tsx index e310a41e7fc..da25487528c 100644 --- a/public/app/features/transformers/editors/OrganizeFieldsTransformerEditor.tsx +++ b/public/app/features/transformers/editors/OrganizeFieldsTransformerEditor.tsx @@ -192,10 +192,13 @@ const reorderToIndex = (fieldNames: string[], startIndex: number, endIndex: numb const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); - return result.reduce((nameByIndex, fieldName, index) => { - nameByIndex[fieldName] = index; - return nameByIndex; - }, {} as Record); + return result.reduce( + (nameByIndex, fieldName, index) => { + nameByIndex[fieldName] = index; + return nameByIndex; + }, + {} as Record + ); }; const orderFieldNamesByIndex = (fieldNames: string[], indexByName: Record = {}): string[] => { diff --git a/public/app/features/transformers/utils.ts b/public/app/features/transformers/utils.ts index a3159caf244..adf95a8c19e 100644 --- a/public/app/features/transformers/utils.ts +++ b/public/app/features/transformers/utils.ts @@ -9,17 +9,20 @@ export function useAllFieldNamesFromDataFrames(input: DataFrame[]): string[] { } return Object.keys( - input.reduce((names, frame) => { - if (!frame || !Array.isArray(frame.fields)) { - return names; - } + input.reduce( + (names, frame) => { + if (!frame || !Array.isArray(frame.fields)) { + return names; + } - return frame.fields.reduce((names, field) => { - const t = getFieldDisplayName(field, frame, input); - names[t] = true; - return names; - }, names); - }, {} as Record) + return frame.fields.reduce((names, field) => { + const t = getFieldDisplayName(field, frame, input); + names[t] = true; + return names; + }, names); + }, + {} as Record + ) ); }, [input]); } diff --git a/public/app/features/variables/editor/getVariableQueryEditor.tsx b/public/app/features/variables/editor/getVariableQueryEditor.tsx index d3557d7f07a..5d2d34d4c0d 100644 --- a/public/app/features/variables/editor/getVariableQueryEditor.tsx +++ b/public/app/features/variables/editor/getVariableQueryEditor.tsx @@ -17,7 +17,7 @@ import { LegacyVariableQueryEditor } from './LegacyVariableQueryEditor'; export async function getVariableQueryEditor< TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData, - VariableQuery extends DataQuery = TQuery + VariableQuery extends DataQuery = TQuery, >( datasource: DataSourceApi, importDataSourcePluginFunc = importDataSourcePlugin @@ -50,7 +50,7 @@ export async function getVariableQueryEditor< export function StandardVariableQueryEditor< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >({ datasource: propsDatasource, query: propsQuery, diff --git a/public/app/features/variables/guard.ts b/public/app/features/variables/guard.ts index a24869c2c67..a953979a33b 100644 --- a/public/app/features/variables/guard.ts +++ b/public/app/features/variables/guard.ts @@ -62,7 +62,7 @@ export function isLegacyAdHocDataSource(datasource: null | DataSourceRef | strin interface DataSourceWithLegacyVariableSupport< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { metricFindQuery(query: any, options?: any): Promise; variables: undefined; @@ -70,7 +70,7 @@ interface DataSourceWithLegacyVariableSupport< interface DataSourceWithStandardVariableSupport< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { variables: { getType(): VariableSupportType; @@ -81,7 +81,7 @@ interface DataSourceWithStandardVariableSupport< interface DataSourceWithCustomVariableSupport< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { variables: { getType(): VariableSupportType; @@ -92,7 +92,7 @@ interface DataSourceWithCustomVariableSupport< interface DataSourceWithDatasourceVariableSupport< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { variables: { getType(): VariableSupportType; @@ -105,7 +105,7 @@ interface DataSourceWithDatasourceVariableSupport< * */ export const hasLegacyVariableSupport = < TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( datasource: DataSourceApi ): datasource is DataSourceWithLegacyVariableSupport => { @@ -114,7 +114,7 @@ export const hasLegacyVariableSupport = < export const hasStandardVariableSupport = < TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( datasource: DataSourceApi ): datasource is DataSourceWithStandardVariableSupport => { @@ -132,7 +132,7 @@ export const hasStandardVariableSupport = < export const hasCustomVariableSupport = < TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( datasource: DataSourceApi ): datasource is DataSourceWithCustomVariableSupport => { @@ -155,7 +155,7 @@ export const hasCustomVariableSupport = < export const hasDatasourceVariableSupport = < TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( datasource: DataSourceApi ): datasource is DataSourceWithDatasourceVariableSupport => { @@ -168,7 +168,7 @@ export const hasDatasourceVariableSupport = < export function isLegacyQueryEditor< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( component: VariableQueryEditorType, datasource: DataSourceApi @@ -182,7 +182,7 @@ export function isLegacyQueryEditor< export function isQueryEditor< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, >( component: VariableQueryEditorType, datasource: DataSourceApi diff --git a/public/app/features/variables/inspect/utils.ts b/public/app/features/variables/inspect/utils.ts index 3ff5b9993ba..f123858d113 100644 --- a/public/app/features/variables/inspect/utils.ts +++ b/public/app/features/variables/inspect/utils.ts @@ -118,52 +118,58 @@ const validVariableNames: Record = { }; export const getPropsWithVariable = (variableId: string, parent: { key: string; value: any }, result: any) => { - const stringValues = Object.keys(parent.value).reduce((all, key) => { - const value = parent.value[key]; - if (!value || typeof value !== 'string') { - return all; - } - - const isValidName = validVariableNames[key] - ? validVariableNames[key].find((regex: RegExp) => regex.test(variableId)) - : undefined; - - let hasVariable = containsVariable(value, variableId); - if (key === 'repeat' && value === variableId) { - // repeat stores value without variable format - hasVariable = true; - } - - if (!isValidName && hasVariable) { - all = { - ...all, - [key]: value, - }; - } - - return all; - }, {} as Record); - - const objectValues = Object.keys(parent.value).reduce((all, key) => { - const value = parent.value[key]; - if (value && typeof value === 'object' && Object.keys(value).length) { - let id = value.title || value.name || value.id || key; - if (Array.isArray(parent.value) && parent.key === 'panels') { - id = `${id}[${value.id}]`; + const stringValues = Object.keys(parent.value).reduce( + (all, key) => { + const value = parent.value[key]; + if (!value || typeof value !== 'string') { + return all; } - const newResult = getPropsWithVariable(variableId, { key, value }, {}); + const isValidName = validVariableNames[key] + ? validVariableNames[key].find((regex: RegExp) => regex.test(variableId)) + : undefined; - if (Object.keys(newResult).length) { + let hasVariable = containsVariable(value, variableId); + if (key === 'repeat' && value === variableId) { + // repeat stores value without variable format + hasVariable = true; + } + + if (!isValidName && hasVariable) { all = { ...all, - [id]: newResult, + [key]: value, }; } - } - return all; - }, {} as Record); + return all; + }, + {} as Record + ); + + const objectValues = Object.keys(parent.value).reduce( + (all, key) => { + const value = parent.value[key]; + if (value && typeof value === 'object' && Object.keys(value).length) { + let id = value.title || value.name || value.id || key; + if (Array.isArray(parent.value) && parent.key === 'panels') { + id = `${id}[${value.id}]`; + } + + const newResult = getPropsWithVariable(variableId, { key, value }, {}); + + if (Object.keys(newResult).length) { + all = { + ...all, + [id]: newResult, + }; + } + } + + return all; + }, + {} as Record + ); if (Object.keys(stringValues).length || Object.keys(objectValues).length) { result = { diff --git a/public/app/features/variables/query/actions.ts b/public/app/features/variables/query/actions.ts index a5b3a5d58d0..41b3131846e 100644 --- a/public/app/features/variables/query/actions.ts +++ b/public/app/features/variables/query/actions.ts @@ -184,22 +184,25 @@ export function flattenQuery(query: any): any { } const keys = Object.keys(query); - const flattened = keys.reduce((all, key) => { - const value = query[key]; - if (typeof value !== 'object' || value === null) { - all[key] = value; - return all; - } - - const result = flattenQuery(value); - for (let childProp in result) { - if (result.hasOwnProperty(childProp)) { - all[`${key}_${childProp}`] = result[childProp]; + const flattened = keys.reduce( + (all, key) => { + const value = query[key]; + if (typeof value !== 'object' || value === null) { + all[key] = value; + return all; } - } - return all; - }, {} as Record); + const result = flattenQuery(value); + for (let childProp in result) { + if (result.hasOwnProperty(childProp)) { + all[`${key}_${childProp}`] = result[childProp]; + } + } + + return all; + }, + {} as Record + ); return flattened; } diff --git a/public/app/features/variables/shared/testing/datasourceVariableBuilder.ts b/public/app/features/variables/shared/testing/datasourceVariableBuilder.ts index 28847c872ae..8f52026e81e 100644 --- a/public/app/features/variables/shared/testing/datasourceVariableBuilder.ts +++ b/public/app/features/variables/shared/testing/datasourceVariableBuilder.ts @@ -3,7 +3,7 @@ import { DataSourceVariableModel, QueryVariableModel, VariableRefresh } from 'ap import { MultiVariableBuilder } from './multiVariableBuilder'; export class DatasourceVariableBuilder< - T extends DataSourceVariableModel | QueryVariableModel + T extends DataSourceVariableModel | QueryVariableModel, > extends MultiVariableBuilder { withRefresh(refresh: VariableRefresh) { this.variable.refresh = refresh; diff --git a/public/app/features/variables/types.ts b/public/app/features/variables/types.ts index 3b74f7914be..11c66dcfafd 100644 --- a/public/app/features/variables/types.ts +++ b/public/app/features/variables/types.ts @@ -89,7 +89,7 @@ export interface VariableQueryEditorProps { export type VariableQueryEditorType< TQuery extends DataQuery = DataQuery, - TOptions extends DataSourceJsonData = DataSourceJsonData + TOptions extends DataSourceJsonData = DataSourceJsonData, > = ComponentType | ComponentType> | null; export interface VariablesChangedEvent { diff --git a/public/app/plugins/datasource/alertmanager/types.ts b/public/app/plugins/datasource/alertmanager/types.ts index 5d7c2fab86b..b8ff117bc1d 100644 --- a/public/app/plugins/datasource/alertmanager/types.ts +++ b/public/app/plugins/datasource/alertmanager/types.ts @@ -218,7 +218,7 @@ export type AlertmanagerAlert = { receivers: [ { name: string; - } + }, ]; fingerprint: string; status: { diff --git a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchRequest.ts b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchRequest.ts index beaf0424414..8570f18393d 100644 --- a/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchRequest.ts +++ b/public/app/plugins/datasource/cloudwatch/query-runner/CloudWatchRequest.ts @@ -20,7 +20,10 @@ export abstract class CloudWatchRequest { AppNotificationTimeout.Error ); - constructor(public instanceSettings: DataSourceInstanceSettings, templateSrv: TemplateSrv) { + constructor( + public instanceSettings: DataSourceInstanceSettings, + templateSrv: TemplateSrv + ) { this.templateSrv = templateSrv; this.ref = getDataSourceRef(instanceSettings); } diff --git a/public/app/plugins/datasource/elasticsearch/ElasticResponse.ts b/public/app/plugins/datasource/elasticsearch/ElasticResponse.ts index cd74a7147b8..f76107b0376 100644 --- a/public/app/plugins/datasource/elasticsearch/ElasticResponse.ts +++ b/public/app/plugins/datasource/elasticsearch/ElasticResponse.ts @@ -27,7 +27,10 @@ interface TopMetricBucket { } export class ElasticResponse { - constructor(private targets: ElasticsearchQuery[], private response: any) { + constructor( + private targets: ElasticsearchQuery[], + private response: any + ) { this.targets = targets; this.response = response; } @@ -784,8 +787,10 @@ const addPreferredVisualisationType = (series: any, type: PreferredVisualisation const toNameTypePair = (docs: Array>) => - (propName: string): [string, FieldType] => - [propName, guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName])]; + (propName: string): [string, FieldType] => [ + propName, + guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName]), + ]; /** * Trying to guess data type from its value. This is far from perfect, as in order to have accurate guess diff --git a/public/app/plugins/datasource/elasticsearch/IndexPattern.ts b/public/app/plugins/datasource/elasticsearch/IndexPattern.ts index 4f8b1221c4d..a0334e712bb 100644 --- a/public/app/plugins/datasource/elasticsearch/IndexPattern.ts +++ b/public/app/plugins/datasource/elasticsearch/IndexPattern.ts @@ -21,7 +21,10 @@ export const intervalMap: IntervalMap = { export class IndexPattern { private dateLocale = 'en'; - constructor(private pattern: string, private interval?: keyof typeof intervalMap) {} + constructor( + private pattern: string, + private interval?: keyof typeof intervalMap + ) {} getIndexForToday() { if (this.interval) { diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index 98260c728ce..c8de04dc765 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -84,7 +84,10 @@ export class GraphiteDatasource requestCounter = 100; private readonly metricMappings: GraphiteLokiMapping[]; - constructor(instanceSettings: any, private readonly templateSrv: TemplateSrv = getTemplateSrv()) { + constructor( + instanceSettings: any, + private readonly templateSrv: TemplateSrv = getTemplateSrv() + ) { super(instanceSettings); this.basicAuth = instanceSettings.basicAuth; this.url = instanceSettings.url; diff --git a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/CompletionDataProvider.ts b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/CompletionDataProvider.ts index d435fb1ab86..eb515bf1521 100644 --- a/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/CompletionDataProvider.ts +++ b/public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/CompletionDataProvider.ts @@ -13,7 +13,10 @@ interface HistoryRef { } export class CompletionDataProvider { - constructor(private languageProvider: LanguageProvider, private historyRef: HistoryRef = { current: [] }) {} + constructor( + private languageProvider: LanguageProvider, + private historyRef: HistoryRef = { current: [] } + ) {} private buildSelector(labels: Label[]): string { const allLabelTexts = labels.map( diff --git a/public/app/plugins/datasource/mysql/sqlCompletionProvider.ts b/public/app/plugins/datasource/mysql/sqlCompletionProvider.ts index 18446a98df7..b44b2475027 100644 --- a/public/app/plugins/datasource/mysql/sqlCompletionProvider.ts +++ b/public/app/plugins/datasource/mysql/sqlCompletionProvider.ts @@ -53,48 +53,47 @@ export const customStatementPlacementProvider: StatementPlacementProvider = () = ]; export const customSuggestionKinds: (getMeta: CompletionProviderGetterArgs['getMeta']) => SuggestionKindProvider = - (getMeta) => () => - [ - { - id: SuggestionKind.Tables, - overrideDefault: true, - suggestionsResolver: async (ctx) => { - const databaseName = getDatabaseName(ctx.currentToken); + (getMeta) => () => [ + { + id: SuggestionKind.Tables, + overrideDefault: true, + suggestionsResolver: async (ctx) => { + const databaseName = getDatabaseName(ctx.currentToken); - const suggestions = await getMeta({ schema: databaseName }); + const suggestions = await getMeta({ schema: databaseName }); - return suggestions.map(mapToSuggestion(ctx)); - }, + return suggestions.map(mapToSuggestion(ctx)); }, - { - id: SuggestionKind.Columns, - overrideDefault: true, - suggestionsResolver: async (ctx) => { - const databaseToken = getDatabaseToken(ctx.currentToken); - const databaseName = getDatabaseName(databaseToken); - const tableName = getTableName(databaseToken); + }, + { + id: SuggestionKind.Columns, + overrideDefault: true, + suggestionsResolver: async (ctx) => { + const databaseToken = getDatabaseToken(ctx.currentToken); + const databaseName = getDatabaseName(databaseToken); + const tableName = getTableName(databaseToken); - if (!databaseName || !tableName) { - return []; - } + if (!databaseName || !tableName) { + return []; + } - const suggestions = await getMeta({ schema: databaseName, table: tableName }); + const suggestions = await getMeta({ schema: databaseName, table: tableName }); - return suggestions.map(mapToSuggestion(ctx)); - }, + return suggestions.map(mapToSuggestion(ctx)); }, - { - id: customSuggestionKind.tablesWithinDatabase, - applyTo: [customStatementPlacement.afterDatabase], - suggestionsResolver: async (ctx) => { - const databaseName = getDatabaseName(ctx.currentToken); + }, + { + id: customSuggestionKind.tablesWithinDatabase, + applyTo: [customStatementPlacement.afterDatabase], + suggestionsResolver: async (ctx) => { + const databaseName = getDatabaseName(ctx.currentToken); - const suggestions = await getMeta({ schema: databaseName }); + const suggestions = await getMeta({ schema: databaseName }); - return suggestions.map(mapToSuggestion(ctx)); - }, + return suggestions.map(mapToSuggestion(ctx)); }, - ]; + }, + ]; function mapToSuggestion(ctx: PositionContext) { return function (tableDefinition: TableDefinition) { diff --git a/public/app/plugins/datasource/opentsdb/datasource.ts b/public/app/plugins/datasource/opentsdb/datasource.ts index 48048b17408..da0ea1ae059 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.ts +++ b/public/app/plugins/datasource/opentsdb/datasource.ts @@ -46,7 +46,10 @@ export default class OpenTsDatasource extends DataSourceApi { - acc[def.sign] = { - id: def.id, - comparison: def.comparison, - }; - return acc; -}, {} as Record); +export const binaryScalarOperatorToOperatorName = binaryScalarDefs.reduce( + (acc, def) => { + acc[def.sign] = { + id: def.id, + comparison: def.comparison, + }; + return acc; + }, + {} as Record +); // Not sure about this one. It could also be a more generic 'Simple math operation' where user specifies // both the operator and the operand in a single input diff --git a/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx b/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx index 8bf5e694ced..cdc90d0ec48 100644 --- a/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx +++ b/public/app/plugins/datasource/prometheus/querybuilder/components/LabelFilters.tsx @@ -85,11 +85,9 @@ export function LabelFilters({ {variableEditor ? (
({ subscribe: jest.fn(), - } as any), + }) as any, publish: jest.fn(), removeAllListeners: jest.fn(), newScopedBus: jest.fn(), diff --git a/public/app/plugins/panel/barchart/quadtree.ts b/public/app/plugins/panel/barchart/quadtree.ts index 10e813f63e0..30446cacf31 100644 --- a/public/app/plugins/panel/barchart/quadtree.ts +++ b/public/app/plugins/panel/barchart/quadtree.ts @@ -50,7 +50,13 @@ export class Quadtree { o: Rect[]; q: Quads | null; - constructor(public x: number, public y: number, public w: number, public h: number, public l: number = 0) { + constructor( + public x: number, + public y: number, + public w: number, + public h: number, + public l: number = 0 + ) { this.o = []; this.q = null; } diff --git a/public/app/plugins/panel/table-old/editor.ts b/public/app/plugins/panel/table-old/editor.ts index b26f578a852..e6cb416ee54 100644 --- a/public/app/plugins/panel/table-old/editor.ts +++ b/public/app/plugins/panel/table-old/editor.ts @@ -15,7 +15,10 @@ export class TablePanelEditorCtrl { static $inject = ['$scope', 'uiSegmentSrv']; - constructor($scope: any, private uiSegmentSrv: any) { + constructor( + $scope: any, + private uiSegmentSrv: any + ) { $scope.editor = this; this.panelCtrl = $scope.ctrl; this.panel = this.panelCtrl.panel; diff --git a/public/app/plugins/panel/table-old/module.ts b/public/app/plugins/panel/table-old/module.ts index 1836c6cd5cd..71bf0cf2db3 100644 --- a/public/app/plugins/panel/table-old/module.ts +++ b/public/app/plugins/panel/table-old/module.ts @@ -56,7 +56,12 @@ export class TablePanelCtrl extends MetricsPanelCtrl { static $inject = ['$scope', '$injector', 'annotationsSrv', '$sanitize']; - constructor($scope: any, $injector: any, private annotationsSrv: any, private $sanitize: any) { + constructor( + $scope: any, + $injector: any, + private annotationsSrv: any, + private $sanitize: any + ) { super($scope, $injector); this.pageIndex = 0; diff --git a/public/app/plugins/panel/timeseries/plugins/annotations/AnnotationTooltip.tsx b/public/app/plugins/panel/timeseries/plugins/annotations/AnnotationTooltip.tsx index fca158f2e4a..8de6863218a 100644 --- a/public/app/plugins/panel/timeseries/plugins/annotations/AnnotationTooltip.tsx +++ b/public/app/plugins/panel/timeseries/plugins/annotations/AnnotationTooltip.tsx @@ -82,9 +82,7 @@ export const AnnotationTooltip = ({ {alertText} <> - {tags?.map((t, i) => ( - - ))} + {tags?.map((t, i) => )}
diff --git a/public/sass/base/_grafana_icons.scss b/public/sass/base/_grafana_icons.scss index 40fc44da405..cfb55f8464d 100644 --- a/public/sass/base/_grafana_icons.scss +++ b/public/sass/base/_grafana_icons.scss @@ -1,7 +1,8 @@ @font-face { font-family: 'grafana-icons'; src: url('../fonts/grafana-icons.eot?okx5td'); - src: url('../fonts/grafana-icons.eot?okx5td#iefix') format('embedded-opentype'), + src: + url('../fonts/grafana-icons.eot?okx5td#iefix') format('embedded-opentype'), url('../fonts/grafana-icons.ttf?okx5td') format('truetype'), url('../fonts/grafana-icons.woff?okx5td') format('woff'), url('../fonts/grafana-icons.svg?okx5td#grafana-icons') format('svg'); diff --git a/public/sass/base/font-awesome/_path.scss b/public/sass/base/font-awesome/_path.scss index d452de2170a..5c84b7bb940 100644 --- a/public/sass/base/font-awesome/_path.scss +++ b/public/sass/base/font-awesome/_path.scss @@ -4,7 +4,8 @@ @font-face { font-family: 'FontAwesome'; src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); - src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), + src: + url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), diff --git a/public/sass/components/_scrollbar.scss b/public/sass/components/_scrollbar.scss index 281423c8a2d..ee242a0d9aa 100644 --- a/public/sass/components/_scrollbar.scss +++ b/public/sass/components/_scrollbar.scss @@ -20,8 +20,12 @@ .ps__rail-x { display: none; opacity: 0; - transition: background-color 0.2s linear, opacity 0.2s linear; - -webkit-transition: background-color 0.2s linear, opacity 0.2s linear; + transition: + background-color 0.2s linear, + opacity 0.2s linear; + -webkit-transition: + background-color 0.2s linear, + opacity 0.2s linear; height: 15px; /* there must be 'bottom' or 'top' for ps__rail-x */ bottom: 0px; @@ -32,8 +36,12 @@ .ps__rail-y { display: none; opacity: 0; - transition: background-color 0.2s linear, opacity 0.2s linear; - -webkit-transition: background-color 0.2s linear, opacity 0.2s linear; + transition: + background-color 0.2s linear, + opacity 0.2s linear; + -webkit-transition: + background-color 0.2s linear, + opacity 0.2s linear; width: 15px; /* there must be 'right' or 'left' for ps__rail-y */ right: 0; @@ -242,7 +250,9 @@ // height: 15px; width: 15px; - transition: background-color 0.2s linear, opacity 0.2s linear; + transition: + background-color 0.2s linear, + opacity 0.2s linear; opacity: 0; } diff --git a/public/sass/components/_slate_editor.scss b/public/sass/components/_slate_editor.scss index 67647f6f8b8..bd596c4542a 100644 --- a/public/sass/components/_slate_editor.scss +++ b/public/sass/components/_slate_editor.scss @@ -61,8 +61,11 @@ display: block; white-space: nowrap; cursor: pointer; - transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), - background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1); + transition: + color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), + padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1); } .typeahead-item__selected { diff --git a/public/sass/components/_tagsinput.scss b/public/sass/components/_tagsinput.scss index 8d9d3255bd4..44a7109196c 100644 --- a/public/sass/components/_tagsinput.scss +++ b/public/sass/components/_tagsinput.scss @@ -36,7 +36,9 @@ } &:hover { - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: + inset 0 1px 0 rgba(255, 255, 255, 0.2), + 0 1px 2px rgba(0, 0, 0, 0.05); &:active { box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); diff --git a/public/test/matchers/utils.ts b/public/test/matchers/utils.ts index 26776b1fb1f..e7758bb9177 100644 --- a/public/test/matchers/utils.ts +++ b/public/test/matchers/utils.ts @@ -15,8 +15,8 @@ export function forceObservableCompletion(subscription: Subscription, resolve: ( `${matcherHint('.toEmitValues')} Expected ${printReceived('Observable')} to be ${printExpected( - `completed within ${OBSERVABLE_TEST_TIMEOUT_IN_MS}ms` - )} but it did not.`, + `completed within ${OBSERVABLE_TEST_TIMEOUT_IN_MS}ms` + )} but it did not.`, }); }) ); diff --git a/public/test/mocks/datasource_srv.ts b/public/test/mocks/datasource_srv.ts index 3f68dded950..9da05b83ac2 100644 --- a/public/test/mocks/datasource_srv.ts +++ b/public/test/mocks/datasource_srv.ts @@ -12,7 +12,10 @@ import { } from '@grafana/data'; export class DatasourceSrvMock { - constructor(private defaultDS: DataSourceApi, private datasources: { [name: string]: DataSourceApi }) { + constructor( + private defaultDS: DataSourceApi, + private datasources: { [name: string]: DataSourceApi } + ) { // } diff --git a/yarn.lock b/yarn.lock index 7805d1d30d4..ed13b39dae5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19502,7 +19502,7 @@ __metadata: postcss-loader: 7.3.3 postcss-reporter: 7.0.5 postcss-scss: 4.0.6 - prettier: 2.8.4 + prettier: 3.0.0 prismjs: 1.29.0 prop-types: 15.8.1 pseudoizer: ^0.1.0 @@ -19594,6 +19594,9 @@ __metadata: whatwg-fetch: 3.6.2 xlsx: "https://cdn.sheetjs.com/xlsx-0.19.1/xlsx-0.19.1.tgz" yargs: ^17.5.1 + dependenciesMeta: + prettier@3.0.0: + unplugged: true languageName: unknown linkType: soft @@ -26332,12 +26335,12 @@ __metadata: languageName: node linkType: hard -"prettier@npm:2.8.4": - version: 2.8.4 - resolution: "prettier@npm:2.8.4" +"prettier@npm:3.0.0": + version: 3.0.0 + resolution: "prettier@npm:3.0.0" bin: - prettier: bin-prettier.js - checksum: c173064bf3df57b6d93d19aa98753b9b9dd7657212e33b41ada8e2e9f9884066bb9ca0b4005b89b3ab137efffdf8fbe0b462785aba20364798ff4303aadda57e + prettier: bin/prettier.cjs + checksum: 6a832876a1552dc58330d2467874e5a0b46b9ccbfc5d3531eb69d15684743e7f83dc9fbd202db6270446deba9c82b79d24383d09924c462b457136a759425e33 languageName: node linkType: hard