babel-plugin-jsx-rename
Advanced tools
Comparing version
@@ -24,2 +24,8 @@ "use strict"; | ||
function toHump(name) { | ||
return name.replace(/\-(\w)/g, function (all, letter) { | ||
return letter.toUpperCase(); | ||
}); | ||
} | ||
var _default = (0, _helperPluginUtils.declare)((api, options) => { | ||
@@ -69,3 +75,4 @@ api.assertVersion(7); | ||
const tagName = namePath.node.name; | ||
const transferTagName = tagName.replace(/^\S/, s => s.toUpperCase()); | ||
let transferTagName = toHump(tagName); | ||
transferTagName = transferTagName.replace(/^\S/, s => s.toUpperCase()); | ||
namePath.replaceWith((0, _types.jsxIdentifier)(`${prefix}${transferTagName}`)); | ||
@@ -72,0 +79,0 @@ this.renameComponentCache.add(`${prefix}${transferTagName}`); |
{ | ||
"name": "babel-plugin-jsx-rename", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -17,2 +17,9 @@ import { declare } from "@babel/helper-plugin-utils"; | ||
function toHump(name) { | ||
return name.replace(/\-(\w)/g, function (all, letter) { | ||
return letter.toUpperCase(); | ||
}); | ||
} | ||
export default declare((api, options) => { | ||
@@ -54,3 +61,4 @@ api.assertVersion(7); | ||
const tagName = namePath.node.name; | ||
const transferTagName = tagName.replace(/^\S/, s => s.toUpperCase()); | ||
let transferTagName = toHump(tagName); | ||
transferTagName = transferTagName.replace(/^\S/, s => s.toUpperCase()); | ||
namePath.replaceWith( | ||
@@ -57,0 +65,0 @@ jsxIdentifier(`${prefix}${transferTagName}`) |
5559
7.11%129
10.26%