🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

babel-plugin-transform-react-remove-prop-types

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-remove-prop-types - npm Package Compare versions

Comparing version

to
0.3.0

17

lib/index.js

@@ -107,2 +107,19 @@ 'use strict';

}
},
MemberExpression: function MemberExpression(path) {
var node = path.node,
scope = path.scope;
if (node.property.name === 'propTypes') {
var binding = scope.getBinding(node.object.name);
if (!binding) {
return;
}
if (['ImportDefaultSpecifier', 'ImportSpecifier'].indexOf(binding.path.node.type) !== -1) {
throw path.buildCodeFrameError('You are accessing the propTypes from an imported Identifier.\n' + 'It\'s likely to break at runtime. Instead, import the propTypes.\n' + 'For more details, have a look at this issue: https://goo.gl/sHDdUk.');
}
}
}

@@ -109,0 +126,0 @@ });

3

package.json
{
"name": "babel-plugin-transform-react-remove-prop-types",
"version": "0.2.12",
"version": "0.3.0",
"description": "Remove unnecessary React propTypes from the production build",

@@ -53,4 +53,5 @@ "main": "lib/index.js",

"nodemon": "^1.11.0",
"path-exists": "^3.0.0",
"pkgfiles": "^2.3.2"
}
}

@@ -219,2 +219,23 @@ // @flow weak

},
MemberExpression(path) {
const {
node,
scope,
} = path;
if (node.property.name === 'propTypes') {
const binding = scope.getBinding(node.object.name);
if (!binding) {
return;
}
if (['ImportDefaultSpecifier', 'ImportSpecifier'].indexOf(binding.path.node.type) !== -1) {
throw path.buildCodeFrameError(
'You are accessing the propTypes from an imported Identifier.\n' +
'It\'s likely to break at runtime. Instead, import the propTypes.\n' +
'For more details, have a look at this issue: https://goo.gl/sHDdUk.');
}
}
},
});

@@ -221,0 +242,0 @@ },