react-i18n-mini-parser
Advanced tools
Comparing version
@@ -11,3 +11,3 @@ "use strict"; | ||
sources | ||
.map(source => parser_1.parse(source, options)) | ||
.map(source => (0, parser_1.parse)(source, options)) | ||
.forEach((arr) => { | ||
@@ -27,5 +27,5 @@ arr.forEach((item) => { | ||
}); | ||
return { messages: utils_1.sort(messages), errors }; | ||
return { messages: (0, utils_1.sort)(messages), errors }; | ||
} | ||
exports.extract = extract; | ||
//# sourceMappingURL=index.js.map |
@@ -38,3 +38,3 @@ "use strict"; | ||
: initializer; | ||
if (utils_1.isString(node)) { | ||
if ((0, utils_1.isString)(node)) { | ||
extract(name.text, node.text); | ||
@@ -44,3 +44,3 @@ continue; | ||
if (typescript_1.default.isBinaryExpression(node)) { | ||
const [result, isStatic] = utils_1.concatString(node); | ||
const [result, isStatic] = (0, utils_1.concatString)(node); | ||
if (isStatic) | ||
@@ -51,4 +51,4 @@ extract(name.text, result); | ||
} | ||
if (id && message) | ||
options.onMessageFound({ id, message }); | ||
if (message) | ||
options.onMessageFound({ id: id || message, message }); | ||
} | ||
@@ -62,7 +62,11 @@ function extractMessagesFromDefine(properties, options) { | ||
function extractFromCall(node, options) { | ||
const funcName = utils_1.getName(node); | ||
const funcName = (0, utils_1.getName)(node); | ||
const { translateNames, defineFunctionNames } = options; | ||
if (translateNames.includes(funcName) || defineFunctionNames.includes(funcName)) { | ||
const argument = node.arguments[0]; | ||
if (argument && typescript_1.default.isObjectLiteralExpression(argument)) { | ||
if (!argument) | ||
return; | ||
if ((0, utils_1.isString)(argument)) | ||
options.onMessageFound({ id: argument.text, message: argument.text }); | ||
else if (typescript_1.default.isObjectLiteralExpression(argument)) { | ||
if (defineFunctionNames.includes(funcName)) | ||
@@ -76,3 +80,3 @@ extractMessagesFromDefine(argument.properties, options); | ||
function extractFromJSX(node, options) { | ||
if (options.translateNames.includes(utils_1.getName(node))) { | ||
if (options.translateNames.includes((0, utils_1.getName)(node))) { | ||
extractMessageFromProps(node.attributes.properties, options); | ||
@@ -85,3 +89,3 @@ } | ||
extractFromCall(node, options); | ||
else if (utils_1.isJsx(node)) | ||
else if ((0, utils_1.isJsx)(node)) | ||
extractFromJSX(node, options); | ||
@@ -88,0 +92,0 @@ return typescript_1.default.visitEachChild(node, visitor, context); |
{ | ||
"name": "react-i18n-mini-parser", | ||
"version": "0.5.0", | ||
"version": "1.0.0", | ||
"description": "NodeJS module for extracting default i18n messages from a project files where using react-i18n-mini.", | ||
@@ -38,9 +38,9 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "26.0.23", | ||
"jest": "27.0.6", | ||
"ts-jest": "27.0.3" | ||
"@types/jest": "27.0.3", | ||
"jest": "27.3.1", | ||
"ts-jest": "27.0.7" | ||
}, | ||
"dependencies": { | ||
"typescript": "4.3.5" | ||
"typescript": "4.5.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18298
2.3%226
1.8%0
-100%+ Added
- Removed
Updated