From e38f2795a956cb8bd228ff32c67f60afc8f431f9 Mon Sep 17 00:00:00 2001 From: Sam Washington Date: Fri, 5 Feb 2021 02:00:53 -0600 Subject: [PATCH 1/2] updated build script --- .eslintcache | 2 +- package.json | 2 +- src/lib/Viz.tsx | 3 ++- src/lib/useD3Elements.ts | 2 +- src/lib/useSimulation.ts | 21 +++------------------ src/lib/useSimulation.types.ts | 14 ++++++++++++++ 6 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 src/lib/useSimulation.types.ts diff --git a/.eslintcache b/.eslintcache index d3828e7..5e201f5 100644 --- a/.eslintcache +++ b/.eslintcache @@ -1 +1 @@ -[{"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/index.tsx":"1","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/reportWebVitals.ts":"2","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/App.tsx":"3","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/data.ts":"4","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/VizInputs.tsx":"5","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/Viz.tsx":"6","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumFromList.ts":"7","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToX_2.ts":"8","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToSpiral.ts":"9","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToRectangle.ts":"10","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useSimulation.ts":"11","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/util/useLocalStorage.ts":"12","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/RangeInput.tsx":"13","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3Elements.ts":"14","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3RootSvg.ts":"15","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/index.ts":"16","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/getLinkDraggingFunction.ts":"17"},{"size":500,"mtime":1609538580297,"results":"18","hashOfConfig":"19"},{"size":425,"mtime":1609538580298,"results":"20","hashOfConfig":"19"},{"size":2074,"mtime":1612502482171,"results":"21","hashOfConfig":"19"},{"size":4803,"mtime":1612080217564,"results":"22","hashOfConfig":"19"},{"size":8911,"mtime":1612502432591,"results":"23","hashOfConfig":"19"},{"size":3010,"mtime":1612503572013,"results":"24","hashOfConfig":"19"},{"size":596,"mtime":1611165669336,"results":"25","hashOfConfig":"19"},{"size":874,"mtime":1611126830907,"results":"26","hashOfConfig":"19"},{"size":520,"mtime":1611053173240,"results":"27","hashOfConfig":"19"},{"size":403,"mtime":1610135972115,"results":"28","hashOfConfig":"19"},{"size":12636,"mtime":1612511254453,"results":"29","hashOfConfig":"19"},{"size":1629,"mtime":1611122311902,"results":"30","hashOfConfig":"19"},{"size":2689,"mtime":1612498032691,"results":"31","hashOfConfig":"19"},{"size":4249,"mtime":1612509616232,"results":"32","hashOfConfig":"19"},{"size":2199,"mtime":1612510585275,"results":"33","hashOfConfig":"19"},{"size":105,"mtime":1612493944650,"results":"34","hashOfConfig":"19"},{"size":1213,"mtime":1612507162229,"results":"35","hashOfConfig":"19"},{"filePath":"36","messages":"37","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},"1sq1kvm",{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":1,"source":null},{"filePath":"43","messages":"44","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"45","usedDeprecatedRules":"38"},{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"48","messages":"49","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"52","messages":"53","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"54","usedDeprecatedRules":"38"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"59","messages":"60","errorCount":0,"warningCount":12,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"61","messages":"62","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"63","usedDeprecatedRules":"38"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"66","messages":"67","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"68","usedDeprecatedRules":"38"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/index.tsx",[],["75","76"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/reportWebVitals.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/App.tsx",["77","78"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/data.ts",["79","80","81","82"],"import * as d3 from 'd3';\nimport {DataCalculationPoint, Datum, DatumPrimaryKey} from './data.types';\nimport {datumFromList} from './datumFromList';\nimport {datumToRectangle} from './datumToRectangle';\nimport {datumToSpiral} from './datumToSpiral';\nimport {useEffect, useMemo, useState} from 'react';\nimport {datumToX_2} from './datumToX_2';\n\nexport const d_selectIndex = (d: Datum | undefined) => d?.i;\nexport const d_Id = (d: Datum | undefined): DatumPrimaryKey | undefined => d_selectIndex(d);\nexport const d_selectX = (d: Datum | undefined) => d?.x;\nexport const d_selectY = (d: Datum | undefined) => d?.y;\nexport const d_selectRadius = (d: Datum | undefined) => d?.r || 1;\n\nexport const getDataFillFn = (n: number) => (d: Datum, i: number) => d3.interpolateRainbow((d_selectIndex(d) || 1) / n);\n\n\nconst options: { [key: string]: (d: DataCalculationPoint) => Datum | undefined } =\n {\n spiral: datumToSpiral,\n x_2: datumToX_2,\n square: datumToRectangle,\n list_1: datumFromList,\n line: ({count, radius = 5, index: i}: DataCalculationPoint) => {\n return {\n x: i * 2 * radius,\n y: -i * 2 * radius,\n i,\n r: radius,\n }\n\n },\n };\n\n\ntype GeneratedDataOption = keyof typeof options;\n\nfunction createNodes(\n choice: GeneratedDataOption,\n count: number,\n theta: number,\n radialDecay: number | undefined,\n width: number,\n height: number,\n radius: number | undefined,\n steps: number,\n): Datum[] {\n return Array.from({length: count},\n (_, index) => {\n const thetaMultiplier = theta * index;\n let fn = [\n ((index || 1) ** 2) / ((radialDecay || 1) * count || 1),\n Math.pow((index || 1) ** .5, -(radialDecay || 0) / 100) || 1,\n ][1];\n const radiusMultiplier = radialDecay ? fn : 1;\n let scaledIndex = index / count;\n const args: DataCalculationPoint =\n {\n count,\n width,\n height,\n index,\n radius,\n steps,\n theta,\n scaledIndex,\n thetaMultiplier,\n radiusMultiplier: isFinite(radiusMultiplier) ? radiusMultiplier : 100,\n };\n if (!options[choice]) {\n throw new Error(`Missing option for ${choice}`)\n }\n return options[choice](args);\n })\n .filter(i => i !== undefined) as Datum[];\n}\n\ntype NodeInfo = { steps: number, theta: number, radialDecay?: number, radius?: number, count: number, };\n\n/**\n * ToDo: mutate the data instead of reinitializing it everytime one of the parameters changes\n */\nexport function useData(strategy: GeneratedDataOption,\n nodeInfo: NodeInfo,\n {width, height}: { width: number, height: number },\n): Datum[] {\n const radius = nodeInfo.radius ?? 5;\n\n const [prev, setPrev] = useState();\n useEffect(\n () => { setPrev({...nodeInfo, strategy}) },\n [...Object.values(nodeInfo), strategy],\n );\n\n const changed =\n (nodeInfo.theta !== prev?.theta) ||\n (nodeInfo.steps !== prev?.steps) ||\n (nodeInfo.radialDecay !== prev?.radialDecay);\n\n const nodes =\n useMemo(\n () => createNodes(strategy,\n nodeInfo.count,\n nodeInfo.theta,\n nodeInfo.radialDecay,\n width,\n height,\n nodeInfo.radius ?? 5,\n nodeInfo.steps),\n [changed],\n );\n\n useEffect(() => {\n if (!prev?.radius || !nodes.length) return;\n const difference = radius - prev.radius;\n if (!difference) return;\n nodes.map(node => node.r += difference);\n }, [prev?.radius, radius]);\n\n return nodes;\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/VizInputs.tsx",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/Viz.tsx",["83","84"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumFromList.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToX_2.ts",["85","86"],"import {DataCalculationPoint, Datum} from './data.types';\n\nexport function datumToX_2({\n steps = 12,\n width = 100,\n height = 100,\n radius = 0,\n radiusMultiplier = 1,\n theta = 1,\n thetaMultiplier = 0,\n index = 0,\n count = 1,\n }: DataCalculationPoint,\n): Datum {\n const distance = steps * Math.sqrt(index + 0.5);\n\n const horizontalDivisions = (count || 1) / width;\n console.log(count, width)\n return {\n x: 10 * index * (theta/10),\n y: -(index ** 2) * (steps/100),\n i: index,\n r: radius * radiusMultiplier,\n radiusMultiplier,\n };\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToSpiral.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToRectangle.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useSimulation.ts",["87","88","89","90","91","92","93","94","95","96","97","98"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/util/useLocalStorage.ts",["99"],"import {useCallback, useEffect, useState} from 'react';\n\nconst getKey = (key: string, initialValue: any) => {\n try {\n const item = global.localStorage?.getItem(key);\n return item ? JSON.parse(item) : initialValue;\n } catch (error) {\n console.log(error);\n return initialValue;\n }\n};\n\nexport function useLocalStorage(key: string, initialValue: T): [T, (t: T) => any] {\n const [storedValue, setStoredValue] = useState(() => getKey(key, initialValue));\n\n useEffect(() => setStoredValue(getKey(key, initialValue)), [key])\n\n const setValue = useCallback((value: Function | T) => {\n try {\n const valueToStore =\n typeof value === 'function'\n ? (value as Function)(storedValue)\n : value;\n setStoredValue(valueToStore);\n\n let cache: any[] = [];\n\n const serialized\n =\n JSON.stringify(valueToStore, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n // Duplicate reference found, discard key\n if (cache.includes(value)) return;\n\n // Store value in our collection\n cache.push(value);\n }\n return value;\n });\n\n global.localStorage?.setItem(key, serialized);\n } catch (error) {\n console.log(error);\n }\n }, [storedValue, key]);\n\n return [storedValue, setValue];\n}\n","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/RangeInput.tsx",["100","101"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3Elements.ts",["102"],"import {Datum, LinkDefinition, SvgCircleSelection, SvgLineSelection, SvgSelection} from './data.types';\nimport * as d3 from 'd3';\nimport {ValueFn} from 'd3';\nimport {useCallback, useMemo} from 'react';\nimport {d_selectRadius, d_selectX, d_selectY, getDataFillFn} from './data';\nimport {D3ComponentDefinition} from './useD3RootSvg';\nimport {ForceConfiguration} from './useSimulation';\n\ntype L = { source: Datum, target: Datum };\n\nexport type Information = { data: Datum[], links: LinkDefinition[] };\n\nexport type Style = {\n radius: number,\n colors?: number,\n animation?: 'random',\n radialDecay?: number\n};\n\nexport function useD3Elements(information: Information, style: Style, simSettings?: ForceConfiguration): [D3ComponentDefinition, D3ComponentDefinition] {\n type GenericValueFn = ValueFn;\n const _circles: D3ComponentDefinition =\n {\n data: information.data,\n initComponent(_svg: SvgSelection) {\n _svg.append('g').attr('class', 'circles');\n const circles = this.setData(_svg, information.data);\n if (circles) this.element.format((circles as SvgCircleSelection).join('circle'));\n },\n format:\n useCallback(\n (circles?: SvgCircleSelection, simulation?: d3.Simulation) => {\n let out = circles\n ?.attr('cx', ((d: Datum) => d_selectX(d)) as GenericValueFn)\n .attr('cy', ((d: Datum) => d_selectY(d)) as GenericValueFn)\n .attr('r', (d) => d_selectRadius(d) || style.radius)\n .attr('fill', getDataFillFn(style.colors || 30) as GenericValueFn);\n\n if (simulation) {\n let click = (event: d3.D3DragEvent, d: Datum) => {\n delete d.fx;\n delete d.fy;\n simulation?.alphaTarget(.9).restart();\n console.log(d);\n }\n\n // @ts-ignore\n out?.on('click', click);\n\n }\n return out;\n },\n [style.colors, style.radius],\n ),\n select:\n useMemo(() => (svg: SvgSelection) => (svg.select('g.circles').selectAll('circle') as unknown as SvgCircleSelection), []),\n };\n\n const _links: D3ComponentDefinition =\n {\n data: information.links,\n initComponent(_svg: SvgSelection) {\n _svg.append('g').attr('class', 'links');\n const links = this.setData(_svg, information.links);\n if (links) this.element.format((links as SvgLineSelection).join('line'));\n },\n format:\n useCallback(\n (links?: SvgLineSelection) => {\n return links\n ?.attr('stroke', '#cccccc')\n .attr('stroke-width', (10 * Math.abs((simSettings?.nodeLinkStrength || .1))) + 'px')\n .attr('x1', ((l: L) => l.source?.x) as GenericValueFn)\n .attr('y1', ((l: L) => l.source?.y) as GenericValueFn)\n .attr('x2', ((l: L) => l.target?.x) as GenericValueFn)\n .attr('y2', ((l: L) => l.target?.y) as GenericValueFn);\n },\n [information.links, information.data, simSettings?.nodeLinkStrength],\n )\n ,\n select:\n useMemo(() => (svg: SvgSelection) => (svg.select('g.links').selectAll('line') as unknown as SvgLineSelection), []),\n };\n return [_links, _circles];\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3RootSvg.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/index.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/getLinkDraggingFunction.ts",["103"],{"ruleId":"104","replacedBy":"105"},{"ruleId":"106","replacedBy":"107"},{"ruleId":"108","severity":1,"message":"109","line":7,"column":13,"nodeType":"110","messageId":"111","endLine":7,"endColumn":29,"fix":"112"},{"ruleId":"113","severity":1,"message":"114","line":36,"column":37,"nodeType":"115","endLine":36,"endColumn":43,"suggestions":"116"},{"ruleId":"113","severity":1,"message":"117","line":92,"column":9,"nodeType":"115","endLine":92,"endColumn":47,"suggestions":"118"},{"ruleId":"113","severity":1,"message":"119","line":92,"column":10,"nodeType":"120","endLine":92,"endColumn":36},{"ruleId":"113","severity":1,"message":"121","line":110,"column":19,"nodeType":"115","endLine":110,"endColumn":28,"suggestions":"122"},{"ruleId":"113","severity":1,"message":"123","line":118,"column":8,"nodeType":"115","endLine":118,"endColumn":30,"suggestions":"124"},{"ruleId":"113","severity":1,"message":"125","line":52,"column":38,"nodeType":"115","endLine":52,"endColumn":81,"suggestions":"126"},{"ruleId":"113","severity":1,"message":"127","line":73,"column":9,"nodeType":"115","endLine":73,"endColumn":45,"suggestions":"128"},{"ruleId":"129","severity":1,"message":"130","line":15,"column":11,"nodeType":"131","messageId":"132","endLine":15,"endColumn":19},{"ruleId":"129","severity":1,"message":"133","line":17,"column":11,"nodeType":"131","messageId":"132","endLine":17,"endColumn":30},{"ruleId":"134","severity":1,"message":"135","line":78,"column":5,"nodeType":"136","messageId":"137","endLine":91,"endColumn":6},{"ruleId":"113","severity":1,"message":"138","line":89,"column":19,"nodeType":"115","endLine":89,"endColumn":41,"suggestions":"139"},{"ruleId":"134","severity":1,"message":"135","line":111,"column":27,"nodeType":"136","messageId":"137","endLine":114,"endColumn":28},{"ruleId":"113","severity":1,"message":"140","line":136,"column":23,"nodeType":"115","endLine":143,"endColumn":24,"suggestions":"141"},{"ruleId":"134","severity":1,"message":"135","line":234,"column":31,"nodeType":"136","messageId":"137","endLine":261,"endColumn":32},{"ruleId":"134","severity":1,"message":"135","line":269,"column":27,"nodeType":"136","messageId":"137","endLine":274,"endColumn":28},{"ruleId":"113","severity":1,"message":"142","line":276,"column":23,"nodeType":"115","endLine":284,"endColumn":24,"suggestions":"143"},{"ruleId":"113","severity":1,"message":"144","line":283,"column":27,"nodeType":"120","endLine":283,"endColumn":36},{"ruleId":"113","severity":1,"message":"145","line":286,"column":9,"nodeType":"131","endLine":286,"endColumn":18,"suggestions":"146"},{"ruleId":"134","severity":1,"message":"135","line":290,"column":5,"nodeType":"136","messageId":"137","endLine":292,"endColumn":6},{"ruleId":"113","severity":1,"message":"147","line":291,"column":69,"nodeType":"115","endLine":291,"endColumn":96,"suggestions":"148"},{"ruleId":"113","severity":1,"message":"149","line":291,"column":83,"nodeType":"150","endLine":291,"endColumn":95},{"ruleId":"113","severity":1,"message":"151","line":16,"column":64,"nodeType":"115","endLine":16,"endColumn":69,"suggestions":"152"},{"ruleId":"113","severity":1,"message":"153","line":23,"column":9,"nodeType":"115","endLine":23,"endColumn":26,"suggestions":"154"},{"ruleId":"129","severity":1,"message":"155","line":27,"column":19,"nodeType":"131","messageId":"132","endLine":27,"endColumn":27},{"ruleId":"113","severity":1,"message":"156","line":78,"column":27,"nodeType":"115","endLine":78,"endColumn":95,"suggestions":"157"},{"ruleId":"134","severity":1,"message":"135","line":26,"column":9,"nodeType":"136","messageId":"137","endLine":29,"endColumn":10},"no-native-reassign",["158"],"no-negated-in-lhs",["159"],"no-useless-rename","Destructuring assignment props unnecessarily renamed.","Property","unnecessarilyRenamed",{"range":"160","text":"161"},"react-hooks/exhaustive-deps","React Hook useMemo has an unnecessary dependency: 'data'. Either exclude it or remove the dependency array.","ArrayExpression",["162"],"React Hook useEffect has a missing dependency: 'nodeInfo'. Either include it or remove the dependency array. If 'setPrev' needs the current value of 'nodeInfo', you can also switch to useReducer instead of useState and read 'nodeInfo' in the reducer.",["163"],"React Hook useEffect has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.","SpreadElement","React Hook useMemo has missing dependencies: 'height', 'nodeInfo.count', 'nodeInfo.radialDecay', 'nodeInfo.radius', 'nodeInfo.steps', 'nodeInfo.theta', 'strategy', and 'width'. Either include them or remove the dependency array.",["164"],"React Hook useEffect has a missing dependency: 'nodes'. Either include it or remove the dependency array.",["165"],"React Hook useMemo has missing dependencies: 'props.forces?.boundingBox' and 'props.forces?.center'. Either include them or remove the dependency array.",["166"],"React Hook useEffect has an unnecessary dependency: 'ref.current'. Either exclude it or remove the dependency array. Mutable values like 'ref.current' aren't valid dependencies because mutating them doesn't re-render the component.",["167"],"@typescript-eslint/no-unused-vars","'distance' is assigned a value but never used.","Identifier","unusedVar","'horizontalDivisions' is assigned a value but never used.","no-lone-blocks","Nested block is redundant.","BlockStatement","redundantNestedBlock","React Hook useEffect has a missing dependency: 'root'. Either include it or remove the dependency array.",["168"],"React Hook useCallback has missing dependencies: 'root' and 'simulation'. Either include them or remove the dependency array.",["169"],"React Hook useCallback has missing dependencies: 'offset', 'simSettings', and 'simulation'. Either include them or remove the dependency array.",["170"],"React Hook useCallback has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.","React Hook useEffect has a missing dependency: 'useTheForce'. Either include it or remove the dependency array.",["171"],"React Hook useEffect has a missing dependency: 'simulation'. Either include it or remove the dependency array.",["172"],"React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.","UnaryExpression","React Hook useEffect has a missing dependency: 'initialValue'. Either include it or remove the dependency array. If 'setStoredValue' needs the current value of 'initialValue', you can also switch to useReducer instead of useState and read 'initialValue' in the reducer.",["173"],"React Hook useEffect has missing dependencies: 'inputRef', 'setValue', and 'step'. Either include them or remove the dependency array. If 'setValue' changes too often, find the parent component that defines it and wrap that definition in useCallback.",["174"],"'setWidth' is assigned a value but never used.","React Hook useCallback has unnecessary dependencies: 'information.data' and 'information.links'. Either exclude them or remove the dependency array.",["175"],"no-global-assign","no-unsafe-negation",[138,154],"props",{"desc":"176","fix":"177"},{"desc":"178","fix":"179"},{"desc":"180","fix":"181"},{"desc":"182","fix":"183"},{"desc":"184","fix":"185"},{"desc":"186","fix":"187"},{"desc":"188","fix":"189"},{"desc":"190","fix":"191"},{"desc":"192","fix":"193"},{"desc":"194","fix":"195"},{"desc":"196","fix":"197"},{"desc":"198","fix":"199"},{"desc":"200","fix":"201"},{"desc":"202","fix":"203"},"Update the dependencies array to be: []",{"range":"204","text":"205"},"Update the dependencies array to be: [nodeInfo, strategy]",{"range":"206","text":"207"},"Update the dependencies array to be: [height, nodeInfo.count, nodeInfo.radialDecay, nodeInfo.radius, nodeInfo.steps, nodeInfo.theta, strategy, width]",{"range":"208","text":"209"},"Update the dependencies array to be: [nodes, prev.radius, radius]",{"range":"210","text":"211"},"Update the dependencies array to be: [props.forces?.boundingBox, props.forces?.center, nodeStrength, linkStrength]",{"range":"212","text":"213"},"Update the dependencies array to be: [sim, simSettingSpread]",{"range":"214","text":"215"},"Update the dependencies array to be: [style.radius, offset, root]",{"range":"216","text":"217"},"Update the dependencies array to be: [root, information.links, information.data, simulation]",{"range":"218","text":"219"},"Update the dependencies array to be: [simSettings, information.data, information.links, update, offset, simulation]",{"range":"220","text":"221"},"Update the dependencies array to be: [useTheForce]",{"range":"222","text":"223"},"Update the dependencies array to be: [simSettings, simulation]",{"range":"224","text":"225"},"Update the dependencies array to be: [initialValue, key]",{"range":"226","text":"227"},"Update the dependencies array to be: [value, min, max, inputRef, step, setValue]",{"range":"228","text":"229"},"Update the dependencies array to be: [simSettings?.nodeLinkStrength]",{"range":"230","text":"231"},[993,999],"[]",[3823,3861],"[nodeInfo, strategy]",[4517,4526],"[height, nodeInfo.count, nodeInfo.radialDecay, nodeInfo.radius, nodeInfo.steps, nodeInfo.theta, strategy, width]",[4758,4780],"[nodes, prev.radius, radius]",[2149,2192],"[props.forces?.boundingBox, props.forces?.center, nodeStrength, linkStrength]",[2840,2876],"[sim, simSettingSpread]",[2482,2504],"[style.radius, offset, root]",[4393,4709],"[root, information.links, information.data, simulation]",[11989,12336],"[simSettings, information.data, information.links, update, offset, simulation]",[12390,12440],"[useTheForce]",[12553,12580],"[simSettings, simulation]",[559,564],"[initialValue, key]",[814,831],"[value, min, max, inputRef, step, setValue]",[3921,3989],"[simSettings?.nodeLinkStrength]"] \ No newline at end of file +[{"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/index.tsx":"1","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/reportWebVitals.ts":"2","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/App.tsx":"3","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/data.ts":"4","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/VizInputs.tsx":"5","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/Viz.tsx":"6","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumFromList.ts":"7","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToX_2.ts":"8","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToSpiral.ts":"9","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToRectangle.ts":"10","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useSimulation.ts":"11","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/util/useLocalStorage.ts":"12","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/RangeInput.tsx":"13","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3Elements.ts":"14","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3RootSvg.ts":"15","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/index.ts":"16","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/getLinkDraggingFunction.ts":"17"},{"size":500,"mtime":1609538580297,"results":"18","hashOfConfig":"19"},{"size":425,"mtime":1609538580298,"results":"20","hashOfConfig":"19"},{"size":2074,"mtime":1612502482171,"results":"21","hashOfConfig":"19"},{"size":4803,"mtime":1612080217564,"results":"22","hashOfConfig":"19"},{"size":8911,"mtime":1612502432591,"results":"23","hashOfConfig":"19"},{"size":3048,"mtime":1612511545109,"results":"24","hashOfConfig":"19"},{"size":596,"mtime":1611165669336,"results":"25","hashOfConfig":"19"},{"size":874,"mtime":1611126830907,"results":"26","hashOfConfig":"19"},{"size":520,"mtime":1611053173240,"results":"27","hashOfConfig":"19"},{"size":403,"mtime":1610135972115,"results":"28","hashOfConfig":"19"},{"size":12449,"mtime":1612511561093,"results":"29","hashOfConfig":"19"},{"size":1629,"mtime":1611122311902,"results":"30","hashOfConfig":"19"},{"size":2689,"mtime":1612498032691,"results":"31","hashOfConfig":"19"},{"size":4255,"mtime":1612511545117,"results":"32","hashOfConfig":"19"},{"size":2199,"mtime":1612510585275,"results":"33","hashOfConfig":"19"},{"size":105,"mtime":1612493944650,"results":"34","hashOfConfig":"19"},{"size":1213,"mtime":1612507162229,"results":"35","hashOfConfig":"19"},{"filePath":"36","messages":"37","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},"1sq1kvm",{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":1,"source":null},{"filePath":"43","messages":"44","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"45","usedDeprecatedRules":"38"},{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"48","messages":"49","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"52","messages":"53","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"54","usedDeprecatedRules":"38"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"59","messages":"60","errorCount":0,"warningCount":12,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"61","messages":"62","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"63","usedDeprecatedRules":"38"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"66","messages":"67","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"68","usedDeprecatedRules":"38"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"38"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/index.tsx",[],["75","76"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/reportWebVitals.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/App.tsx",["77","78"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/data.ts",["79","80","81","82"],"import * as d3 from 'd3';\nimport {DataCalculationPoint, Datum, DatumPrimaryKey} from './data.types';\nimport {datumFromList} from './datumFromList';\nimport {datumToRectangle} from './datumToRectangle';\nimport {datumToSpiral} from './datumToSpiral';\nimport {useEffect, useMemo, useState} from 'react';\nimport {datumToX_2} from './datumToX_2';\n\nexport const d_selectIndex = (d: Datum | undefined) => d?.i;\nexport const d_Id = (d: Datum | undefined): DatumPrimaryKey | undefined => d_selectIndex(d);\nexport const d_selectX = (d: Datum | undefined) => d?.x;\nexport const d_selectY = (d: Datum | undefined) => d?.y;\nexport const d_selectRadius = (d: Datum | undefined) => d?.r || 1;\n\nexport const getDataFillFn = (n: number) => (d: Datum, i: number) => d3.interpolateRainbow((d_selectIndex(d) || 1) / n);\n\n\nconst options: { [key: string]: (d: DataCalculationPoint) => Datum | undefined } =\n {\n spiral: datumToSpiral,\n x_2: datumToX_2,\n square: datumToRectangle,\n list_1: datumFromList,\n line: ({count, radius = 5, index: i}: DataCalculationPoint) => {\n return {\n x: i * 2 * radius,\n y: -i * 2 * radius,\n i,\n r: radius,\n }\n\n },\n };\n\n\ntype GeneratedDataOption = keyof typeof options;\n\nfunction createNodes(\n choice: GeneratedDataOption,\n count: number,\n theta: number,\n radialDecay: number | undefined,\n width: number,\n height: number,\n radius: number | undefined,\n steps: number,\n): Datum[] {\n return Array.from({length: count},\n (_, index) => {\n const thetaMultiplier = theta * index;\n let fn = [\n ((index || 1) ** 2) / ((radialDecay || 1) * count || 1),\n Math.pow((index || 1) ** .5, -(radialDecay || 0) / 100) || 1,\n ][1];\n const radiusMultiplier = radialDecay ? fn : 1;\n let scaledIndex = index / count;\n const args: DataCalculationPoint =\n {\n count,\n width,\n height,\n index,\n radius,\n steps,\n theta,\n scaledIndex,\n thetaMultiplier,\n radiusMultiplier: isFinite(radiusMultiplier) ? radiusMultiplier : 100,\n };\n if (!options[choice]) {\n throw new Error(`Missing option for ${choice}`)\n }\n return options[choice](args);\n })\n .filter(i => i !== undefined) as Datum[];\n}\n\ntype NodeInfo = { steps: number, theta: number, radialDecay?: number, radius?: number, count: number, };\n\n/**\n * ToDo: mutate the data instead of reinitializing it everytime one of the parameters changes\n */\nexport function useData(strategy: GeneratedDataOption,\n nodeInfo: NodeInfo,\n {width, height}: { width: number, height: number },\n): Datum[] {\n const radius = nodeInfo.radius ?? 5;\n\n const [prev, setPrev] = useState();\n useEffect(\n () => { setPrev({...nodeInfo, strategy}) },\n [...Object.values(nodeInfo), strategy],\n );\n\n const changed =\n (nodeInfo.theta !== prev?.theta) ||\n (nodeInfo.steps !== prev?.steps) ||\n (nodeInfo.radialDecay !== prev?.radialDecay);\n\n const nodes =\n useMemo(\n () => createNodes(strategy,\n nodeInfo.count,\n nodeInfo.theta,\n nodeInfo.radialDecay,\n width,\n height,\n nodeInfo.radius ?? 5,\n nodeInfo.steps),\n [changed],\n );\n\n useEffect(() => {\n if (!prev?.radius || !nodes.length) return;\n const difference = radius - prev.radius;\n if (!difference) return;\n nodes.map(node => node.r += difference);\n }, [prev?.radius, radius]);\n\n return nodes;\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/VizInputs.tsx",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/Viz.tsx",["83","84"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumFromList.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToX_2.ts",["85","86"],"import {DataCalculationPoint, Datum} from './data.types';\n\nexport function datumToX_2({\n steps = 12,\n width = 100,\n height = 100,\n radius = 0,\n radiusMultiplier = 1,\n theta = 1,\n thetaMultiplier = 0,\n index = 0,\n count = 1,\n }: DataCalculationPoint,\n): Datum {\n const distance = steps * Math.sqrt(index + 0.5);\n\n const horizontalDivisions = (count || 1) / width;\n console.log(count, width)\n return {\n x: 10 * index * (theta/10),\n y: -(index ** 2) * (steps/100),\n i: index,\n r: radius * radiusMultiplier,\n radiusMultiplier,\n };\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToSpiral.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/datumToRectangle.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useSimulation.ts",["87","88","89","90","91","92","93","94","95","96","97","98"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/util/useLocalStorage.ts",["99"],"import {useCallback, useEffect, useState} from 'react';\n\nconst getKey = (key: string, initialValue: any) => {\n try {\n const item = global.localStorage?.getItem(key);\n return item ? JSON.parse(item) : initialValue;\n } catch (error) {\n console.log(error);\n return initialValue;\n }\n};\n\nexport function useLocalStorage(key: string, initialValue: T): [T, (t: T) => any] {\n const [storedValue, setStoredValue] = useState(() => getKey(key, initialValue));\n\n useEffect(() => setStoredValue(getKey(key, initialValue)), [key])\n\n const setValue = useCallback((value: Function | T) => {\n try {\n const valueToStore =\n typeof value === 'function'\n ? (value as Function)(storedValue)\n : value;\n setStoredValue(valueToStore);\n\n let cache: any[] = [];\n\n const serialized\n =\n JSON.stringify(valueToStore, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n // Duplicate reference found, discard key\n if (cache.includes(value)) return;\n\n // Store value in our collection\n cache.push(value);\n }\n return value;\n });\n\n global.localStorage?.setItem(key, serialized);\n } catch (error) {\n console.log(error);\n }\n }, [storedValue, key]);\n\n return [storedValue, setValue];\n}\n","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/RangeInput.tsx",["100","101"],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3Elements.ts",["102"],"import {Datum, LinkDefinition, SvgCircleSelection, SvgLineSelection, SvgSelection} from './data.types';\nimport * as d3 from 'd3';\nimport {ValueFn} from 'd3';\nimport {useCallback, useMemo} from 'react';\nimport {d_selectRadius, d_selectX, d_selectY, getDataFillFn} from './data';\nimport {D3ComponentDefinition} from './useD3RootSvg';\nimport {ForceConfiguration} from './useSimulation';\n\ntype L = { source: Datum, target: Datum };\n\nexport type Information = { data: Datum[], links: LinkDefinition[] };\n\nexport type Style = {\n radius: number,\n colors?: number,\n animation?: 'random',\n radialDecay?: number\n};\n\nexport function useD3Elements(information: Information, style: Style, simSettings?: ForceConfiguration): [D3ComponentDefinition, D3ComponentDefinition] {\n type GenericValueFn = ValueFn;\n const _circles: D3ComponentDefinition =\n {\n data: information.data,\n initComponent(_svg: SvgSelection) {\n _svg.append('g').attr('class', 'circles');\n const circles = this.setData(_svg, information.data);\n if (circles) this.element.format((circles as SvgCircleSelection).join('circle'));\n },\n format:\n useCallback(\n (circles?: SvgCircleSelection, simulation?: d3.Simulation) => {\n let out = circles\n ?.attr('cx', ((d: Datum) => d_selectX(d)) as GenericValueFn)\n .attr('cy', ((d: Datum) => d_selectY(d)) as GenericValueFn)\n .attr('r', (d) => d_selectRadius(d) || style.radius)\n .attr('fill', getDataFillFn(style.colors || 30) as GenericValueFn);\n\n if (simulation) {\n let click = (event: d3.D3DragEvent, d: Datum) => {\n delete d.fx;\n delete d.fy;\n simulation?.alphaTarget(.9).restart();\n console.log(d);\n }\n\n // @ts-ignore\n out?.on('click', click);\n\n }\n return out;\n },\n [style.colors, style.radius],\n ),\n select:\n useMemo(() => (svg: SvgSelection) => (svg.select('g.circles').selectAll('circle') as unknown as SvgCircleSelection), []),\n };\n\n const _links: D3ComponentDefinition =\n {\n data: information.links,\n initComponent(_svg: SvgSelection) {\n _svg.append('g').attr('class', 'links');\n const links = this.setData(_svg, information.links);\n if (links) this.element.format((links as SvgLineSelection).join('line'));\n },\n format:\n useCallback(\n (links?: SvgLineSelection) => {\n return links\n ?.attr('stroke', '#cccccc')\n .attr('stroke-width', (10 * Math.abs((simSettings?.nodeLinkStrength || .1))) + 'px')\n .attr('x1', ((l: L) => l.source?.x) as GenericValueFn)\n .attr('y1', ((l: L) => l.source?.y) as GenericValueFn)\n .attr('x2', ((l: L) => l.target?.x) as GenericValueFn)\n .attr('y2', ((l: L) => l.target?.y) as GenericValueFn);\n },\n [information.links, information.data, simSettings?.nodeLinkStrength],\n )\n ,\n select:\n useMemo(() => (svg: SvgSelection) => (svg.select('g.links').selectAll('line') as unknown as SvgLineSelection), []),\n };\n return [_links, _circles];\n}","/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/useD3RootSvg.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/index.ts",[],"/Users/samwashington/WebstormProjects/playground/visualization/d3/react-d3/src/lib/getLinkDraggingFunction.ts",["103"],{"ruleId":"104","replacedBy":"105"},{"ruleId":"106","replacedBy":"107"},{"ruleId":"108","severity":1,"message":"109","line":7,"column":13,"nodeType":"110","messageId":"111","endLine":7,"endColumn":29,"fix":"112"},{"ruleId":"113","severity":1,"message":"114","line":36,"column":37,"nodeType":"115","endLine":36,"endColumn":43,"suggestions":"116"},{"ruleId":"113","severity":1,"message":"117","line":92,"column":9,"nodeType":"115","endLine":92,"endColumn":47,"suggestions":"118"},{"ruleId":"113","severity":1,"message":"119","line":92,"column":10,"nodeType":"120","endLine":92,"endColumn":36},{"ruleId":"113","severity":1,"message":"121","line":110,"column":19,"nodeType":"115","endLine":110,"endColumn":28,"suggestions":"122"},{"ruleId":"113","severity":1,"message":"123","line":118,"column":8,"nodeType":"115","endLine":118,"endColumn":30,"suggestions":"124"},{"ruleId":"113","severity":1,"message":"125","line":53,"column":38,"nodeType":"115","endLine":53,"endColumn":81,"suggestions":"126"},{"ruleId":"113","severity":1,"message":"127","line":74,"column":9,"nodeType":"115","endLine":74,"endColumn":45,"suggestions":"128"},{"ruleId":"129","severity":1,"message":"130","line":15,"column":11,"nodeType":"131","messageId":"132","endLine":15,"endColumn":19},{"ruleId":"129","severity":1,"message":"133","line":17,"column":11,"nodeType":"131","messageId":"132","endLine":17,"endColumn":30},{"ruleId":"134","severity":1,"message":"135","line":63,"column":5,"nodeType":"136","messageId":"137","endLine":76,"endColumn":6},{"ruleId":"113","severity":1,"message":"138","line":74,"column":19,"nodeType":"115","endLine":74,"endColumn":41,"suggestions":"139"},{"ruleId":"134","severity":1,"message":"135","line":96,"column":27,"nodeType":"136","messageId":"137","endLine":99,"endColumn":28},{"ruleId":"113","severity":1,"message":"140","line":121,"column":23,"nodeType":"115","endLine":128,"endColumn":24,"suggestions":"141"},{"ruleId":"134","severity":1,"message":"135","line":219,"column":31,"nodeType":"136","messageId":"137","endLine":246,"endColumn":32},{"ruleId":"134","severity":1,"message":"135","line":254,"column":27,"nodeType":"136","messageId":"137","endLine":259,"endColumn":28},{"ruleId":"113","severity":1,"message":"142","line":261,"column":23,"nodeType":"115","endLine":269,"endColumn":24,"suggestions":"143"},{"ruleId":"113","severity":1,"message":"144","line":268,"column":27,"nodeType":"120","endLine":268,"endColumn":36},{"ruleId":"113","severity":1,"message":"145","line":271,"column":9,"nodeType":"131","endLine":271,"endColumn":18,"suggestions":"146"},{"ruleId":"134","severity":1,"message":"135","line":275,"column":5,"nodeType":"136","messageId":"137","endLine":277,"endColumn":6},{"ruleId":"113","severity":1,"message":"147","line":276,"column":69,"nodeType":"115","endLine":276,"endColumn":96,"suggestions":"148"},{"ruleId":"113","severity":1,"message":"149","line":276,"column":83,"nodeType":"150","endLine":276,"endColumn":95},{"ruleId":"113","severity":1,"message":"151","line":16,"column":64,"nodeType":"115","endLine":16,"endColumn":69,"suggestions":"152"},{"ruleId":"113","severity":1,"message":"153","line":23,"column":9,"nodeType":"115","endLine":23,"endColumn":26,"suggestions":"154"},{"ruleId":"129","severity":1,"message":"155","line":27,"column":19,"nodeType":"131","messageId":"132","endLine":27,"endColumn":27},{"ruleId":"113","severity":1,"message":"156","line":78,"column":27,"nodeType":"115","endLine":78,"endColumn":95,"suggestions":"157"},{"ruleId":"134","severity":1,"message":"135","line":26,"column":9,"nodeType":"136","messageId":"137","endLine":29,"endColumn":10},"no-native-reassign",["158"],"no-negated-in-lhs",["159"],"no-useless-rename","Destructuring assignment props unnecessarily renamed.","Property","unnecessarilyRenamed",{"range":"160","text":"161"},"react-hooks/exhaustive-deps","React Hook useMemo has an unnecessary dependency: 'data'. Either exclude it or remove the dependency array.","ArrayExpression",["162"],"React Hook useEffect has a missing dependency: 'nodeInfo'. Either include it or remove the dependency array. If 'setPrev' needs the current value of 'nodeInfo', you can also switch to useReducer instead of useState and read 'nodeInfo' in the reducer.",["163"],"React Hook useEffect has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.","SpreadElement","React Hook useMemo has missing dependencies: 'height', 'nodeInfo.count', 'nodeInfo.radialDecay', 'nodeInfo.radius', 'nodeInfo.steps', 'nodeInfo.theta', 'strategy', and 'width'. Either include them or remove the dependency array.",["164"],"React Hook useEffect has a missing dependency: 'nodes'. Either include it or remove the dependency array.",["165"],"React Hook useMemo has missing dependencies: 'props.forces?.boundingBox' and 'props.forces?.center'. Either include them or remove the dependency array.",["166"],"React Hook useEffect has an unnecessary dependency: 'ref.current'. Either exclude it or remove the dependency array. Mutable values like 'ref.current' aren't valid dependencies because mutating them doesn't re-render the component.",["167"],"@typescript-eslint/no-unused-vars","'distance' is assigned a value but never used.","Identifier","unusedVar","'horizontalDivisions' is assigned a value but never used.","no-lone-blocks","Nested block is redundant.","BlockStatement","redundantNestedBlock","React Hook useEffect has a missing dependency: 'root'. Either include it or remove the dependency array.",["168"],"React Hook useCallback has missing dependencies: 'root' and 'simulation'. Either include them or remove the dependency array.",["169"],"React Hook useCallback has missing dependencies: 'offset', 'simSettings', and 'simulation'. Either include them or remove the dependency array.",["170"],"React Hook useCallback has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies.","React Hook useEffect has a missing dependency: 'useTheForce'. Either include it or remove the dependency array.",["171"],"React Hook useEffect has a missing dependency: 'simulation'. Either include it or remove the dependency array.",["172"],"React Hook useEffect has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked.","UnaryExpression","React Hook useEffect has a missing dependency: 'initialValue'. Either include it or remove the dependency array. If 'setStoredValue' needs the current value of 'initialValue', you can also switch to useReducer instead of useState and read 'initialValue' in the reducer.",["173"],"React Hook useEffect has missing dependencies: 'inputRef', 'setValue', and 'step'. Either include them or remove the dependency array. If 'setValue' changes too often, find the parent component that defines it and wrap that definition in useCallback.",["174"],"'setWidth' is assigned a value but never used.","React Hook useCallback has unnecessary dependencies: 'information.data' and 'information.links'. Either exclude them or remove the dependency array.",["175"],"no-global-assign","no-unsafe-negation",[138,154],"props",{"desc":"176","fix":"177"},{"desc":"178","fix":"179"},{"desc":"180","fix":"181"},{"desc":"182","fix":"183"},{"desc":"184","fix":"185"},{"desc":"186","fix":"187"},{"desc":"188","fix":"189"},{"desc":"190","fix":"191"},{"desc":"192","fix":"193"},{"desc":"194","fix":"195"},{"desc":"196","fix":"197"},{"desc":"198","fix":"199"},{"desc":"200","fix":"201"},{"desc":"202","fix":"203"},"Update the dependencies array to be: []",{"range":"204","text":"205"},"Update the dependencies array to be: [nodeInfo, strategy]",{"range":"206","text":"207"},"Update the dependencies array to be: [height, nodeInfo.count, nodeInfo.radialDecay, nodeInfo.radius, nodeInfo.steps, nodeInfo.theta, strategy, width]",{"range":"208","text":"209"},"Update the dependencies array to be: [nodes, prev.radius, radius]",{"range":"210","text":"211"},"Update the dependencies array to be: [props.forces?.boundingBox, props.forces?.center, nodeStrength, linkStrength]",{"range":"212","text":"213"},"Update the dependencies array to be: [sim, simSettingSpread]",{"range":"214","text":"215"},"Update the dependencies array to be: [style.radius, offset, root]",{"range":"216","text":"217"},"Update the dependencies array to be: [root, information.links, information.data, simulation]",{"range":"218","text":"219"},"Update the dependencies array to be: [simSettings, information.data, information.links, update, offset, simulation]",{"range":"220","text":"221"},"Update the dependencies array to be: [useTheForce]",{"range":"222","text":"223"},"Update the dependencies array to be: [simSettings, simulation]",{"range":"224","text":"225"},"Update the dependencies array to be: [initialValue, key]",{"range":"226","text":"227"},"Update the dependencies array to be: [value, min, max, inputRef, step, setValue]",{"range":"228","text":"229"},"Update the dependencies array to be: [simSettings?.nodeLinkStrength]",{"range":"230","text":"231"},[993,999],"[]",[3823,3861],"[nodeInfo, strategy]",[4517,4526],"[height, nodeInfo.count, nodeInfo.radialDecay, nodeInfo.radius, nodeInfo.steps, nodeInfo.theta, strategy, width]",[4758,4780],"[nodes, prev.radius, radius]",[2187,2230],"[props.forces?.boundingBox, props.forces?.center, nodeStrength, linkStrength]",[2878,2914],"[sim, simSettingSpread]",[2295,2317],"[style.radius, offset, root]",[4206,4522],"[root, information.links, information.data, simulation]",[11802,12149],"[simSettings, information.data, information.links, update, offset, simulation]",[12203,12253],"[useTheForce]",[12366,12393],"[simSettings, simulation]",[559,564],"[initialValue, key]",[814,831],"[value, min, max, inputRef, step, setValue]",[3921,3989],"[simSettings?.nodeLinkStrength]"] \ No newline at end of file diff --git a/package.json b/package.json index 2b65c04..6d6b9cd 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "scripts": { "start": "react-scripts start", - "build": "rm -rf dist; tsc", + "build": "rm -rf dist; tsc --noEmit false", "test": "react-scripts test", "eject": "react-scripts eject", "prepublish": "npm run build;" diff --git a/src/lib/Viz.tsx b/src/lib/Viz.tsx index b1df4c0..e18721b 100644 --- a/src/lib/Viz.tsx +++ b/src/lib/Viz.tsx @@ -1,7 +1,8 @@ import React, {useEffect, useMemo, useRef} from 'react'; -import {ForceConfiguration, useSimulation} from './useSimulation'; +import {useSimulation} from './useSimulation'; import {Height, ViewBox, Width} from './viz.types'; import {Datum, LinkDefinition} from './data.types'; +import {ForceConfiguration} from './useSimulation.types'; type VizParams = { data: Datum[], diff --git a/src/lib/useD3Elements.ts b/src/lib/useD3Elements.ts index f7c6ceb..7eadbb8 100644 --- a/src/lib/useD3Elements.ts +++ b/src/lib/useD3Elements.ts @@ -3,8 +3,8 @@ import * as d3 from 'd3'; import {ValueFn} from 'd3'; import {useCallback, useMemo} from 'react'; import {d_selectRadius, d_selectX, d_selectY, getDataFillFn} from './data'; -import {ForceConfiguration} from './useSimulation'; import {Definition} from './useD3RootSvg.types'; +import {ForceConfiguration} from './useSimulation.types'; type L = { source: Datum, target: Datum }; diff --git a/src/lib/useSimulation.ts b/src/lib/useSimulation.ts index 7a6f332..9e7b3f2 100644 --- a/src/lib/useSimulation.ts +++ b/src/lib/useSimulation.ts @@ -5,31 +5,16 @@ import {ViewBox} from './viz.types'; import {Datum, SvgCircleSelection, SvgLineSelection} from './data.types'; import {Information, Style, useD3Elements} from './useD3Elements'; import {getFn_updateLinkLineElementWhenDragged} from './getLinkDraggingFunction'; +import {ForceConfiguration, NDimensionalTuple_2} from './useSimulation.types'; -//////////////////// -/** - * Types - */ -export interface ForceConfiguration { - boundingBox?: boolean; - nodeForceStrength: number; - center?: number; - nodeLinkStrength: number -} - -type NDimensionalTuple_2 = [number, number]; - -//////////////////// /** * Selectors */ - /** * Simulation Width * @param offset */ -const o_Width = (offset: ViewBox) => offset[2]; - +const o_Width = (offset: ViewBox) => offset[2]; /** * Simulation Height * @param offset @@ -37,7 +22,7 @@ const o_Width = (offset: ViewBox) => offset[2]; const o_Height = (offset: ViewBox) => offset[3]; -/////////////////////////////// +//////////////////// /** * Export */ diff --git a/src/lib/useSimulation.types.ts b/src/lib/useSimulation.types.ts new file mode 100644 index 0000000..f0df29b --- /dev/null +++ b/src/lib/useSimulation.types.ts @@ -0,0 +1,14 @@ +/** + * Configuration for the forces in a simulation + */ +export interface ForceConfiguration { + boundingBox?: boolean; + nodeForceStrength: number; + center?: number; + nodeLinkStrength: number +} + +/** + * Describes 2 dimensions, X and Y + */ +export type NDimensionalTuple_2 = [number, number]; \ No newline at end of file From 9077d47a05eb7cb31ac539569c1a966748b82ea2 Mon Sep 17 00:00:00 2001 From: Sam Washington Date: Fri, 5 Feb 2021 02:01:20 -0600 Subject: [PATCH 2/2] v0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d6b9cd..fd8decd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spwashi/react-d3", - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0",