Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .eslintrc.cjs

This file was deleted.

894 changes: 0 additions & 894 deletions .yarn/releases/yarn-4.2.2.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ packageExtensions:
dependencies:
eslint-import-resolver-node: "*"

yarnPath: .yarn/releases/yarn-4.2.2.cjs
yarnPath: .yarn/releases/yarn-4.5.0.cjs
61 changes: 61 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-plugin-prettier';

export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
plugins: { prettier },
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'max-classes-per-file': 'off',
'no-underscore-dangle': 'off',
'import/extensions': 'off',
},
});

// import path from "node:path";
// import { fileURLToPath } from "node:url";
// import js from "@eslint/js";
// import { FlatCompat } from "@eslint/eslintrc";

// const __filename = fileURLToPath(import.meta.url);
// const __dirname = path.dirname(__filename);
// const compat = new FlatCompat({
// baseDirectory: __dirname,
// recommendedConfig: js.configs.recommended,
// allConfig: js.configs.all
// });

// export default [...fixupConfigRules(compat.extends(
// "airbnb-typescript",
// "react-app",
// "plugin:prettier/recommended",
// "prettier",
// )), {
// plugins: {
// prettier: fixupPluginRules(prettier),
// },

// languageOptions: {
// ecmaVersion: 5,
// sourceType: "script",

// parserOptions: {
// project: "./tsconfig.eslint.json",
// },
// },

// settings: {
// react: {
// version: "99.99.99",
// },
// },

// rules: {
// "@typescript-eslint/no-explicit-any": "off",
// "max-classes-per-file": "off",
// "no-underscore-dangle": "off",
// "import/extensions": "off",
// },
// }];
6 changes: 0 additions & 6 deletions jest.config.js

This file was deleted.

70 changes: 29 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,75 +69,63 @@
"last 2 Firefox versions"
],
"dependencies": {
"@sgratzl/boxplots": "^1.3.0"
"@sgratzl/boxplots": "^1.3.2"
},
"devDependencies": {
"@chiogen/rollup-plugin-terser": "^7.1.3",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.12",
"@eslint/js": "^9.11.1",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-typescript": "^12.1.0",
"@types/jest-image-snapshot": "^6.4.0",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@yarnpkg/sdks": "^3.1.2",
"@types/node": "^22.7.4",
"@yarnpkg/sdks": "^3.2.0",
"canvas": "^2.11.2",
"canvas-5-polyfill": "^0.1.5",
"chart.js": "^4.4.3",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"chart.js": "^4.4.4",
"eslint": "^9.11.1",
"eslint-plugin-prettier": "^5.2.1",
"jest-image-snapshot": "^6.4.0",
"prettier": "^3.3.1",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"jsdom": "^25.0.1",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"rollup": "^4.22.5",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1",
"ts-jest": "^29.1.4",
"tslib": "^2.6.3",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.3",
"typedoc-vitepress-theme": "^1.0.0",
"typescript": "^5.4.5",
"vitepress": "^1.2.3",
"vue": "^3.4.27",
"ts-jest": "^29.2.5",
"tslib": "^2.7.0",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.8",
"typedoc-vitepress-theme": "^1.0.1",
"typescript": "^5.6.2",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.8",
"vitepress": "^1.3.4",
"vitest": "^2.1.1",
"vue": "^3.5.10",
"vue-chartjs": "^5.3.1"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0"
},
"scripts": {
"clean": "rimraf --glob build node_modules \"*.tgz\" \"*.tsbuildinfo\"",
"compile": "tsc -b tsconfig.c.json",
"start": "yarn run watch",
"watch": "rollup -c -w",
"build": "rollup -c",
"test": "yarn node --experimental-vm-modules $(yarn bin jest) --passWithNoTests --detectOpenHandles --forceExit",
"test": "vitest --passWithNoTests",
"test:watch": "yarn run test --watch",
"test:coverage": "yarn run test --coverage",
"lint": "yarn run eslint && yarn run prettier",
"fix": "yarn run eslint:fix && yarn run prettier:write",
"prettier:write": "prettier \"*\" \"*/**\" --write",
"prettier": "prettier \"*\" \"*/**\" --check",
"eslint": "eslint src --ext .ts,.tsx --cache",
"eslint": "eslint src --cache",
"eslint:fix": "yarn run eslint --fix",
"prepare": "yarn run build",
"docs:api": "typedoc --options typedoc.json",
"docs:dev": "vitepress dev docs",
"docs:build": "yarn run docs:api && vitepress build docs",
"docs:preview": "vitepress preview docs"
},
"packageManager": "yarn@4.2.2"
"packageManager": "yarn@4.5.0"
}
8 changes: 4 additions & 4 deletions src/__tests__/createChart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="jest" />
/// <reference types="node" />

import { expect } from 'vitest';
import { Chart, ChartConfiguration, defaults, ChartType, DefaultDataPoint } from 'chart.js';
import { toMatchImageSnapshot, MatchImageSnapshotOptions } from 'jest-image-snapshot';
import 'canvas-5-polyfill';
Expand All @@ -12,7 +12,7 @@ function toBuffer(canvas: HTMLCanvasElement) {
canvas.toBlob((b) => {
const file = new FileReader();
file.onload = () => resolve(Buffer.from(file.result as ArrayBuffer));
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

file.readAsArrayBuffer(b!);
});
});
Expand Down Expand Up @@ -40,7 +40,7 @@ export default function createChart<
canvas.height = height;
Object.assign(defaults.font, { family: 'Courier New' });
// defaults.color = 'transparent';
// eslint-disable-next-line no-param-reassign

config.options = {
responsive: false,
animation: {
Expand All @@ -56,7 +56,7 @@ export default function createChart<
},
...(config.options || {}),
} as any;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

const ctx = canvas.getContext('2d')!;

const t = new Chart<TYPE, DATA, LABEL>(ctx, config);
Expand Down
1 change: 1 addition & 0 deletions src/controllers/BoxPlotController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
LinearScale,
LogarithmicScale,
} from 'chart.js';
import { describe, beforeAll, test } from 'vitest';
import createChart from '../__tests__/createChart';
import { BoxPlotController, BoxPlotDataPoint } from './BoxPlotController';
import { Samples } from './__tests__/utils';
Expand Down
10 changes: 4 additions & 6 deletions src/controllers/BoxPlotController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ export class BoxPlotController extends StatsBase<IBoxPlot, Required<IBoxplotOpti
/**
* @hidden
*/
// eslint-disable-next-line class-methods-use-this

protected _parseStats(value: unknown, config: IBoxplotOptions): IBoxPlot | undefined {
return asBoxPlotStats(value, config);
}

/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

protected _transformStats<T>(target: any, source: IBoxPlot, mapper: (v: number) => T): void {
super._transformStats(target, source, mapper);
for (const key of ['whiskerMin', 'whiskerMax']) {
// eslint-disable-next-line no-param-reassign
target[key] = mapper(source[key as 'whiskerMin' | 'whiskerMax']);
}
}
Expand Down Expand Up @@ -82,8 +81,7 @@ export interface BoxPlotControllerDatasetOptions

export type BoxPlotDataPoint = number[] | (Partial<IBoxPlot> & Pick<IBoxPlot, 'min' | 'max' | 'median' | 'q1' | 'q3'>);

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IBoxPlotChartOptions extends IBoxplotOptions {}
export type IBoxPlotChartOptions = IBoxplotOptions;

declare module 'chart.js' {
export interface ChartTypeRegistry {
Expand All @@ -92,7 +90,7 @@ declare module 'chart.js' {
datasetOptions: BoxPlotControllerDatasetOptions;
defaultDataPoint: BoxPlotDataPoint;
scales: keyof CartesianScaleTypeRegistry;
metaExtensions: {};
metaExtensions: object;
parsedDataType: IBoxPlot & ChartTypeRegistry['bar']['parsedDataType'];
};
}
Expand Down
24 changes: 10 additions & 14 deletions src/controllers/StatsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,16 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
/**
* @hidden
*/
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types

protected _transformStats<T>(target: any, source: S, mapper: (v: number) => T): void {
for (const key of ['min', 'max', 'median', 'q3', 'q1', 'mean']) {
const v = source[key as keyof IBaseStats];
if (typeof v === 'number') {
// eslint-disable-next-line no-param-reassign
target[key] = mapper(v);
}
}
for (const key of ['outliers', 'items']) {
if (Array.isArray(source[key as keyof IBaseStats])) {
// eslint-disable-next-line no-param-reassign
target[key] = source[key as 'outliers' | 'items'].map(mapper);
}
}
Expand All @@ -90,13 +88,13 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
getMinMax(scale: Scale, canStack?: boolean | undefined): { min: number; max: number } {
const bak = scale.axis;
const config = this.options;
// eslint-disable-next-line no-param-reassign

scale.axis = config.minStats;
const { min } = super.getMinMax(scale, canStack);
// eslint-disable-next-line no-param-reassign

scale.axis = config.maxStats;
const { max } = super.getMinMax(scale, canStack);
// eslint-disable-next-line no-param-reassign

scale.axis = bak;
return { min, max };
}
Expand All @@ -105,9 +103,8 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
* @hidden
*/
parsePrimitiveData(meta: ChartMeta, data: any[], start: number, count: number): Record<string, unknown>[] {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const vScale = meta.vScale!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

const iScale = meta.iScale!;
const labels = iScale.getLabels();
const r = [];
Expand Down Expand Up @@ -142,7 +139,7 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

protected abstract _parseStats(value: any, options: C): S | undefined;
/**
* @hidden
Expand Down Expand Up @@ -182,9 +179,8 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
/**
* @hidden
*/
// eslint-disable-next-line class-methods-use-this

protected _toStringStats(b: S): string {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const f = (v: number) => (v == null ? 'NaN' : formatNumber(v, this.chart.options.locale!, {}));
return `(min: ${f(b.min)}, 25% quantile: ${f(b.q1)}, median: ${f(b.median)}, mean: ${f(b.mean)}, 75% quantile: ${f(
b.q3
Expand All @@ -194,15 +190,15 @@ export abstract class StatsBase<S extends IBaseStats, C extends Required<IBaseOp
/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

updateElement(rectangle: Element, index: number, properties: any, mode: UpdateMode): void {
const reset = mode === 'reset';
const scale = this._cachedMeta.vScale as LinearScale;
const parsed = this.getParsed(index) as unknown as S;
const base = scale.getBasePixel();
// eslint-disable-next-line no-param-reassign

properties._datasetIndex = this.index;
// eslint-disable-next-line no-param-reassign

properties._index = index;
this._transformStats(properties, parsed, (v) => (reset ? base : scale.getPixelForValue(v, index)));
super.updateElement(rectangle, index, properties, mode);
Expand Down
1 change: 1 addition & 0 deletions src/controllers/ViolinController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import createChart from '../__tests__/createChart';
import { ViolinController } from './ViolinController';
import { Samples } from './__tests__/utils';
import { Violin } from '../elements';
import { describe, beforeAll, test } from 'vitest';

describe('violin', () => {
beforeAll(() => {
Expand Down
Loading