fix linting

This commit is contained in:
Nate Kelley 2025-07-23 12:02:54 -06:00
parent 0850e503ab
commit 1dea5d5236
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
46 changed files with 107 additions and 96 deletions

View File

@ -13,5 +13,17 @@
"useKeyWithClickEvents": "off"
}
}
}
},
"overrides": [
{
"include": ["src/components/charts/*"],
"linter": {
"rules": {
"correctness": {
"useExhaustiveDependencies": "off"
}
}
}
}
]
}

View File

@ -12,16 +12,13 @@
"./styles": "./src/styles/styles.css",
"./dist/style.css": "./dist/style.css"
},
"files": [
"dist",
"src/styles/styles.css"
],
"files": ["dist", "src/styles/styles.css"],
"scripts": {
"prebuild": "tsx scripts/validate-env.ts",
"build": "vite build && tsc --emitDeclarationOnly --declaration",
"typecheck": "tsc --noEmit",
"dev": "vite build --watch",
"lint": "biome check",
"lint": "biome check --write",
"test": "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage"

View File

@ -6,6 +6,7 @@ export interface ChartMountedPluginOptions {
}
declare module 'chart.js' {
// biome-ignore lint/correctness/noUnusedVariables: we need to define the plugin options
interface PluginOptionsByType<TType extends ChartType> {
chartMounted?: ChartMountedPluginOptions;
}
@ -18,12 +19,12 @@ declare module 'chart.js' {
export const ChartMountedPlugin: Plugin<ChartType, ChartMountedPluginOptions> = {
id: 'chartMounted',
afterInit: (chart, args, options) => {
afterInit: (chart, _args, options) => {
if (!chart || !options) return;
options?.onMounted?.(chart);
chart.$mountedPlugin = true;
},
afterRender: (chart, args, options) => {
afterRender: (chart, _args, options) => {
if (chart.$initialAnimationCompleted === undefined) {
chart.$initialAnimationCompleted = true;
}

View File

@ -5,6 +5,7 @@ export interface ChartTotalizerPluginOptions {
}
declare module 'chart.js' {
// biome-ignore lint/correctness/noUnusedVariables: we need to define the plugin options
interface PluginOptionsByType<TType extends ChartType> {
totalizer?: ChartTotalizerPluginOptions | false;
}
@ -23,7 +24,7 @@ export const ChartTotalizerPlugin: Plugin<ChartType, ChartTotalizerPluginOptions
chart.$totalizer = { stackTotals: {}, seriesTotals: [] };
},
beforeDatasetsUpdate: (chart, args, options) => {
beforeDatasetsUpdate: (chart, _args, options) => {
if (options?.enabled === false) return;
const stackTotals: Record<string, number> = {};
@ -35,8 +36,8 @@ export const ChartTotalizerPlugin: Plugin<ChartType, ChartTotalizerPluginOptions
//dataset.hidden is true when the dataset is hidden by what was passed in the options
return !meta.hidden && !dataset.hidden;
})
.forEach((dataset, datasetIndex) => {
(chart.data.labels as string[])?.forEach((label, labelIndex) => {
.forEach((dataset) => {
(chart.data.labels as string[])?.forEach((_label, labelIndex) => {
const value = dataset.data[labelIndex];
if (typeof value === 'number') {
stackTotals[labelIndex] = (stackTotals[labelIndex] || 0) + value;

View File

@ -1,5 +1,5 @@
import type { Context } from 'chartjs-plugin-datalabels';
import { determineFontColorContrast } from '@/lib/colors';
import type { Context } from 'chartjs-plugin-datalabels';
export const dataLabelFontColorContrast = (context: Context) => {
const color = context.dataset.backgroundColor as string;

View File

@ -1,6 +1,6 @@
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
import type { Context } from 'chartjs-plugin-datalabels';
import { describe, expect, it } from 'vitest';
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
import { formatBarAndLineDataLabel } from './formatBarAndLineDataLabel';
describe('formatBarAndLineDataLabel', () => {

View File

@ -1,7 +1,7 @@
import type { Chart } from 'chart.js';
import { describe, expect, it } from 'vitest';
import type { ColumnSettings } from '@buster/server-shared/metrics';
import type { ColumnLabelFormat, SimplifiedColumnType } from '@buster/server-shared/metrics';
import type { Chart } from 'chart.js';
import { describe, expect, it } from 'vitest';
import { getLegendItems } from './getLegendItems';
describe('getLegendItems', () => {

View File

@ -1,7 +1,7 @@
import type { ColumnSettings } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { barOptionsHandler, barPluginsHandler } from './barChartOptions';
import type { ChartSpecificOptionsProps } from './interfaces';
import type { ColumnSettings } from '@buster/server-shared/metrics';
type BarGroupType = 'stack' | 'group' | 'percentage-stack' | null;

View File

@ -4,7 +4,7 @@ import type { ChartProps } from '../../core';
import type { ChartSpecificOptionsProps } from './interfaces';
export const barOptionsHandler = (
props: ChartSpecificOptionsProps
_props: ChartSpecificOptionsProps
): ChartProps<ChartJSChartType>['options'] => {
return {};
};

View File

@ -1,6 +1,6 @@
import type { ChartEncodes, ChartType } from '@buster/server-shared/metrics';
import type { ChartType as ChartJSChartType } from 'chart.js';
import type { BusterChartProps } from '../../../BusterChart.types';
import type { ChartEncodes, ChartType } from '@buster/server-shared/metrics';
import type { ChartProps } from '../../core';
export interface UseChartSpecificOptionsProps {

View File

@ -1,3 +1,4 @@
import type { ChartType } from '@buster/server-shared/metrics';
import type { ChartType as ChartJSChartType, PluginChartOptions } from 'chart.js';
import { useMemo } from 'react';
import type { DeepPartial } from 'utility-types';
@ -5,7 +6,6 @@ import type { ChartProps } from '../../core';
import { barOptionsHandler, barPluginsHandler } from './barChartOptions';
import type { ChartSpecificOptionsProps, UseChartSpecificOptionsProps } from './interfaces';
import { pieOptionsHandler, piePluginsHandler } from './pieChartOptions';
import type { ChartType } from '@buster/server-shared/metrics';
export const useChartSpecificOptions = ({
selectedChartType,
@ -36,13 +36,13 @@ const chartTypeOptionsHandler: Record<
ChartType,
(props: ChartSpecificOptionsProps) => ChartProps<ChartJSChartType>['options']
> = {
['pie']: pieOptionsHandler,
['line']: defaultHandler,
['scatter']: defaultHandler,
['bar']: barOptionsHandler,
['combo']: defaultHandler,
['metric']: defaultHandler,
['table']: defaultHandler,
pie: pieOptionsHandler,
line: defaultHandler,
scatter: defaultHandler,
bar: barOptionsHandler,
combo: defaultHandler,
metric: defaultHandler,
table: defaultHandler,
};
//********** PLUGINS ************ */
@ -55,11 +55,11 @@ const chartTypePluginsHandler: Record<
ChartType,
(props: ChartSpecificOptionsProps) => DeepPartial<PluginChartOptions<ChartJSChartType>>['plugins']
> = {
['pie']: piePluginsHandler,
['line']: defaultPluginsHandler,
['scatter']: defaultPluginsHandler,
['bar']: barPluginsHandler,
['combo']: defaultPluginsHandler,
['metric']: defaultPluginsHandler,
['table']: defaultPluginsHandler,
pie: piePluginsHandler,
line: defaultPluginsHandler,
scatter: defaultPluginsHandler,
bar: barPluginsHandler,
combo: defaultPluginsHandler,
metric: defaultPluginsHandler,
table: defaultPluginsHandler,
};

View File

@ -1,12 +1,12 @@
import {
type ChartConfigProps,
type ChartType,
DEFAULT_COLUMN_LABEL_FORMAT,
type GoalLine,
} from '@buster/server-shared/metrics';
import { renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { useGoalLines } from './useGoalLines';
import {
DEFAULT_COLUMN_LABEL_FORMAT,
type ChartConfigProps,
type ChartType,
type GoalLine,
} from '@buster/server-shared/metrics';
describe('useGoalLines', () => {
const defaultParams = {

View File

@ -1,8 +1,8 @@
import { useMemo } from 'react';
import type { ChartConfigProps } from '@buster/server-shared/metrics';
import { formatLabel } from '@/lib/columnFormatter';
import { truncateWithEllipsis } from '../../../../commonHelpers/titleHelpers';
import { AXIS_TITLE_SEPARATOR } from '@/lib/axisFormatter';
import { formatLabel } from '@/lib/columnFormatter';
import type { ChartConfigProps } from '@buster/server-shared/metrics';
import { useMemo } from 'react';
import { truncateWithEllipsis } from '../../../../commonHelpers/titleHelpers';
export const useY2AxisTitle = ({
y2Axis,

View File

@ -1,6 +1,6 @@
import type { ChartConfigProps, ChartType } from '@buster/server-shared/metrics';
import { renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { type ChartConfigProps, type ChartType } from '@buster/server-shared/metrics';
import { useInteractions } from './useInteractions';
describe('useInteractions', () => {

View File

@ -1,7 +1,7 @@
import type { ChartConfigProps } from '@buster/server-shared/metrics';
import type { CoreInteractionOptions } from 'chart.js';
import { useMemo } from 'react';
import type { DeepPartial } from 'utility-types'; // Add this import
import type { ChartConfigProps } from '@buster/server-shared/metrics';
interface UseInteractionsProps {
selectedChartType: ChartConfigProps['selectedChartType'];

View File

@ -1,3 +1,4 @@
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
import type {
BarControllerDatasetOptions,
Chart,
@ -5,7 +6,6 @@ import type {
TooltipItem,
} from 'chart.js';
import { describe, expect, it } from 'vitest';
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
import { barAndLineTooltipHelper } from './barAndLineTooltipHelper';
type MockDataset = Partial<

View File

@ -1,6 +1,6 @@
import { type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import type { Chart, TooltipItem } from 'chart.js';
import { describe, expect, it } from 'vitest';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ColumnLabelFormat } from '@buster/server-shared/metrics';
import { pieTooltipHelper } from './pieTooltipHelper';
describe('pieTooltipHelper', () => {

View File

@ -1,15 +1,15 @@
import '../../../ChartJSTheme';
import {
type ChartEncodes,
type ColumnSettings,
DEFAULT_COLUMN_LABEL_FORMAT,
DEFAULT_COLUMN_SETTINGS,
type SimplifiedColumnType,
} from '@buster/server-shared/metrics';
import { renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { useXAxis } from './useXAxis';
import {
DEFAULT_COLUMN_LABEL_FORMAT,
DEFAULT_COLUMN_SETTINGS,
type ChartEncodes,
type ColumnSettings,
type SimplifiedColumnType,
} from '@buster/server-shared/metrics';
describe('useXAxis', () => {
const defaultProps = {

View File

@ -1,6 +1,6 @@
import { type ComboChartAxis, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import { renderHook } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ComboChartAxis } from '@buster/server-shared/metrics';
import { useY2Axis } from './useY2Axis';
describe('useY2Axis', () => {

View File

@ -1,7 +1,7 @@
import { type ChartEncodes, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import { renderHook } from '@testing-library/react';
import type { LinearScaleOptions } from 'chart.js';
import { describe, expect, it } from 'vitest';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ChartEncodes } from '@buster/server-shared/metrics';
import { useYAxis } from './useYAxis';
describe('useYAxis', () => {

View File

@ -1,6 +1,6 @@
import { DEFAULT_COLUMN_SETTINGS } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { comboSeriesBuilder_data } from './comboSeriesBuilder';
import { DEFAULT_COLUMN_SETTINGS } from '@buster/server-shared/metrics';
describe('comboSeriesBuilder_data', () => {
const mockColors = ['#000000', '#111111'];

View File

@ -1,14 +1,14 @@
import {
type ColumnSettings,
DEFAULT_COLUMN_SETTINGS,
ENABLED_DOTS_ON_LINE_SIZE,
} from '@buster/server-shared/metrics';
import type { DatasetOption } from '../../../chartHooks';
import type { ChartProps } from '../../core';
import { barBuilder } from './barSeriesBuilder';
import type { SeriesBuilderProps } from './interfaces';
import { lineBuilder, lineSeriesBuilder_labels } from './lineSeriesBuilder';
import type { LabelBuilderProps } from './useSeriesOptions';
import {
DEFAULT_COLUMN_SETTINGS,
ENABLED_DOTS_ON_LINE_SIZE,
type ColumnSettings,
} from '@buster/server-shared/metrics';
type ComboSeries = Array<
ChartProps<'bar'>['data']['datasets'][number] | ChartProps<'line'>['data']['datasets'][number]

View File

@ -1,5 +1,5 @@
import type { BusterChartProps } from '../../../BusterChart.types';
import type { ChartEncodes } from '@buster/server-shared/metrics';
import type { BusterChartProps } from '../../../BusterChart.types';
import type { DatasetOptionsWithTicks } from '../../../chartHooks';
export interface SeriesBuilderProps {

View File

@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { ChartType } from '@buster/server-shared/metrics';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { computeHiddenShowItems } from './helpers';
import type { BusterChartLegendItem } from './interfaces';

View File

@ -1,11 +1,11 @@
import { describe, expect, it } from 'vitest';
import {
type ColumnLabelFormat,
type ShowLegendHeadline,
type ColumnMetaData,
type SimplifiedColumnType,
DEFAULT_COLUMN_LABEL_FORMAT,
type ShowLegendHeadline,
type SimplifiedColumnType,
} from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import type { DatasetOptionsWithTicks } from '../chartHooks/useDatasetOptions/interfaces';
import type { BusterChartLegendItem } from './interfaces';
import { addLegendHeadlines } from './legendHeadlineHelpers';

View File

@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import { fn } from '@storybook/test';
import type { BusterChartLegendItem } from '../interfaces';
import { OverflowButton } from '../OverflowContainer';
import type { BusterChartLegendItem } from '../interfaces';
const meta = {
title: 'UI/Charts/OverflowButton',

View File

@ -1,7 +1,7 @@
import type React from 'react';
import type { ITooltipItem } from './interfaces';
import { TooltipItem } from './TooltipItem';
import { TooltipTitle } from './TooltipTitle';
import type { ITooltipItem } from './interfaces';
const MAX_ITEMS_IN_TOOLTIP = 12;

View File

@ -1,6 +1,6 @@
import type React from 'react';
import type { ChartType } from '@buster/server-shared/metrics';
import { cn } from '@/lib/classMerge';
import type { ChartType } from '@buster/server-shared/metrics';
import type React from 'react';
import { LegendItemDot } from '../BusterChartLegend/LegendDot';
import type { ITooltipItem, TooltipItemValueProps } from './interfaces';

View File

@ -1,5 +1,5 @@
import type React from 'react';
import type { ChartType } from '@buster/server-shared/metrics';
import type React from 'react';
import { LegendItemDot } from '../BusterChartLegend';
export const TooltipTitle: React.FC<{

View File

@ -1,5 +1,5 @@
import { type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ColumnLabelFormat } from '@buster/server-shared/metrics';
import { aggregateAndCreateDatasets } from './aggregateAndCreateDatasets';
describe('aggregateAndCreateDatasets', () => {

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import type { ColumnMetaData } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { sortLineBarData } from './datasetHelpers_BarLinePie';
describe('sortLineBarData', () => {

View File

@ -1,5 +1,5 @@
import { type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ColumnLabelFormat } from '@buster/server-shared/metrics';
import { dataMapper } from './dataMapper';
describe('dataMapper', () => {

View File

@ -1,6 +1,6 @@
import type { ChartConfigProps } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { type ChartConfigProps } from '@buster/server-shared/metrics';
import { getPieInnerLabelTitle, InnerLabelTitleRecord } from './pieLabelHelpers';
import { InnerLabelTitleRecord, getPieInnerLabelTitle } from './pieLabelHelpers';
describe('pieLabelHelpers', () => {
describe('InnerLabelTitleRecord', () => {
@ -52,7 +52,7 @@ describe('pieLabelHelpers', () => {
});
it('should work with each type of aggregate', () => {
const testCases: Array<NonNullable<ChartConfigProps['pieInnerLabelAggregate']>> = [
const testCases: NonNullable<ChartConfigProps['pieInnerLabelAggregate']>[] = [
'sum',
'average',
'median',

View File

@ -1,6 +1,6 @@
import type { ChartEncodes } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { doesChartHaveValidAxis } from './helpers';
import type { ChartEncodes } from '@buster/server-shared/metrics';
describe('doesChartHaveValidAxis', () => {
it('should return true when isTable is true regardless of other parameters', () => {

View File

@ -1,5 +1,5 @@
import type { Meta } from '@storybook/react';
import { DEFAULT_CHART_CONFIG } from '@buster/server-shared/metrics';
import type { Meta } from '@storybook/react';
import { BusterChart } from '../BusterChart';
export const sharedMeta: Partial<Meta<typeof BusterChart>> = {

View File

@ -1,5 +1,5 @@
import { type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import type { Meta, StoryObj } from '@storybook/react';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ColumnLabelFormat } from '@buster/server-shared/metrics';
import { BusterMetricChart } from '../MetricChart/BusterMetricChart';
const meta: Meta<typeof BusterMetricChart> = {

View File

@ -1,6 +1,6 @@
import { type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT } from '@buster/server-shared/metrics';
import type { Meta, StoryObj } from '@storybook/react';
import { BusterTableChart } from '../TableChart/BusterTableChart';
import { DEFAULT_COLUMN_LABEL_FORMAT, type ColumnLabelFormat } from '@buster/server-shared/metrics';
// Helper functions for generating sample data
const generateProductName = (index: number) => `Product ${index + 1}`;

View File

@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import type { ColumnMetaData } from '@buster/server-shared/metrics';
import { DEFAULT_CHART_CONFIG } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import {
createDefaultBarAndLineAxis,
createDefaultPieAxis,

View File

@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest';
import {
type ColumnMetaData,
type ColumnLabelFormat,
type ColumnMetaData,
DEFAULT_COLUMN_LABEL_FORMAT,
} from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { createDefaultColumnLabelFormats } from './createDefaultColumnFormats';
describe('createDefaultColumnFormats', () => {

View File

@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import type { ColumnMetaData, ColumnSettings } from '@buster/server-shared/metrics';
import { DEFAULT_COLUMN_SETTINGS } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { createDefaultColumnSettings } from './createDefaultColumnSettings';
describe('createDefaultColumnSettings', () => {

View File

@ -1,10 +1,10 @@
import { create } from 'mutative';
import {
type ColumnMetaData,
type ChartConfigProps,
type ColumnMetaData,
DEFAULT_COLUMN_SETTINGS,
} from '@buster/server-shared/metrics';
import type { ColumnSettings } from '@buster/server-shared/metrics';
import { create } from 'mutative';
export const createDefaultColumnSettings = (
existingColumnSettings: Record<string, ColumnSettings> | undefined,

View File

@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest';
import {
type ChartType,
type DataMetadata,
type ChartConfigProps,
type ChartType,
DEFAULT_CHART_CONFIG,
type DataMetadata,
} from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { createDefaultChartConfig } from '.';
describe('createDefaultChartConfig', () => {

View File

@ -1,7 +1,7 @@
import { cn } from '@/lib/classMerge';
import type { Row } from '@tanstack/react-table';
import type { VirtualItem } from '@tanstack/react-virtual';
import type React from 'react';
import { cn } from '@/lib/classMerge';
import { DataGridCell } from './DataGridCell';
interface DataGridRowProps {

View File

@ -1,6 +1,6 @@
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
import { describe, expect, it } from 'vitest';
import { formatLabel } from './columnFormatter';
import type { ColumnLabelFormat } from '@buster/server-shared/metrics';
describe('formatLabel', () => {
describe('number formatting', () => {

View File

@ -1,12 +1,12 @@
import { describe, expect, it } from 'vitest';
import {
DATE_TYPES,
NUMBER_TYPES,
TEXT_TYPES,
isDateColumnType,
isNumericColumnStyle,
isNumericColumnType,
NUMBER_TYPES,
simplifyColumnType,
TEXT_TYPES,
} from './messages';
describe('simplifyColumnType', () => {

View File

@ -376,7 +376,7 @@ async function createPackageFiles(config: PackageConfig) {
build: "tsc",
typecheck: "tsc --noEmit",
dev: "tsc --watch",
lint: "biome check",
lint: "biome check --write",
test: "vitest run",
"test:watch": "vitest watch",
"test:coverage": "vitest run --coverage",