babel-plugin-react-pure-component
Advanced tools
+28
| /** | ||
| * Set the displayName of components created with react-pure-component | ||
| */ | ||
| 'use strict'; | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| exports['default'] = function (_ref) { | ||
| var Plugin = _ref.Plugin; | ||
| var t = _ref.types; | ||
| return new Plugin('pure-component', { | ||
| visitor: { | ||
| VariableDeclarator: function VariableDeclarator(node) { | ||
| if (node.init.type === 'CallExpression' && node.init.callee.type === 'Identifier' && node.init.callee.name === 'pure') { | ||
| var displayName = node.id.name; | ||
| return [node, t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier(displayName), t.identifier('displayName')), t.literal(displayName)))]; | ||
| } | ||
| return node; | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
| module.exports = exports['default']; |
+1
-1
| { | ||
| "name": "babel-plugin-react-pure-component", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Add displayName to components created with react-pure-component", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+1
-1
@@ -5,3 +5,3 @@ /** | ||
| export default function ({ Plugin, types: t }) { | ||
| return new Plugin('pure-component', { | ||
| return new Plugin('react-pure-component', { | ||
| visitor: { | ||
@@ -8,0 +8,0 @@ VariableDeclarator(node) { |
2073
64.52%3
50%54
68.75%