Skip to content

Add eslint and fix some side-effects #122

@mayorovad

Description

@mayorovad

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:

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.

fontBackgroundColor: ColorValue;
fontBorderColor: ColorValue;

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions