-
Notifications
You must be signed in to change notification settings - Fork 100
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
More typescript eslint rules #1119
More typescript eslint rules #1119
Conversation
We have a lot of fields that return number, and lots that return number | undefined. This rule helps us track down cases where we're checking if a value is undefined when the types assert the value cannot be undefined.
Match is equivalent to exec if the entire string is to be searched for one match. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec
Codecov Report
@@ Coverage Diff @@
## master #1119 +/- ##
==========================================
+ Coverage 52.41% 53.22% +0.81%
==========================================
Files 235 235
Lines 11352 11329 -23
Branches 1600 1516 -84
==========================================
+ Hits 5950 6030 +80
+ Misses 5388 5285 -103
Partials 14 14
Continue to review full report at Codecov.
|
# Conflicts: # src/tests/components/Menu.test.tsx
Comparing two enums when there's only one value makes no sense
ca84371
to
6f8610e
Compare
392a23e
to
26865c8
Compare
Intermittent issue came up in build, present on master, added failing test as #1129. This one should be ready. |
First commit: Adds the typescript-eslint rules that are recommended, which consider type information. This fixes numerous different potential bugs and points of confusion. For example:
onClick
expects a method returning void, but often we want to do something asynchronously. So these cases are marked with a new functionintentionallyFloat
.async
but didn'tawait
anything.SoldAsset
, which requires acloseDate
and aclosePrice
. Eliminates lots of unnecessary undefined checking.Second commit: Adds a (not officially recommended but perfect for this project)
no-unnecessary-condition
rule. Benefits:number
and lots that returnnumber | undefined
. The basic rules catch cases where we're treating a field incorrectly as a field returning number when it can be undefined. This rule makes sure we're not needlessly checking for undefined when the types say undefined is not possible. In the future if we remove| undefined
from a field, the linter will find all the places where we were doing something like?? 0
.x() ?? 0 > 0
!??
is lower precedence than>
so that expression forx: () => A
would have typeA | boolean
and might not behave as expected.What kind of change does this PR introduce? (delete not applicable)