Skip to content
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

Merged
merged 3 commits into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gulp/plugins/util/parseType.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ require('babel-register')
const _ = require('lodash')
const SUI = require('../../../src/lib/SUI') // eslint-disable-line no-unused-vars

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}`)

const transformEnumValues = values => _.flatMap(values, ({ value }) => {
if (_.startsWith(value, '...SUI')) return evalValue(value.substring(3))
Expand All @@ -13,10 +15,10 @@ const parseEnum = type => {
const { value } = type

if (typeof value === 'string' && value.includes('SUI')) {
return Object.assign(type, { value: evalValue(value) })
return Object.assign(type, { value: uniqValues(evalValue(value)) })
}

return Object.assign(type, { value: transformEnumValues(value) })
return Object.assign(type, { value: uniqValues(transformEnumValues(value)) })
}

const parseUnion = union => {
Expand Down