From 6a8290bbfc628b07e04ad85315e3717d6ea64eb3 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Thu, 31 Aug 2017 18:39:39 +0530 Subject: [PATCH] added immutable propTypes --- utils/babel-plugin-js-to-immutable-prop-types.js | 6 ++++++ utils/babel-plugin-js-to-prop-types.js | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/utils/babel-plugin-js-to-immutable-prop-types.js b/utils/babel-plugin-js-to-immutable-prop-types.js index 1e6f9a2..557b907 100644 --- a/utils/babel-plugin-js-to-immutable-prop-types.js +++ b/utils/babel-plugin-js-to-immutable-prop-types.js @@ -68,6 +68,12 @@ export default function({ types: t }) { path.replaceWith(t.identifier("PropTypes.bool")); }, + VariableDeclaration(path) { + path.insertBefore(t.identifier(`import ImmutablePropTypes from 'react-immutable-proptypes' + import PropTypes from 'prop-types + `)) + }, + Program(path) { path.traverse({ enter(path) { diff --git a/utils/babel-plugin-js-to-prop-types.js b/utils/babel-plugin-js-to-prop-types.js index e330448..2454840 100644 --- a/utils/babel-plugin-js-to-prop-types.js +++ b/utils/babel-plugin-js-to-prop-types.js @@ -76,6 +76,13 @@ export default function({ types: t }) { }); }, + VariableDeclaration(path) { + path.insertBefore(t.identifier( + `import PropTypes from 'prop-types' + `)) + }, + + ObjectExpression(path) { if ( t.isVariableDeclarator(path.parent) ||