Chore: Avoid Grafana core imports for the test data source (#71956)

This commit is contained in:
Andres Martinez Gotor 2023-07-20 09:34:19 +02:00 committed by GitHub
parent 2c82a6b6c4
commit 47f1c5d084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 10 deletions

View File

@ -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"
}
]
}
]
}
}
]
}

View File

@ -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 && (
<InlineField label="Drop" tooltip={'Drop a random set of points'}>
<NumberInput
<Input
type="number"
min={0}
max={100}
step={5}
width={8}
onChange={onDropPercentChanged}
onChange={onInputChange}
name="dropPercent"
placeholder="0"
value={query.dropPercent}
suffix={<Icon name="percentage" />}

View File

@ -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';