mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 13:44:39 +08:00
Also update the PRESUBMIT linter configuration to make sure it actually runs the linter when updating ESLint. Otherwise, it would not properly do the full linter check. R=jacktfranklin@chromium.org DISABLE_THIRD_PARTY_CHECK=Update ESLint Bug: 1068145 Change-Id: Ibf2de156366dc64c90ee1aced5537d2038e7a268 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2137384 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
'use strict';
|
|
var _ = require('lodash');
|
|
|
|
/**
|
|
* Choice object
|
|
* Normalize input as choice object
|
|
* @constructor
|
|
* @param {Number|String|Object} val Choice value. If an object is passed, it should contains
|
|
* at least one of `value` or `name` property
|
|
*/
|
|
|
|
module.exports = class Choice {
|
|
constructor(val, answers) {
|
|
// Don't process Choice and Separator object
|
|
if (val instanceof Choice || val.type === 'separator') {
|
|
// eslint-disable-next-line no-constructor-return
|
|
return val;
|
|
}
|
|
|
|
if (_.isString(val) || _.isNumber(val)) {
|
|
this.name = String(val);
|
|
this.value = val;
|
|
this.short = String(val);
|
|
} else {
|
|
_.extend(this, val, {
|
|
name: val.name || val.value,
|
|
value: 'value' in val ? val.value : val.name,
|
|
short: val.short || val.name || val.value
|
|
});
|
|
}
|
|
|
|
if (_.isFunction(val.disabled)) {
|
|
this.disabled = val.disabled(answers);
|
|
} else {
|
|
this.disabled = val.disabled;
|
|
}
|
|
}
|
|
};
|