-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Hi!
After looking at code for a little longer, it's seems that there are many introduced side-effects, which will be VERY tiring to find with the naked eye 👁️ . What do you think about adding eslint and looking what`s up? After linting with simple set of rules, there is indeed some interesting places, which can lead to bugs/side-effects, and also some code-style inconsistencies.
For example in addTextBackground of svg canvas:
maxGraph/packages/core/src/view/canvas/SvgCanvas2D.ts
Lines 1755 to 1756 in 02ea6f1
| if (s.fontBackgroundColor != null || s.fontBorderColor != null) { | |
| let bbox = null; |
There is checks for null, but when porting, null initialization replaced with NONE value, so this check will never work again, which lead to calling very time-consuming code of addTextBackground.
maxGraph/packages/core/src/types.ts
Lines 232 to 233 in 02ea6f1
| fontBackgroundColor: ColorValue; | |
| fontBorderColor: ColorValue; |
maxGraph/packages/core/src/view/canvas/AbstractCanvas2D.ts
Lines 166 to 167 in 02ea6f1
| fontBackgroundColor: NONE, | |
| fontBorderColor: NONE, |
But with right set of rules eslint is able to find it and scream warning Unnecessary conditional, the types have no overlap
Will be happy to make PR with eslint configured, if you interested :)