-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-magic-numbers] Support negative numbers #1072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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