diff --git a/src/apis/StyleSheet/StyleSheetValidation.js b/src/apis/StyleSheet/StyleSheetValidation.js index 567fb5b8..0d584108 100644 --- a/src/apis/StyleSheet/StyleSheetValidation.js +++ b/src/apis/StyleSheet/StyleSheetValidation.js @@ -1,62 +1,68 @@ -/* eslint-disable */ /** - * Copyright (c) 2016-present, Nicolas Gallagher. * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. - + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule StyleSheetValidation * @flow */ import ImageStylePropTypes from '../../components/Image/ImageStylePropTypes'; -import ReactPropTypeLocationNames from '../../vendor/ReactPropTypeLocationNames'; -import ReactPropTypesSecret from '../../vendor/ReactPropTypesSecret'; import TextInputStylePropTypes from '../../components/TextInput/TextInputStylePropTypes'; import TextStylePropTypes from '../../components/Text/TextStylePropTypes'; import ViewStylePropTypes from '../../components/View/ViewStylePropTypes'; import warning from 'fbjs/lib/warning'; import { oneOf, string } from 'prop-types'; +// Hardcoded because this is a legit case but we don't want to load it from +// a private API. We might likely want to unify style sheet creation with how it +// is done in the DOM so this might move into React. I know what I'm doing so +// plz don't fire me. +const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + class StyleSheetValidation { static validateStyleProp(prop, style, caller) { if (process.env.NODE_ENV !== 'production') { if (allStylePropTypes[prop] === undefined) { - var message1 = '"' + prop + '" is not a valid style property.'; - var message2 = + const message1 = '"' + prop + '" is not a valid style property.'; + const message2 = '\nValid style props: ' + JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' '); styleError(message1, style, caller, message2); - } else { - var error = allStylePropTypes[prop]( - style, - prop, - caller, - ReactPropTypeLocationNames.prop, - null, - ReactPropTypesSecret - ); - if (error) { - styleError(error.message, style, caller); - } + } + const error = allStylePropTypes[prop]( + style, + prop, + caller, + 'prop', + null, + ReactPropTypesSecret + ); + if (error) { + styleError(error.message, style, caller); } } } static validateStyle(name, styles) { if (process.env.NODE_ENV !== 'production') { - for (var prop in styles[name]) { + for (const prop in styles[name]) { StyleSheetValidation.validateStyleProp(prop, styles[name], 'StyleSheet ' + name); } } } static addValidStylePropTypes(stylePropTypes) { - for (var key in stylePropTypes) { + for (const key in stylePropTypes) { allStylePropTypes[key] = stylePropTypes[key]; } } } -var styleError = function(message1, style, caller?, message2?) { +const styleError = function(message1, style, caller?, message2?) { warning( false, message1 + @@ -68,7 +74,7 @@ var styleError = function(message1, style, caller?, message2?) { ); }; -var allStylePropTypes = {}; +const allStylePropTypes = {}; StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes); StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes); diff --git a/src/components/Touchable/TouchableOpacity.js b/src/components/Touchable/TouchableOpacity.js index 6b2ad224..c825d640 100644 --- a/src/components/Touchable/TouchableOpacity.js +++ b/src/components/Touchable/TouchableOpacity.js @@ -53,7 +53,6 @@ var PRESS_RETENTION_OFFSET = { top: 20, left: 20, right: 20, bottom: 30 }; * ``` */ var TouchableOpacity = createReactClass({ - displayName: 'TouchableOpacity', mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin], propTypes: { diff --git a/src/propTypes/ColorPropType.js b/src/propTypes/ColorPropType.js index 28ce847d..9c5059b3 100644 --- a/src/propTypes/ColorPropType.js +++ b/src/propTypes/ColorPropType.js @@ -1,25 +1,23 @@ -/* eslint-disable */ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ColorPropType - */ + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ColorPropType + * @flow + */ -var colorPropType = function(isRequired, props, propName, componentName, location, propFullName) { - var normalizeColor = require('normalize-css-color'); - var ReactPropTypeLocationNames = require('../vendor/ReactPropTypeLocationNames'); - var color = props[propName]; +const colorPropType = function(isRequired, props, propName, componentName, location, propFullName) { + const normalizeColor = require('normalize-css-color'); + const color = props[propName]; if (color === undefined || color === null) { if (isRequired) { - var locationName = ReactPropTypeLocationNames[location]; return new Error( 'Required ' + - locationName + + location + ' `' + (propFullName || propName) + '` was not specified in `' + @@ -42,10 +40,9 @@ var colorPropType = function(isRequired, props, propName, componentName, locatio } if (normalizeColor(color) === null) { - var locationName = ReactPropTypeLocationNames[location]; return new Error( 'Invalid ' + - locationName + + location + ' `' + (propFullName || propName) + '` supplied to `' + @@ -70,11 +67,13 @@ var colorPropType = function(isRequired, props, propName, componentName, locatio } }; +let ColorPropType; + if (process.env.NODE_ENV !== 'production') { - var ColorPropType = colorPropType.bind(null, false /* isRequired */); + ColorPropType = colorPropType.bind(null, false /* isRequired */); ColorPropType.isRequired = colorPropType.bind(null, true /* isRequired */); } else { - var ColorPropType = function() {}; + ColorPropType = function() {}; } module.exports = ColorPropType; diff --git a/src/vendor/ReactPropTypeLocationNames/index.js b/src/vendor/ReactPropTypeLocationNames/index.js deleted file mode 100644 index b754727e..00000000 --- a/src/vendor/ReactPropTypeLocationNames/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -let ReactPropTypeLocationNames = {}; - -if (process.env.NODE_ENV !== 'production') { - ReactPropTypeLocationNames = { - prop: 'prop', - context: 'context', - childContext: 'child context' - }; -} - -module.exports = ReactPropTypeLocationNames; diff --git a/src/vendor/ReactPropTypesSecret/index.js b/src/vendor/ReactPropTypesSecret/index.js deleted file mode 100644 index 64c31f90..00000000 --- a/src/vendor/ReactPropTypesSecret/index.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; -module.exports = ReactPropTypesSecret;