fix(eslint-plugin): [no-magic-numbers] Support negative numbers#1072
Conversation
|
Thanks for the PR, @a-tarasyuk! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
d6979f7 to
4597e36
Compare
|
did we want to handle explicitly positive numbers at the same time? (I don't use this rule, so IDK if it's worth the effort) |
|
There are several Unary Operators which can potentially cause issues and which are all applied to numbers class A {
public readonly A = +127;
public readonly B = -127;
public readonly C = ~127;
public readonly D = ++127;
public readonly D = --127;
}Does that make sense to handle all of them? |
|
I don't think that people will use anything other than +/- when delcaring a constant.
|
4597e36 to
278cb38
Compare
|
@bradzacher ok, added |
bradzacher
left a comment
There was a problem hiding this comment.
LGTM, thanks for doing this
…or-negative-readonly-class-properties
Codecov Report
@@ Coverage Diff @@
## master #1072 +/- ##
==========================================
+ Coverage 94.01% 94.02% +0.01%
==========================================
Files 115 115
Lines 5110 5123 +13
Branches 1429 1434 +5
==========================================
+ Hits 4804 4817 +13
Misses 177 177
Partials 129 129
|
|
It seems like it doesn't work in enums: enum Status {
NONE = 0,
START = 1,
ERROR_DNS = -2,
ERROR_INSTALL = -6
} |
|
Please raise a new issue. Commenting on an old, closed PR is bad way to let us know of bugs. |
Fixes #1070