Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Sep 29, 2024
1 parent eb3d3f7 commit 49c1021
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"canvas": "^2.11.2",
"canvas-5-polyfill": "^0.1.5",
"chart.js": "^4.4.4",
"chartjs-plugin-datalabels": "^2.2.0",
"eslint": "^9.11.1",
"eslint-plugin-prettier": "^5.2.1",
"jest-image-snapshot": "^6.4.0",
Expand Down
17 changes: 6 additions & 11 deletions src/controllers/DendrogramController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ export class DendrogramController extends GraphController {
/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

updateEdgeElement(line: EdgeLine, index: number, properties: any, mode: UpdateMode): void {
// eslint-disable-next-line no-param-reassign
properties._orientation = this.options.tree.orientation;
super.updateEdgeElement(line, index, properties, mode);
}
Expand All @@ -62,10 +61,9 @@ export class DendrogramController extends GraphController {
/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

updateElement(point: Element<AnyObject, AnyObject>, index: number, properties: any, mode: UpdateMode): void {
if (index != null) {
// eslint-disable-next-line no-param-reassign
properties.angle = (this.getParsed(index) as { angle: number }).angle;
}
super.updateElement(point, index, properties, mode);
Expand Down Expand Up @@ -112,23 +110,20 @@ export class DendrogramController extends GraphController {

const orientation = {
horizontal: (d: { x: number; y: number; data: { x: number; y: number } }) => {
// eslint-disable-next-line no-param-reassign
d.data.x = d.y - 1;
// eslint-disable-next-line no-param-reassign

d.data.y = -d.x + 1;
},
vertical: (d: { x: number; y: number; data: { x: number; y: number } }) => {
// eslint-disable-next-line no-param-reassign
d.data.x = d.x - 1;
// eslint-disable-next-line no-param-reassign

d.data.y = -d.y + 1;
},
radial: (d: { x: number; y: number; data: { x: number; y: number; angle?: number } }) => {
// eslint-disable-next-line no-param-reassign
d.data.x = Math.cos(d.x) * d.y;
// eslint-disable-next-line no-param-reassign

d.data.y = Math.sin(d.x) * d.y;
// eslint-disable-next-line no-param-reassign

d.data.angle = d.y === 0 ? Number.NaN : d.x;
},
};
Expand Down
8 changes: 3 additions & 5 deletions src/controllers/ForceDirectedGraphController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,8 @@ export class ForceDirectedGraphController extends GraphController {

nodes.forEach((node) => {
if (node._sim) {
// eslint-disable-next-line no-param-reassign
node.x = rescaleX(node._sim.x ?? 0);
// eslint-disable-next-line no-param-reassign

node.y = rescaleY(node._sim.y ?? 0);
}
});
Expand All @@ -284,7 +283,7 @@ export class ForceDirectedGraphController extends GraphController {
const nodes = (this._cachedMeta._parsed as ITreeSimNode[]).map((node, i) => {
const simNode: ITreeSimNode['_sim'] = { ...node };
simNode.index = i;
// eslint-disable-next-line no-param-reassign

node._sim = simNode;
if (!node.reset) {
return simNode;
Expand All @@ -308,7 +307,7 @@ export class ForceDirectedGraphController extends GraphController {
const nodes = (meta._parsed as ITreeSimNode[]).map((node, i) => {
const simNode: ITreeSimNode['_sim'] = { ...node };
simNode.index = i;
// eslint-disable-next-line no-param-reassign

node._sim = simNode;
if (simNode.x === null) {
delete simNode.x;
Expand All @@ -317,7 +316,6 @@ export class ForceDirectedGraphController extends GraphController {
delete simNode.y;
}
if (simNode.x == null && simNode.y == null) {
// eslint-disable-next-line no-param-reassign
node.reset = true;
}
return simNode;
Expand Down
20 changes: 6 additions & 14 deletions src/controllers/GraphController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class GraphController extends ScatterController {
this.getDataset = () => {
return new Proxy(dataset, {
get(obj: any, prop: string) {
return prop === 'data' ? obj.edges ?? [] : obj[prop];
return prop === 'data' ? (obj.edges ?? []) : obj[prop];
},
});
};
Expand All @@ -259,8 +259,8 @@ export class GraphController extends ScatterController {
};

function copyPoint(point: { x: number; y: number; angle?: number }) {
const x = reset ? base.x : xScale?.getPixelForValue(point.x, 0) ?? 0;
const y = reset ? base.y : yScale?.getPixelForValue(point.y, 0) ?? 0;
const x = reset ? base.x : (xScale?.getPixelForValue(point.x, 0) ?? 0);
const y = reset ? base.y : (yScale?.getPixelForValue(point.y, 0) ?? 0);
return {
x,
y,
Expand Down Expand Up @@ -301,20 +301,20 @@ export class GraphController extends ScatterController {
/**
* @hidden
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

updateEdgeElement(edge: EdgeLine, index: number, properties: any, mode: UpdateMode): void {
super.updateElement(edge as unknown as Element<AnyObject, AnyObject>, index, properties, mode);
}

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

updateElement(point: Element<AnyObject, AnyObject>, index: number, properties: any, mode: UpdateMode): void {
if (mode === 'reset') {
// start in center also in x
const { xScale } = this._cachedMeta;
// eslint-disable-next-line no-param-reassign

properties.x = xScale?.getBasePixel() ?? 0;
}
super.updateElement(point, index, properties, mode);
Expand Down Expand Up @@ -345,7 +345,6 @@ export class GraphController extends ScatterController {
return index;
}

// eslint-disable-next-line no-console
console.warn('cannot resolve edge ref', ref);
return -1;
}
Expand Down Expand Up @@ -501,7 +500,6 @@ export class GraphController extends ScatterController {
meta.edges = metaData;

for (let i = 0; i < edges.length; i += 1) {
// eslint-disable-next-line new-cap
metaData[i] = new this.edgeElementType();
}
}
Expand All @@ -515,7 +513,6 @@ export class GraphController extends ScatterController {
const metaData = meta.edges || (meta.edges = []);

for (let i = 0; i < edges.length; i += 1) {
// eslint-disable-next-line new-cap
metaData[i] = metaData[i] || new this.edgeElementType();
}
if (edges.length < metaData.length) {
Expand Down Expand Up @@ -549,25 +546,21 @@ export class GraphController extends ScatterController {
_insertEdgeElements(start: number, count: number): void {
const elements = [];
for (let i = 0; i < count; i += 1) {
// eslint-disable-next-line new-cap
elements.push(new this.edgeElementType());
}
(this._cachedMeta as unknown as IExtendedChartMeta).edges.splice(start, 0, ...elements);
this.updateEdgeElements(elements, start, 'reset');
this._scheduleResyncLayout();
}

// eslint-disable-next-line class-methods-use-this
reLayout(): void {
// hook
}

// eslint-disable-next-line class-methods-use-this
resetLayout(): void {
// hook
}

// eslint-disable-next-line class-methods-use-this
stopLayout(): void {
// hook
}
Expand All @@ -585,7 +578,6 @@ export class GraphController extends ScatterController {
});
}

// eslint-disable-next-line class-methods-use-this
resyncLayout(): void {
// hook
}
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,7 @@ __metadata:
canvas: "npm:^2.11.2"
canvas-5-polyfill: "npm:^0.1.5"
chart.js: "npm:^4.4.4"
chartjs-plugin-datalabels: "npm:^2.2.0"
d3-dispatch: "npm:^3.0.1"
d3-force: "npm:^3.0.0"
d3-hierarchy: "npm:^3.1.2"
Expand Down Expand Up @@ -2262,6 +2263,15 @@ __metadata:
languageName: unknown
linkType: soft

"chartjs-plugin-datalabels@npm:^2.2.0":
version: 2.2.0
resolution: "chartjs-plugin-datalabels@npm:2.2.0"
peerDependencies:
chart.js: ">=3.0.0"
checksum: 10c0/de4855a795e4eef34869a16db1a8a0f905b6dfed0258c733338f472625361eb56fb899214b18651c1c1064cd343a78285ba576576693a40ec51285a84f022ea0
languageName: node
linkType: hard

"check-error@npm:^2.1.1":
version: 2.1.1
resolution: "check-error@npm:2.1.1"
Expand Down

0 comments on commit 49c1021

Please sign in to comment.