Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { Graph, Point } from '@maxgraph/core';
import { type CellStyle, Graph, Point } from '@maxgraph/core';

import { globalTypes, globalValues } from './shared/args.js';
import { createGraphContainer } from './shared/configure.js';
Expand All @@ -32,14 +32,14 @@ export default {
},
};

const Template = ({ label, ...args }) => {
const Template = ({ label, ...args }: Record<string, string>) => {
const container = createGraphContainer(args);

const graph = new Graph(container);
graph.setEnabled(false);
const parent = graph.getDefaultParent();

const vertexStyle = {
const vertexStyle: CellStyle = {
shape: 'cylinder',
strokeWidth: 2,
fillColor: '#ffffff',
Expand Down Expand Up @@ -74,21 +74,21 @@ const Template = ({ label, ...args }) => {
strokeWidth: 3,
endArrow: 'block',
endSize: 2,
endFill: 1,
endFill: true,
strokeColor: 'black',
rounded: 1,
rounded: true,
},
});
e1.geometry.points = [new Point(230, 50)];
e1.geometry && (e1.geometry.points = [new Point(230, 50)]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid assignment within expression.

The assignment within the condition makes the code harder to read and maintain.

-e1.geometry && (e1.geometry.points = [new Point(230, 50)]);
+if (e1.geometry) {
+  e1.geometry.points = [new Point(230, 50)];
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
e1.geometry && (e1.geometry.points = [new Point(230, 50)]);
if (e1.geometry) {
e1.geometry.points = [new Point(230, 50)];
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 82-82: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

graph.orderCells(true, [e1]);
});

// Adds animation to edge shape and makes "pipe" visible
const state = graph.view.getState(e1);
state.shape.node.getElementsByTagName('path')[0].removeAttribute('visibility');
state.shape.node.getElementsByTagName('path')[0].setAttribute('stroke-width', '6');
state.shape.node.getElementsByTagName('path')[0].setAttribute('stroke', 'lightGray');
state.shape.node.getElementsByTagName('path')[1].setAttribute('class', 'flow');
const state = graph.view.getState(e1!);
state?.shape?.node.getElementsByTagName('path')[0].removeAttribute('visibility');
state?.shape?.node.getElementsByTagName('path')[0].setAttribute('stroke-width', '6');
state?.shape?.node.getElementsByTagName('path')[0].setAttribute('stroke', 'lightGray');
state?.shape?.node.getElementsByTagName('path')[1].setAttribute('class', 'flow');

return container;
};
Expand Down