From 47f1c5d08406bc97c49987a95688527d85cb6381 Mon Sep 17 00:00:00 2001 From: Andres Martinez Gotor Date: Thu, 20 Jul 2023 09:34:19 +0200 Subject: [PATCH] Chore: Avoid Grafana core imports for the test data source (#71956) --- .eslintrc | 33 +++++++++++++++++++ .../datasource/testdata/QueryEditor.tsx | 14 +++----- .../plugins/datasource/testdata/runStreams.ts | 2 ++ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.eslintrc b/.eslintrc index aa0594784d3..81112897a70 100644 --- a/.eslintrc +++ b/.eslintrc @@ -88,6 +88,39 @@ } ] } + }, + { + "files": [ + "public/app/plugins/datasource/testdata/*.{ts,tsx}", + "public/app/plugins/datasource/testdata/**/*.{ts,tsx}" + ], + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [ + // generic rules + { + "name": "react-redux", + "importNames": ["useDispatch", "useSelector"], + "message": "Please import from app/types instead." + }, + { + "name": "react-i18next", + "importNames": ["Trans", "t"], + "message": "Please import from app/core/internationalization instead" + } + ], + // new rules + "patterns": [ + { + "group": ["**/app/*"], + "message": "Core plugins are not allowed to depend on Grafana core packages" + } + ] + } + ] + } } ] } diff --git a/public/app/plugins/datasource/testdata/QueryEditor.tsx b/public/app/plugins/datasource/testdata/QueryEditor.tsx index ea6eff194e1..f48c330827b 100644 --- a/public/app/plugins/datasource/testdata/QueryEditor.tsx +++ b/public/app/plugins/datasource/testdata/QueryEditor.tsx @@ -4,7 +4,6 @@ import { useAsync } from 'react-use'; import { QueryEditorProps, SelectableValue } from '@grafana/data'; import { selectors as editorSelectors } from '@grafana/e2e-selectors'; import { InlineField, InlineFieldRow, InlineSwitch, Input, Select, Icon, TextArea } from '@grafana/ui'; -import { NumberInput } from 'app/core/components/OptionsUI/NumberInput'; import { RandomWalkEditor, StreamingClientEditor } from './components'; import { CSVContentEditor } from './components/CSVContentEditor'; @@ -166,13 +165,6 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props) onUpdate({ ...query, csvWave }); }; - const onDropPercentChanged = (dropPercent: number | undefined) => { - if (!dropPercent) { - dropPercent = undefined; - } - onChange({ ...query, dropPercent }); - }; - const options = useMemo( () => (scenarioList || []) @@ -234,12 +226,14 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props) )} {show.dropPercent && ( - } diff --git a/public/app/plugins/datasource/testdata/runStreams.ts b/public/app/plugins/datasource/testdata/runStreams.ts index a2b5a533f61..dac0ab22c99 100644 --- a/public/app/plugins/datasource/testdata/runStreams.ts +++ b/public/app/plugins/datasource/testdata/runStreams.ts @@ -12,7 +12,9 @@ import { DataFrameSchema, DataFrameData, } from '@grafana/data'; +// eslint-disable-next-line no-restricted-imports -- In the process from being removed import { liveTimer } from 'app/features/dashboard/dashgrid/liveTimer'; +// eslint-disable-next-line no-restricted-imports -- In the process from being removed import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame'; import { getRandomLine } from './LogIpsum';