danielzhe commented on issue #1377:
URL:
https://github.com/apache/incubator-kie-issues/issues/1377#issuecomment-2209461138
The first issue we have it is with this line:
`newValues.push(...Array(Math.max(0, minSize - C.length)));`
Let's consider this as our "Example Line", since `Array` returns an array of
`any` and `newValues` is a typed-array (`number[]`).
I did some research about what we can do to prevent that kind of issue, not
only that specific issue but also other issues related to objects with no
defined type (`any`).
**1. CUSTOM ESLINT RULE**
ESLint give us the possibility to create our custom rules. There are plenty
of documentation and examples to do that and it is a very powerful tool since
we can do almost every type of validation.
PROS:
[+] Very powerfull, alow us to create almost any kind of rule
CONS:
[-] Demands time to create the rules
[-] The developer must have have the ESLint configured in its IDE
**2. ESLINT OPTION "no-unsafe-assignment"**
We can enable the rule "@typescript-eslint/no-unsafe-assignment": "error",
in the .eslintrc.js.
This setting will NOT give a warning in our Example Line, but it will give
warning when we try to "tricky" the compiler with something like that:
`accessor: expressionHolderId as any`
Also:
`expression: getNewExpression(prev.in.expression),`
PROS:
[+] It will not break our entire codebase with errors, if we decide to set
the level to "error" instead of "warning
CONS:
[-] It will give us warnings in a few things that we already know
[-] The developer must have have the ESLint configured in its IDE
**3. ESLINT OPTION "no-explicit-any"**
This options marks as an error every use of the world "any". We can lower
the level to "warning" instead of "error" because enabling it as an error give
us 1900+ errors, only in BEE.
PROS:
[+] It will "ban" the use of "any"
CONS:
[-] The developer must have have the ESLint configured in its IDE
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]