-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
docs(props): fix uniqueness #1780
Conversation
gulp/plugins/util/parseType.js
Outdated
const evalValue = value => _.uniq(eval(value)) // eslint-disable-line no-eval | ||
const evalValue = value => eval(value) // eslint-disable-line no-eval | ||
|
||
const uniqValues = values => _.uniqWith(values, (val, other) => val == other) // eslint-disable-line eqeqeq |
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.
We cannot use there strict equals, because 1
and '1'
aren't equal.
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.
Coerce them both to numbers with the +
operator:
+val === +other
Example:
val = '5'
typeof val // => "string"
typeof +val // => "number"
val === 5 // => false
+val === 5 // => true
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.
Yes, but not all items of array are numbers:
val = 'five'
+val // => NaN
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.
I think we can do following:
`${val}` === `${other}`
// or
val.toString() === other.toString()
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.
Nice catch, that works as well.
Codecov Report
@@ Coverage Diff @@
## master #1780 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 142 142
Lines 2459 2459
=======================================
Hits 2453 2453
Misses 6 6 Continue to review full report at Codecov.
|
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.
I've performed requested change, LGTM
Thank ya! |
Released in |
Before
After
Why?
SUI.WIDTHS
contains both numbers and strings (example:1
and'1'
), but it does not matter for the docs. Also, as we usevalue
askey
and React convertskey
to string, we have duplicate, but invisible elements.