From 549094d27ce955bac0ccdefd2ff1e8ade6416617 Mon Sep 17 00:00:00 2001 From: Will Browne Date: Thu, 29 Feb 2024 15:53:09 +0100 Subject: [PATCH] =?UTF-8?q?grafana/data:=20Gardening=20=F0=9F=91=A8?= =?UTF-8?q?=E2=80=8D=F0=9F=8C=BE=E2=9C=82=EF=B8=8F=F0=9F=8C=B3=20(#83615)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove suspected unused dependencies from grafana/data * un-export funcs and types * re-export NoopTransformerOptions * remove knip --- packages/grafana-data/package.json | 11 ---- .../src/context/plugins/usePluginContext.tsx | 20 ------- .../grafana-data/src/field/fieldComparers.ts | 12 ++--- .../src/panel/getPanelOptionsWithDefaults.ts | 2 +- .../transformations/matchers/predicates.ts | 6 +-- .../transformers/calculateField.ts | 2 +- .../transformers/groupToNestedTable.ts | 2 +- .../transformations/transformers/reduce.ts | 6 +-- .../transformations/transformers/sortBy.ts | 2 +- .../src/types/OptionsUIRegistryBuilder.ts | 2 +- .../src/valueFormats/dateTimeFormatters.ts | 7 --- yarn.lock | 53 +++++++++++-------- 12 files changed, 46 insertions(+), 79 deletions(-) diff --git a/packages/grafana-data/package.json b/packages/grafana-data/package.json index 740b0375263..8deb7ab7ed8 100644 --- a/packages/grafana-data/package.json +++ b/packages/grafana-data/package.json @@ -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", diff --git a/packages/grafana-data/src/context/plugins/usePluginContext.tsx b/packages/grafana-data/src/context/plugins/usePluginContext.tsx index e2ea1056629..51723446b81 100644 --- a/packages/grafana-data/src/context/plugins/usePluginContext.tsx +++ b/packages/grafana-data/src/context/plugins/usePluginContext.tsx @@ -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; -} diff --git a/packages/grafana-data/src/field/fieldComparers.ts b/packages/grafana-data/src/field/fieldComparers.ts index 972b435cd35..3f525b06405 100644 --- a/packages/grafana-data/src/field/fieldComparers.ts +++ b/packages/grafana-data/src/field/fieldComparers.ts @@ -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); }; diff --git a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts index f3a8d44faf7..3bcdf8883ae 100644 --- a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts +++ b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts @@ -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; diff --git a/packages/grafana-data/src/transformations/matchers/predicates.ts b/packages/grafana-data/src/transformations/matchers/predicates.ts index ef26e05be1e..7939f95aec0 100644 --- a/packages/grafana-data/src/transformations/matchers/predicates.ts +++ b/packages/grafana-data/src/transformations/matchers/predicates.ts @@ -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; }; diff --git a/packages/grafana-data/src/transformations/transformers/calculateField.ts b/packages/grafana-data/src/transformations/transformers/calculateField.ts index e50dc3b268b..b50f1bcac2d 100644 --- a/packages/grafana-data/src/transformations/transformers/calculateField.ts +++ b/packages/grafana-data/src/transformations/transformers/calculateField.ts @@ -61,7 +61,7 @@ export interface BinaryOptions { right: string; } -export interface IndexOptions { +interface IndexOptions { asPercentile: boolean; } diff --git a/packages/grafana-data/src/transformations/transformers/groupToNestedTable.ts b/packages/grafana-data/src/transformations/transformers/groupToNestedTable.ts index 146f86a6e46..aa2d1f9c883 100644 --- a/packages/grafana-data/src/transformations/transformers/groupToNestedTable.ts +++ b/packages/grafana-data/src/transformations/transformers/groupToNestedTable.ts @@ -11,7 +11,7 @@ import { DataTransformerID } from './ids'; export const SHOW_NESTED_HEADERS_DEFAULT = true; -export enum GroupByOperationID { +enum GroupByOperationID { aggregate = 'aggregate', groupBy = 'groupby', } diff --git a/packages/grafana-data/src/transformations/transformers/reduce.ts b/packages/grafana-data/src/transformations/transformers/reduce.ts index f8ba7adddc5..d7e8ba8cda5 100644 --- a/packages/grafana-data/src/transformations/transformers/reduce.ts +++ b/packages/grafana-data/src/transformations/transformers/reduce.ts @@ -64,7 +64,7 @@ export const reduceTransformer: DataTransformerInfo = /** * @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(); 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; } diff --git a/packages/grafana-data/src/transformations/transformers/sortBy.ts b/packages/grafana-data/src/transformations/transformers/sortBy.ts index 7cd99acce36..58315815621 100644 --- a/packages/grafana-data/src/transformations/transformers/sortBy.ts +++ b/packages/grafana-data/src/transformations/transformers/sortBy.ts @@ -43,7 +43,7 @@ export const sortByTransformer: DataTransformerInfo = ), }; -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) { diff --git a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts index 0765f1987a3..b5a0e74f34f 100644 --- a/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts +++ b/packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts @@ -30,7 +30,7 @@ export interface OptionsEditorItem /** * Describes an API for option editors UI builder */ -export interface OptionsUIRegistryBuilderAPI< +interface OptionsUIRegistryBuilderAPI< TOptions, TEditorProps, T extends OptionsEditorItem, diff --git a/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts b/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts index fe230f5023b..4eb18bf8c50 100644 --- a/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts +++ b/packages/grafana-data/src/valueFormats/dateTimeFormatters.ts @@ -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: '' }; diff --git a/yarn.lock b/yarn.lock index d38be2aca6f..a7c80cb6779 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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