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", "ol": "7.4.0",
"papaparse": "5.4.1", "papaparse": "5.4.1",
"react-use": "17.5.0", "react-use": "17.5.0",
"regenerator-runtime": "0.14.1",
"rxjs": "7.8.1", "rxjs": "7.8.1",
"string-hash": "^1.1.3", "string-hash": "^1.1.3",
"tinycolor2": "1.6.0", "tinycolor2": "1.6.0",
@ -63,29 +62,19 @@
}, },
"devDependencies": { "devDependencies": {
"@grafana/tsconfig": "^1.3.0-rc1", "@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", "@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/dompurify": "^3.0.0",
"@types/history": "4.7.11", "@types/history": "4.7.11",
"@types/jest": "29.5.12",
"@types/jquery": "3.5.29",
"@types/lodash": "4.14.202", "@types/lodash": "4.14.202",
"@types/marked": "5.0.2", "@types/marked": "5.0.2",
"@types/node": "20.11.20", "@types/node": "20.11.20",
"@types/papaparse": "5.3.14", "@types/papaparse": "5.3.14",
"@types/react": "18.2.60", "@types/react": "18.2.60",
"@types/react-dom": "18.2.19", "@types/react-dom": "18.2.19",
"@types/testing-library__jest-dom": "5.14.9",
"@types/tinycolor2": "1.4.6", "@types/tinycolor2": "1.4.6",
"esbuild": "0.18.12", "esbuild": "0.18.12",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"rimraf": "5.0.5", "rimraf": "5.0.5",
"rollup": "2.79.1", "rollup": "2.79.1",
"rollup-plugin-dts": "^5.0.0", "rollup-plugin-dts": "^5.0.0",

View File

@ -1,7 +1,5 @@
import { useContext } from 'react'; import { useContext } from 'react';
import { PluginMeta } from '../../types';
import { Context, PluginContextType } from './PluginContext'; import { Context, PluginContextType } from './PluginContext';
export function usePluginContext(): PluginContextType { export function usePluginContext(): PluginContextType {
@ -11,21 +9,3 @@ export function usePluginContext(): PluginContextType {
} }
return context; 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; type IndexComparer = (a: number, b: number) => number;
/** @public */
export const fieldIndexComparer = (field: Field, reverse = false): IndexComparer => { export const fieldIndexComparer = (field: Field, reverse = false): IndexComparer => {
const values = field.values; const values = field.values;
@ -26,8 +25,7 @@ export const fieldIndexComparer = (field: Field, reverse = false): IndexComparer
} }
}; };
/** @public */ const timeComparer = (a: unknown, b: unknown): number => {
export const timeComparer = (a: unknown, b: unknown): number => {
if (!a || !b) { if (!a || !b) {
return falsyComparer(a, b); return falsyComparer(a, b);
} }
@ -49,20 +47,18 @@ export const timeComparer = (a: unknown, b: unknown): number => {
return 0; return 0;
}; };
/** @public */ const numericComparer = (a: number, b: number): number => {
export const numericComparer = (a: number, b: number): number => {
return a - b; return a - b;
}; };
/** @public */ const stringComparer = (a: string, b: string): number => {
export const stringComparer = (a: string, b: string): number => {
if (!a || !b) { if (!a || !b) {
return falsyComparer(a, b); return falsyComparer(a, b);
} }
return a.localeCompare(b); return a.localeCompare(b);
}; };
export const booleanComparer = (a: boolean, b: boolean): number => { const booleanComparer = (a: boolean, b: boolean): number => {
return falsyComparer(a, b); return falsyComparer(a, b);
}; };

View File

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

View File

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

View File

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

View File

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

View File

@ -64,7 +64,7 @@ export const reduceTransformer: DataTransformerInfo<ReduceTransformerOptions> =
/** /**
* @internal only exported for testing * @internal only exported for testing
*/ */
export function reduceSeriesToRows( function reduceSeriesToRows(
data: DataFrame[], data: DataFrame[],
matcher: FieldMatcher, matcher: FieldMatcher,
reducerId: ReducerID[], reducerId: ReducerID[],
@ -156,7 +156,7 @@ export function reduceSeriesToRows(
return mergeResults(processed); return mergeResults(processed);
} }
export function getDistinctLabelKeys(frames: DataFrame[]): string[] { function getDistinctLabelKeys(frames: DataFrame[]): string[] {
const keys = new Set<string>(); const keys = new Set<string>();
for (const frame of frames) { for (const frame of frames) {
for (const field of frame.fields) { for (const field of frame.fields) {
@ -173,7 +173,7 @@ export function getDistinctLabelKeys(frames: DataFrame[]): string[] {
/** /**
* @internal only exported for testing * @internal only exported for testing
*/ */
export function mergeResults(data: DataFrame[]): DataFrame | undefined { function mergeResults(data: DataFrame[]): DataFrame | undefined {
if (!data?.length) { if (!data?.length) {
return undefined; 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) => { return data.map((frame) => {
const s = attachFieldIndex(frame, sort, ctx); const s = attachFieldIndex(frame, sort, ctx);
if (s.length && s[0].index != null) { 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 * Describes an API for option editors UI builder
*/ */
export interface OptionsUIRegistryBuilderAPI< interface OptionsUIRegistryBuilderAPI<
TOptions, TOptions,
TEditorProps, TEditorProps,
T extends OptionsEditorItem<TOptions, any, TEditorProps, any>, 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'); 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 { export function toSeconds(size: number, decimals?: DecimalCount): FormattedValue {
if (size === null) { if (size === null) {
return { text: '' }; return { text: '' };

View File

@ -3536,18 +3536,10 @@ __metadata:
"@braintree/sanitize-url": "npm:7.0.0" "@braintree/sanitize-url": "npm:7.0.0"
"@grafana/schema": "npm:11.0.0-pre" "@grafana/schema": "npm:11.0.0-pre"
"@grafana/tsconfig": "npm:^1.3.0-rc1" "@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" "@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/d3-interpolate": "npm:^3.0.0"
"@types/dompurify": "npm:^3.0.0" "@types/dompurify": "npm:^3.0.0"
"@types/history": "npm:4.7.11" "@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/lodash": "npm:4.14.202"
"@types/marked": "npm:5.0.2" "@types/marked": "npm:5.0.2"
"@types/node": "npm:20.11.20" "@types/node": "npm:20.11.20"
@ -3555,7 +3547,6 @@ __metadata:
"@types/react": "npm:18.2.60" "@types/react": "npm:18.2.60"
"@types/react-dom": "npm:18.2.19" "@types/react-dom": "npm:18.2.19"
"@types/string-hash": "npm:1.1.3" "@types/string-hash": "npm:1.1.3"
"@types/testing-library__jest-dom": "npm:5.14.9"
"@types/tinycolor2": "npm:1.4.6" "@types/tinycolor2": "npm:1.4.6"
d3-interpolate: "npm:3.0.1" d3-interpolate: "npm:3.0.1"
date-fns: "npm:3.3.1" date-fns: "npm:3.3.1"
@ -3573,9 +3564,7 @@ __metadata:
papaparse: "npm:5.4.1" papaparse: "npm:5.4.1"
react: "npm:18.2.0" react: "npm:18.2.0"
react-dom: "npm:18.2.0" react-dom: "npm:18.2.0"
react-test-renderer: "npm:18.2.0"
react-use: "npm:17.5.0" react-use: "npm:17.5.0"
regenerator-runtime: "npm:0.14.1"
rimraf: "npm:5.0.5" rimraf: "npm:5.0.5"
rollup: "npm:2.79.1" rollup: "npm:2.79.1"
rollup-plugin-dts: "npm:^5.0.0" rollup-plugin-dts: "npm:^5.0.0"
@ -9215,7 +9204,7 @@ __metadata:
languageName: node languageName: node
linkType: hard 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 version: 8.56.3
resolution: "@types/eslint@npm:8.56.3" resolution: "@types/eslint@npm:8.56.3"
dependencies: dependencies:
@ -9225,6 +9214,16 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@types/estree@npm:*, @types/estree@npm:^1.0.0, @types/estree@npm:^1.0.5":
version: 1.0.5 version: 1.0.5
resolution: "@types/estree@npm:1.0.5" resolution: "@types/estree@npm:1.0.5"
@ -10213,11 +10212,11 @@ __metadata:
linkType: hard linkType: hard
"@types/yargs@npm:^15.0.0": "@types/yargs@npm:^15.0.0":
version: 15.0.14 version: 15.0.19
resolution: "@types/yargs@npm:15.0.14" resolution: "@types/yargs@npm:15.0.19"
dependencies: dependencies:
"@types/yargs-parser": "npm:*" "@types/yargs-parser": "npm:*"
checksum: 10/1687ce075a7d01af3c2d342b4f2a2267e06dad6b5eb3fa36643763bd05ca8e6fdfc4dad3d0cb32fc6f3216fd84c0ad2a8032da9190435d033aa800917e8d845c checksum: 10/c3abcd3472c32c02702f365dc1702a0728562deb8a8c61f3ce2161958d756cc033f7d78567565b4eba62f5869e9b5eac93d4c1dcb2c97af17aafda8f9f892b4b
languageName: node languageName: node
linkType: hard linkType: hard
@ -15659,7 +15658,17 @@ __metadata:
languageName: node languageName: node
linkType: hard 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 version: 5.15.0
resolution: "enhanced-resolve@npm:5.15.0" resolution: "enhanced-resolve@npm:5.15.0"
dependencies: dependencies:
@ -17036,7 +17045,7 @@ __metadata:
languageName: node languageName: node
linkType: hard 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 version: 3.3.2
resolution: "fast-glob@npm:3.3.2" resolution: "fast-glob@npm:3.3.2"
dependencies: dependencies:
@ -18253,15 +18262,15 @@ __metadata:
linkType: hard linkType: hard
"globby@npm:^13.1.1": "globby@npm:^13.1.1":
version: 13.1.3 version: 13.2.2
resolution: "globby@npm:13.1.3" resolution: "globby@npm:13.2.2"
dependencies: dependencies:
dir-glob: "npm:^3.0.1" dir-glob: "npm:^3.0.1"
fast-glob: "npm:^3.2.11" fast-glob: "npm:^3.3.0"
ignore: "npm:^5.2.0" ignore: "npm:^5.2.4"
merge2: "npm:^1.4.1" merge2: "npm:^1.4.1"
slash: "npm:^4.0.0" slash: "npm:^4.0.0"
checksum: 10/c5eee00704455c283b3e466b63d906bcd32a64bbe2d00792016cf518cc1a247433ba8cae4ebe6076075a4b14d6fd07f8a9587083d59bfa85e3c4fab9fffa4d91 checksum: 10/4494a9d2162a7e4d327988b26be66d8eab87d7f59a83219e74b065e2c3ced23698f68fb10482bf9337133819281803fb886d6ae06afbb2affa743623eb0b1949
languageName: node languageName: node
linkType: hard linkType: hard