Merged in eslint-prettier-config (pull request #53)

Eslint prettier config

* config eslint + manual fixes

* Merge branch 'develop' into eslint-prettier-config

* fixes eslint web2d


Approved-by: Paulo Veiga
This commit is contained in:
Gustavo Fuhr 2022-07-14 03:12:12 +00:00 committed by Paulo Veiga
parent 5ee7448d3c
commit 19353a9423
9 changed files with 144 additions and 136 deletions

View File

@ -22,7 +22,7 @@
"@typescript-eslint"
],
"rules": {
// ignore errores when a line finishes with (setting this value to 0 ignores all errors)
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
"operator-linebreak": [
"error", "after", {
"overrides": {

View File

@ -33,7 +33,8 @@ class OriginalLayout {
$assert(position, 'position can not be null');
$assert(type, 'type can not be null');
const strategy = type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
const strategy =
type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
return new Node(id, size, position, strategy);
}
@ -77,7 +78,7 @@ class OriginalLayout {
/** */
layout() {
const roots = this._treeSet.getTreeRoots();
roots.forEach(((node) => {
roots.forEach((node) => {
// Calculate all node heights ...
const sorter = node.getSorter();
@ -85,7 +86,7 @@ class OriginalLayout {
this._layoutChildren(node, heightById);
this._fixOverlapping(node, heightById);
}));
});
}
_layoutChildren(node, heightById) {
@ -117,8 +118,8 @@ class OriginalLayout {
const direction = node.getSorter().getChildDirection(me._treeSet, child);
if (
(direction > 0 && childFreeDisplacement.x < 0)
|| (direction < 0 && childFreeDisplacement.x > 0)
(direction > 0 && childFreeDisplacement.x < 0) ||
(direction < 0 && childFreeDisplacement.x > 0)
) {
child.resetFreeDisplacement();
child.setFreeDisplacement({
@ -145,9 +146,9 @@ class OriginalLayout {
}
// Continue reordering the children nodes ...
children.forEach(((child) => {
children.forEach((child) => {
this._layoutChildren(child, heightById);
}));
});
}
_calculateAlignOffset(node, child, heightById) {
@ -161,12 +162,13 @@ class OriginalLayout {
const childHeight = child.getSize().height;
if (
this._treeSet.isStartOfSubBranch(child)
&& OriginalLayout._branchIsTaller(child, heightById)
this._treeSet.isStartOfSubBranch(child) &&
OriginalLayout._branchIsTaller(child, heightById)
) {
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
offset = heightById[child.getId()] / 2
- (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
offset =
heightById[child.getId()] / 2 -
(childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
} else {
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
}
@ -189,8 +191,7 @@ class OriginalLayout {
static _branchIsTaller(node, heightById) {
return (
heightById[node.getId()]
> node.getSize().height + node.getSorter()._getVerticalPadding() * 2
heightById[node.getId()] > node.getSize().height + node.getSorter()._getVerticalPadding() * 2
);
}
@ -200,9 +201,9 @@ class OriginalLayout {
if (node.isFree()) {
this._shiftBranches(node, heightById);
}
children.forEach(((child) => {
children.forEach((child) => {
this._fixOverlapping(child, heightById);
}));
});
}
_shiftBranches(node, heightById) {
@ -213,27 +214,28 @@ class OriginalLayout {
node.getFreeDisplacement().y,
);
siblingsToShift.forEach(((sibling) => {
const overlappingOccurs = shiftedBranches.some(
((shiftedBranch) => OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById)),
siblingsToShift.forEach((sibling) => {
/* eslint-disable */
const overlappingOccurs = shiftedBranches.some((shiftedBranch) =>
OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById),
);
/* eslint-enable */
if (!sibling.isFree() || overlappingOccurs) {
const sAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
shiftedBranches.push(sibling);
}
}));
});
const branchesToShift = this._treeSet
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
.filter((branch) => !shiftedBranches.includes(branch));
branchesToShift.forEach(((branch) => {
branchesToShift.forEach((branch) => {
const bAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
shiftedBranches.push(branch);
}));
});
}
static _branchesOverlap(branchA, branchB, heightById) {

View File

@ -75,9 +75,7 @@ class BootstrapDialog extends Options {
)}</button>`,
);
footer.append(this.acceptButton);
this.acceptButton
.unbind('click')
.on('click', this.options.onEventData, this.onAcceptClick);
this.acceptButton.unbind('click').on('click', this.options.onEventData, this.onAcceptClick);
}
if (this.options.removeButton) {
this.removeButton = $(

View File

@ -15,7 +15,25 @@
"import/no-extraneous-dependencies": ["warn", {
"packageDir": ["./"],
"devDependencies": ["!cypress/**/*.js"]
}]
}],
// ignore errors when a line finishes with (setting this value to 0 ignores all errors)
"operator-linebreak": [
"error", "after", {
"overrides": {
"+": "ignore",
"-": "ignore",
":": "ignore",
"*": "ignore",
"?": "ignore",
">": "ignore",
"||": "ignore",
"&&": "ignore",
"(": "ignore"
}
}
],
"object-curly-newline": "off",
"indent": "off"
},
"settings": {
"import/resolver": {

View File

@ -160,13 +160,13 @@ class ElementClass {
*/
setStroke(width, style, color, opacity) {
if (
style != null
&& style !== undefined
&& style !== 'dash'
&& style !== 'dot'
&& style !== 'solid'
&& style !== 'longdash'
&& style !== 'dashdot'
style != null &&
style !== undefined &&
style !== 'dash' &&
style !== 'dot' &&
style !== 'solid' &&
style !== 'longdash' &&
style !== 'dashdot'
) {
throw new Error(`Unsupported stroke style: '${style}'`);
}

View File

@ -49,12 +49,7 @@ class ArrowPeer extends ElementPeer {
}
setDashed(isDashed, length, spacing) {
if (
$defined(isDashed)
&& isDashed
&& $defined(length)
&& $defined(spacing)
) {
if ($defined(isDashed) && isDashed && $defined(length) && $defined(spacing)) {
this._native.setAttribute('stroke-dasharray', `${length}${spacing}`);
} else {
this._native.setAttribute('stroke-dasharray', '');
@ -77,10 +72,10 @@ class ArrowPeer extends ElementPeer {
let xp;
let yp;
if (
$defined(this._fromPoint.x)
&& $defined(this._fromPoint.y)
&& $defined(this._controlPoint.x)
&& $defined(this._controlPoint.y)
$defined(this._fromPoint.x) &&
$defined(this._fromPoint.y) &&
$defined(this._controlPoint.x) &&
$defined(this._controlPoint.y)
) {
if (this._controlPoint.y === 0) this._controlPoint.y = 1;
@ -103,10 +98,12 @@ class ArrowPeer extends ElementPeer {
xp *= Math.sign(x3);
yp = x3 === 0 ? l * Math.sign(y3) : mp * xp;
const path = `M${this._fromPoint.x},${this._fromPoint.y} `
+ `L${x + this._fromPoint.x},${y + this._fromPoint.y} M${this._fromPoint.x},${this._fromPoint.y
} `
+ `L${xp + this._fromPoint.x},${yp + this._fromPoint.y}`;
const path =
`M${this._fromPoint.x},${this._fromPoint.y} ` +
`L${x + this._fromPoint.x},${y + this._fromPoint.y} M${this._fromPoint.x},${
this._fromPoint.y
} ` +
`L${xp + this._fromPoint.x},${yp + this._fromPoint.y}`;
this._native.setAttribute('d', path);
}
}

View File

@ -148,18 +148,24 @@ class CurvedLinePeer extends ElementPeer {
}
_updatePath(avoidControlPointFix) {
if (
$defined(this._x1)
&& $defined(this._y1)
&& $defined(this._x2)
&& $defined(this._y2)
) {
if ($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2)) {
this._calculateAutoControlPoints(avoidControlPointFix);
const path = `M${this._x1.toFixed(2)},${this._y1.toFixed(2)} C${(this._control1.x + this._x1).toFixed(2)},${this._control1.y + this._y1
} ${(this._control2.x + this._x2).toFixed(2)},${(this._control2.y + this._y2).toFixed(2)} ${(this._x2).toFixed(2)},${(this._y2).toFixed(2)}${this._lineStyle
? ` ${(this._control2.x + this._x2).toFixed(2)},${(this._control2.y + this._y2 + 3).toFixed(2)} ${(this._control1.x + this._x1
).toFixed(2)},${(this._control1.y + this._y1 + 5).toFixed(2)} ${this._x1.toFixed(2)},${(this._y1 + 7).toFixed(2)} Z`
const path = `M${this._x1.toFixed(2)},${this._y1.toFixed(2)} C${(
this._control1.x + this._x1
).toFixed(2)},${this._control1.y + this._y1} ${(this._control2.x + this._x2).toFixed(2)},${(
this._control2.y + this._y2
).toFixed(2)} ${this._x2.toFixed(2)},${this._y2.toFixed(2)}${
this._lineStyle
? ` ${(this._control2.x + this._x2).toFixed(2)},${(
this._control2.y +
this._y2 +
3
).toFixed(2)} ${(this._control1.x + this._x1).toFixed(2)},${(
this._control1.y +
this._y1 +
5
).toFixed(2)} ${this._x1.toFixed(2)},${(this._y1 + 7).toFixed(2)} Z`
: ''
}`;
this._native.setAttribute('d', path);
@ -193,10 +199,7 @@ class CurvedLinePeer extends ElementPeer {
const x2 = tarPos.x + Math.sqrt((l * l) / (1 + m * m)) * fix * -1;
const y2 = m * (x2 - tarPos.x) + tarPos.y;
return [
new Point(-srcPos.x + x1, -srcPos.y + y1),
new Point(-tarPos.x + x2, -tarPos.y + y2),
];
return [new Point(-srcPos.x + x1, -srcPos.y + y1), new Point(-tarPos.x + x2, -tarPos.y + y2)];
}
_calculateAutoControlPoints(avoidControlPointFix) {
@ -206,15 +209,15 @@ class CurvedLinePeer extends ElementPeer {
new Point(this._x2, this._y2),
);
if (
!this._customControlPoint_1
&& !($defined(avoidControlPointFix) && avoidControlPointFix === 0)
!this._customControlPoint_1 &&
!($defined(avoidControlPointFix) && avoidControlPointFix === 0)
) {
this._control1.x = defaultpoints[0].x;
this._control1.y = defaultpoints[0].y;
}
if (
!this._customControlPoint_2
&& !($defined(avoidControlPointFix) && avoidControlPointFix === 1)
!this._customControlPoint_2 &&
!($defined(avoidControlPointFix) && avoidControlPointFix === 1)
) {
this._control2.x = defaultpoints[1].x;
this._control2.y = defaultpoints[1].y;

View File

@ -39,9 +39,11 @@ export const getPosition = (elem) => {
// when a statically positioned element is identified
doc = elem.ownerDocument;
offsetParent = elem.offsetParent || doc.documentElement;
while (offsetParent
&& (offsetParent === doc.body || offsetParent === doc.documentElement)
&& getStyle(offsetParent, 'position') === 'static') {
while (
offsetParent &&
(offsetParent === doc.body || offsetParent === doc.documentElement) &&
getStyle(offsetParent, 'position') === 'static'
) {
offsetParent = offsetParent.parentNode;
}
if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {

View File

@ -28,16 +28,4 @@ import Text from './components/Text';
import Point from './components/Point';
import Image from './components/Image';
export {
Arrow,
CurvedLine,
Elipse,
Group,
Image,
Line,
Point,
PolyLine,
Rect,
Text,
Workspace,
};
export { Arrow, CurvedLine, Elipse, Group, Image, Line, Point, PolyLine, Rect, Text, Workspace };