grafana/data: Gardening 👨‍🌾✂️🌳 (#83615)

* remove suspected unused dependencies from grafana/data

* un-export funcs and types

* re-export NoopTransformerOptions

* remove knip
This commit is contained in:
Will Browne 2024-02-29 15:53:09 +01:00 committed by GitHub
parent e26cd8614d
commit 549094d27c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 46 additions and 79 deletions

View File

@ -53,7 +53,6 @@
"ol": "7.4.0",
"papaparse": "5.4.1",
"react-use": "17.5.0",
"regenerator-runtime": "0.14.1",
"rxjs": "7.8.1",
"string-hash": "^1.1.3",
"tinycolor2": "1.6.0",
@ -63,29 +62,19 @@
},
"devDependencies": {
"@grafana/tsconfig": "^1.3.0-rc1",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@testing-library/dom": "9.3.4",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.1",
"@testing-library/user-event": "14.5.2",
"@types/dompurify": "^3.0.0",
"@types/history": "4.7.11",
"@types/jest": "29.5.12",
"@types/jquery": "3.5.29",
"@types/lodash": "4.14.202",
"@types/marked": "5.0.2",
"@types/node": "20.11.20",
"@types/papaparse": "5.3.14",
"@types/react": "18.2.60",
"@types/react-dom": "18.2.19",
"@types/testing-library__jest-dom": "5.14.9",
"@types/tinycolor2": "1.4.6",
"esbuild": "0.18.12",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"rimraf": "5.0.5",
"rollup": "2.79.1",
"rollup-plugin-dts": "^5.0.0",

View File

@ -1,7 +1,5 @@
import { useContext } from 'react';
import { PluginMeta } from '../../types';
import { Context, PluginContextType } from './PluginContext';
export function usePluginContext(): PluginContextType {
@ -11,21 +9,3 @@ export function usePluginContext(): PluginContextType {
}
return context;
}
export function usePluginMeta(): PluginMeta {
const context = usePluginContext();
return context.meta;
}
export function usePluginJsonData() {
const context = usePluginContext();
return context.meta.jsonData;
}
export function usePluginVersion() {
const context = usePluginContext();
return context.meta.info.version;
}

View File

@ -5,7 +5,6 @@ import { Field, FieldType } from '../types/dataFrame';
type IndexComparer = (a: number, b: number) => number;
/** @public */
export const fieldIndexComparer = (field: Field, reverse = false): IndexComparer => {
const values = field.values;
@ -26,8 +25,7 @@ export const fieldIndexComparer = (field: Field, reverse = false): IndexComparer
}
};
/** @public */
export const timeComparer = (a: unknown, b: unknown): number => {
const timeComparer = (a: unknown, b: unknown): number => {
if (!a || !b) {
return falsyComparer(a, b);
}
@ -49,20 +47,18 @@ export const timeComparer = (a: unknown, b: unknown): number => {
return 0;
};
/** @public */
export const numericComparer = (a: number, b: number): number => {
const numericComparer = (a: number, b: number): number => {
return a - b;
};
/** @public */
export const stringComparer = (a: string, b: string): number => {
const stringComparer = (a: string, b: string): number => {
if (!a || !b) {
return falsyComparer(a, b);
}
return a.localeCompare(b);
};
export const booleanComparer = (a: boolean, b: boolean): number => {
const booleanComparer = (a: boolean, b: boolean): number => {
return falsyComparer(a, b);
};

View File

@ -14,7 +14,7 @@ import { ThresholdsConfig, ThresholdsMode } from '../types/thresholds';
import { PanelPlugin } from './PanelPlugin';
export interface Props {
interface Props {
plugin: PanelPlugin;
currentFieldConfig: FieldConfigSource;
currentOptions: Record<string, unknown>;

View File

@ -184,11 +184,11 @@ export const alwaysFieldMatcher = (field: Field) => {
return true;
};
export const alwaysFrameMatcher = (frame: DataFrame) => {
const alwaysFrameMatcher = (frame: DataFrame) => {
return true;
};
export const neverFieldMatcher = (field: Field) => {
const neverFieldMatcher = (field: Field) => {
return false;
};
@ -196,7 +196,7 @@ export const notTimeFieldMatcher = (field: Field) => {
return field.type !== FieldType.time;
};
export const neverFrameMatcher = (frame: DataFrame) => {
const neverFrameMatcher = (frame: DataFrame) => {
return false;
};

View File

@ -61,7 +61,7 @@ export interface BinaryOptions {
right: string;
}
export interface IndexOptions {
interface IndexOptions {
asPercentile: boolean;
}

View File

@ -11,7 +11,7 @@ import { DataTransformerID } from './ids';
export const SHOW_NESTED_HEADERS_DEFAULT = true;
export enum GroupByOperationID {
enum GroupByOperationID {
aggregate = 'aggregate',
groupBy = 'groupby',
}

View File

@ -64,7 +64,7 @@ export const reduceTransformer: DataTransformerInfo<ReduceTransformerOptions> =
/**
* @internal only exported for testing
*/
export function reduceSeriesToRows(
function reduceSeriesToRows(
data: DataFrame[],
matcher: FieldMatcher,
reducerId: ReducerID[],
@ -156,7 +156,7 @@ export function reduceSeriesToRows(
return mergeResults(processed);
}
export function getDistinctLabelKeys(frames: DataFrame[]): string[] {
function getDistinctLabelKeys(frames: DataFrame[]): string[] {
const keys = new Set<string>();
for (const frame of frames) {
for (const field of frame.fields) {
@ -173,7 +173,7 @@ export function getDistinctLabelKeys(frames: DataFrame[]): string[] {
/**
* @internal only exported for testing
*/
export function mergeResults(data: DataFrame[]): DataFrame | undefined {
function mergeResults(data: DataFrame[]): DataFrame | undefined {
if (!data?.length) {
return undefined;
}

View File

@ -43,7 +43,7 @@ export const sortByTransformer: DataTransformerInfo<SortByTransformerOptions> =
),
};
export function sortDataFrames(data: DataFrame[], sort: SortByField[], ctx: DataTransformContext): DataFrame[] {
function sortDataFrames(data: DataFrame[], sort: SortByField[], ctx: DataTransformContext): DataFrame[] {
return data.map((frame) => {
const s = attachFieldIndex(frame, sort, ctx);
if (s.length && s[0].index != null) {

View File

@ -30,7 +30,7 @@ export interface OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>
/**
* Describes an API for option editors UI builder
*/
export interface OptionsUIRegistryBuilderAPI<
interface OptionsUIRegistryBuilderAPI<
TOptions,
TEditorProps,
T extends OptionsEditorItem<TOptions, any, TEditorProps, any>,

View File

@ -102,13 +102,6 @@ export function toMilliSeconds(size: number, decimals?: DecimalCount, scaledDeci
return toFixedScaled(size / 31536000000, decimals, ' year');
}
export function trySubstract(value1: DecimalCount, value2: DecimalCount): DecimalCount {
if (value1 !== null && value1 !== undefined && value2 !== null && value2 !== undefined) {
return value1 - value2;
}
return undefined;
}
export function toSeconds(size: number, decimals?: DecimalCount): FormattedValue {
if (size === null) {
return { text: '' };

View File

@ -3536,18 +3536,10 @@ __metadata:
"@braintree/sanitize-url": "npm:7.0.0"
"@grafana/schema": "npm:11.0.0-pre"
"@grafana/tsconfig": "npm:^1.3.0-rc1"
"@rollup/plugin-commonjs": "npm:25.0.7"
"@rollup/plugin-json": "npm:6.1.0"
"@rollup/plugin-node-resolve": "npm:15.2.3"
"@testing-library/dom": "npm:9.3.4"
"@testing-library/jest-dom": "npm:6.4.2"
"@testing-library/react": "npm:14.2.1"
"@testing-library/user-event": "npm:14.5.2"
"@types/d3-interpolate": "npm:^3.0.0"
"@types/dompurify": "npm:^3.0.0"
"@types/history": "npm:4.7.11"
"@types/jest": "npm:29.5.12"
"@types/jquery": "npm:3.5.29"
"@types/lodash": "npm:4.14.202"
"@types/marked": "npm:5.0.2"
"@types/node": "npm:20.11.20"
@ -3555,7 +3547,6 @@ __metadata:
"@types/react": "npm:18.2.60"
"@types/react-dom": "npm:18.2.19"
"@types/string-hash": "npm:1.1.3"
"@types/testing-library__jest-dom": "npm:5.14.9"
"@types/tinycolor2": "npm:1.4.6"
d3-interpolate: "npm:3.0.1"
date-fns: "npm:3.3.1"
@ -3573,9 +3564,7 @@ __metadata:
papaparse: "npm:5.4.1"
react: "npm:18.2.0"
react-dom: "npm:18.2.0"
react-test-renderer: "npm:18.2.0"
react-use: "npm:17.5.0"
regenerator-runtime: "npm:0.14.1"
rimraf: "npm:5.0.5"
rollup: "npm:2.79.1"
rollup-plugin-dts: "npm:^5.0.0"
@ -9215,7 +9204,7 @@ __metadata:
languageName: node
linkType: hard
"@types/eslint@npm:*, @types/eslint@npm:8.56.3, @types/eslint@npm:^8.37.0, @types/eslint@npm:^8.4.10":
"@types/eslint@npm:*, @types/eslint@npm:8.56.3, @types/eslint@npm:^8.37.0":
version: 8.56.3
resolution: "@types/eslint@npm:8.56.3"
dependencies:
@ -9225,6 +9214,16 @@ __metadata:
languageName: node
linkType: hard
"@types/eslint@npm:^8.4.10":
version: 8.56.4
resolution: "@types/eslint@npm:8.56.4"
dependencies:
"@types/estree": "npm:*"
"@types/json-schema": "npm:*"
checksum: 10/bb8018f0c27839dd0b8c515ac4e6fac39500c36ba20007a6ecca2fe5e5f81cbecca2be8f6f649bdafd5556b8c6d5285d8506ae61cc8570f71fd4e6b07042f641
languageName: node
linkType: hard
"@types/estree@npm:*, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5":
version: 1.0.5
resolution: "@types/estree@npm:1.0.5"
@ -10213,11 +10212,11 @@ __metadata:
linkType: hard
"@types/yargs@npm:^15.0.0":
version: 15.0.14
resolution: "@types/yargs@npm:15.0.14"
version: 15.0.19
resolution: "@types/yargs@npm:15.0.19"
dependencies:
"@types/yargs-parser": "npm:*"
checksum: 10/1687ce075a7d01af3c2d342b4f2a2267e06dad6b5eb3fa36643763bd05ca8e6fdfc4dad3d0cb32fc6f3216fd84c0ad2a8032da9190435d033aa800917e8d845c
checksum: 10/c3abcd3472c32c02702f365dc1702a0728562deb8a8c61f3ce2161958d756cc033f7d78567565b4eba62f5869e9b5eac93d4c1dcb2c97af17aafda8f9f892b4b
languageName: node
linkType: hard
@ -15659,7 +15658,17 @@ __metadata:
languageName: node
linkType: hard
"enhanced-resolve@npm:^5.10.0, enhanced-resolve@npm:^5.15.0":
"enhanced-resolve@npm:^5.10.0":
version: 5.15.1
resolution: "enhanced-resolve@npm:5.15.1"
dependencies:
graceful-fs: "npm:^4.2.4"
tapable: "npm:^2.2.0"
checksum: 10/9d4badf18c515f7607539e61d7b78f3057ba2f17b97d188c5ef9bcbc26fa6d25b66f0007d39a3a3c3c2a83b53bedbdb6ce82250c57b85470b6b73004d78989be
languageName: node
linkType: hard
"enhanced-resolve@npm:^5.15.0":
version: 5.15.0
resolution: "enhanced-resolve@npm:5.15.0"
dependencies:
@ -17036,7 +17045,7 @@ __metadata:
languageName: node
linkType: hard
"fast-glob@npm:^3.0.3, fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.2":
"fast-glob@npm:^3.0.3, fast-glob@npm:^3.2.11, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0, fast-glob@npm:^3.3.2":
version: 3.3.2
resolution: "fast-glob@npm:3.3.2"
dependencies:
@ -18253,15 +18262,15 @@ __metadata:
linkType: hard
"globby@npm:^13.1.1":
version: 13.1.3
resolution: "globby@npm:13.1.3"
version: 13.2.2
resolution: "globby@npm:13.2.2"
dependencies:
dir-glob: "npm:^3.0.1"
fast-glob: "npm:^3.2.11"
ignore: "npm:^5.2.0"
fast-glob: "npm:^3.3.0"
ignore: "npm:^5.2.4"
merge2: "npm:^1.4.1"
slash: "npm:^4.0.0"
checksum: 10/c5eee00704455c283b3e466b63d906bcd32a64bbe2d00792016cf518cc1a247433ba8cae4ebe6076075a4b14d6fd07f8a9587083d59bfa85e3c4fab9fffa4d91
checksum: 10/4494a9d2162a7e4d327988b26be66d8eab87d7f59a83219e74b065e2c3ced23698f68fb10482bf9337133819281803fb886d6ae06afbb2affa743623eb0b1949
languageName: node
linkType: hard