Repository: brigand/babel-plugin-flow-react-proptypes
Pull request #81 (2017-04-26 12:43:15)

Update remaining react PropTypes


Patch:
diff --git a/src/index.js b/src/index.js
index 2db5b36..959ddbc 100644
--- a/src/index.js
+++ b/src/index.js
@@ -236,12 +236,9 @@ module.exports = function flowReactPropTypes(babel) {
         if (propTypesAst.type === 'ObjectExpression') {
           propTypesAst = t.callExpression(
             t.memberExpression(
-              t.memberExpression(
-                t.callExpression(
-                  t.identifier('require'),
-                  [t.stringLiteral('react')]
-                ),
-                t.identifier('PropTypes')
+              t.callExpression(
+                t.identifier('require'),
+                [t.stringLiteral('prop-types')]
               ),
               t.identifier('shape'),
             ),
@@ -301,14 +298,9 @@ module.exports = function flowReactPropTypes(babel) {
                       t.identifier(getExportNameForType(typeName))
                     ),
                     t.memberExpression(
-                      t.memberExpression(
-                        t.callExpression(
-                          t.identifier('require'),
-                          [
-                            t.stringLiteral('react'),
-                          ]
-                        ),
-                        t.identifier('PropTypes')
+                      t.callExpression(
+                        t.identifier('require'),
+                        [t.stringLiteral('prop-types')]
                       ),
                       t.identifier('any')
                     )


Test patch:
diff --git a/src/__tests__/__snapshots__/class-inline-props-test.js.snap b/src/__tests__/__snapshots__/class-inline-props-test.js.snap
index 4fff006..c6c9fbf 100644
--- a/src/__tests__/__snapshots__/class-inline-props-test.js.snap
+++ b/src/__tests__/__snapshots__/class-inline-props-test.js.snap
@@ -15,7 +15,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== \"function\
 
 var React = require(\'react\');
 
-var babelPluginFlowReactPropTypes_proptype_ExternalType = require(\'../types\').babelPluginFlowReactPropTypes_proptype_ExternalType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_ExternalType = require(\'../types\').babelPluginFlowReactPropTypes_proptype_ExternalType || require(\'prop-types\').any;
 
 var Foo = function (_React$Component) {
   _inherits(Foo, _React$Component);
diff --git a/src/__tests__/__snapshots__/export-object-test.js.snap b/src/__tests__/__snapshots__/export-object-test.js.snap
index deea085..1e8425e 100644
--- a/src/__tests__/__snapshots__/export-object-test.js.snap
+++ b/src/__tests__/__snapshots__/export-object-test.js.snap
@@ -2,7 +2,7 @@ exports[`test export-object 1`] = `
 "\'use strict\';
 
 if (typeof exports !== \'undefined\') Object.defineProperty(exports, \'babelPluginFlowReactPropTypes_proptype_Foo\', {
-  value: require(\'react\').PropTypes.shape({
+  value: require(\'prop-types\').shape({
     a_string: require(\'prop-types\').string.isRequired
   })
 });
diff --git a/src/__tests__/__snapshots__/export-type-and-component-test.js.snap b/src/__tests__/__snapshots__/export-type-and-component-test.js.snap
index f15bfed..0b18d66 100644
--- a/src/__tests__/__snapshots__/export-type-and-component-test.js.snap
+++ b/src/__tests__/__snapshots__/export-type-and-component-test.js.snap
@@ -12,7 +12,7 @@ var _react2 = _interopRequireDefault(_react);
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
 if (typeof exports !== \'undefined\') Object.defineProperty(exports, \'babelPluginFlowReactPropTypes_proptype_T\', {
-  value: require(\'react\').PropTypes.shape({
+  value: require(\'prop-types\').shape({
     f: require(\'prop-types\').func.isRequired,
     i: require(\'prop-types\').number.isRequired,
     x: require(\'prop-types\').oneOf([\'foo\', \'baz\']).isRequired
diff --git a/src/__tests__/__snapshots__/import-and-loops-test.js.snap b/src/__tests__/__snapshots__/import-and-loops-test.js.snap
index 03e720d..4fd8c58 100644
--- a/src/__tests__/__snapshots__/import-and-loops-test.js.snap
+++ b/src/__tests__/__snapshots__/import-and-loops-test.js.snap
@@ -11,10 +11,10 @@ var _react2 = _interopRequireDefault(_react);
 
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
-var babelPluginFlowReactPropTypes_proptype_ExternalType = require(\'../types\').babelPluginFlowReactPropTypes_proptype_ExternalType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_ExternalType = require(\'../types\').babelPluginFlowReactPropTypes_proptype_ExternalType || require(\'prop-types\').any;
 
 if (typeof exports !== \'undefined\') Object.defineProperty(exports, \'babelPluginFlowReactPropTypes_proptype_T\', {
-    value: require(\'react\').PropTypes.shape({
+    value: require(\'prop-types\').shape({
         flag: require(\'prop-types\').bool.isRequired,
         list: require(\'prop-types\').arrayOf(babelPluginFlowReactPropTypes_proptype_ExternalType).isRequired
     })
diff --git a/src/__tests__/__snapshots__/import-non-relative.js.snap b/src/__tests__/__snapshots__/import-non-relative.js.snap
index 73ab2c9..a15474c 100644
--- a/src/__tests__/__snapshots__/import-non-relative.js.snap
+++ b/src/__tests__/__snapshots__/import-non-relative.js.snap
@@ -7,9 +7,9 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
 
 function _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
-var babelPluginFlowReactPropTypes_proptype_NamedType = require(\'foo\').babelPluginFlowReactPropTypes_proptype_NamedType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_NamedType = require(\'foo\').babelPluginFlowReactPropTypes_proptype_NamedType || require(\'prop-types\').any;
 
-var babelPluginFlowReactPropTypes_proptype_DefaultType = require(\'bar\').babelPluginFlowReactPropTypes_proptype_DefaultType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_DefaultType = require(\'bar\').babelPluginFlowReactPropTypes_proptype_DefaultType || require(\'prop-types\').any;
 
 var C = function (_React$Component) {
   _inherits(C, _React$Component);
diff --git a/src/__tests__/__snapshots__/import-object-test.js.snap b/src/__tests__/__snapshots__/import-object-test.js.snap
index 42c4c95..ddc62e7 100644
--- a/src/__tests__/__snapshots__/import-object-test.js.snap
+++ b/src/__tests__/__snapshots__/import-object-test.js.snap
@@ -7,9 +7,9 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
 
 function _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
-var babelPluginFlowReactPropTypes_proptype_NamedType = require(\'./foo\').babelPluginFlowReactPropTypes_proptype_NamedType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_NamedType = require(\'./foo\').babelPluginFlowReactPropTypes_proptype_NamedType || require(\'prop-types\').any;
 
-var babelPluginFlowReactPropTypes_proptype_DefaultType = require(\'./bar\').babelPluginFlowReactPropTypes_proptype_DefaultType || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_DefaultType = require(\'./bar\').babelPluginFlowReactPropTypes_proptype_DefaultType || require(\'prop-types\').any;
 
 var C = function (_React$Component) {
   _inherits(C, _React$Component);
diff --git a/src/__tests__/__snapshots__/intersection-export-test.js.snap b/src/__tests__/__snapshots__/intersection-export-test.js.snap
index faadc75..c4b34e8 100644
--- a/src/__tests__/__snapshots__/intersection-export-test.js.snap
+++ b/src/__tests__/__snapshots__/intersection-export-test.js.snap
@@ -13,10 +13,10 @@ function _inherits(subClass, superClass) { if (typeof superClass !== \"function\
 
 var React = require(\'react\');
 
-var babelPluginFlowReactPropTypes_proptype_T = require(\'./T\').babelPluginFlowReactPropTypes_proptype_T || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_T = require(\'./T\').babelPluginFlowReactPropTypes_proptype_T || require(\'prop-types\').any;
 
 if (typeof exports !== \'undefined\') Object.defineProperty(exports, \'babelPluginFlowReactPropTypes_proptype_U\', {
-  value: require(\'react\').PropTypes.shape({
+  value: require(\'prop-types\').shape({
     foo: require(\'prop-types\').string.isRequired
   })
 });
diff --git a/src/__tests__/__snapshots__/stateless-inline-imports-test.js.snap b/src/__tests__/__snapshots__/stateless-inline-imports-test.js.snap
index 959a152..43a4a3f 100644
--- a/src/__tests__/__snapshots__/stateless-inline-imports-test.js.snap
+++ b/src/__tests__/__snapshots__/stateless-inline-imports-test.js.snap
@@ -7,7 +7,7 @@ var _react2 = _interopRequireDefault(_react);
 
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
-var babelPluginFlowReactPropTypes_proptype_T = require(\'../types\').babelPluginFlowReactPropTypes_proptype_T || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_T = require(\'../types\').babelPluginFlowReactPropTypes_proptype_T || require(\'prop-types\').any;
 
 var C = function C(props) {
   _react2.default.createElement(
diff --git a/src/__tests__/__snapshots__/top-level-import-test.js.snap b/src/__tests__/__snapshots__/top-level-import-test.js.snap
index dd0463a..2f20e05 100644
--- a/src/__tests__/__snapshots__/top-level-import-test.js.snap
+++ b/src/__tests__/__snapshots__/top-level-import-test.js.snap
@@ -19,7 +19,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
 
 function _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
-var babelPluginFlowReactPropTypes_proptype_Data = require(\'types\').babelPluginFlowReactPropTypes_proptype_Data || require(\'react\').PropTypes.any;
+var babelPluginFlowReactPropTypes_proptype_Data = require(\'types\').babelPluginFlowReactPropTypes_proptype_Data || require(\'prop-types\').any;
 
 var Test = function (_Component) {
   _inherits(Test, _Component);
diff --git a/src/__tests__/__snapshots__/typeof-test.js.snap b/src/__tests__/__snapshots__/typeof-test.js.snap
index 8217053..e6e7de4 100644
--- a/src/__tests__/__snapshots__/typeof-test.js.snap
+++ b/src/__tests__/__snapshots__/typeof-test.js.snap
@@ -6,7 +6,7 @@ var ActionTypes = {
 };
 
 if (typeof exports !== \'undefined\') Object.defineProperty(exports, \'babelPluginFlowReactPropTypes_proptype_JumpToAction\', {
-  value: require(\'react\').PropTypes.shape({
+  value: require(\'prop-types\').shape({
     type: require(\'prop-types\').any.isRequired,
     index: require(\'prop-types\').number.isRequired
   })