babel-plugin-i18next-extract
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,3 @@ import i18next from 'i18next'; | ||
import path from 'path'; | ||
import stringify from 'json-stable-stringify'; | ||
@@ -611,4 +612,10 @@ const COMMENT_HINT_PREFIX = 'i18next-extract-'; | ||
return null; | ||
const bindings = path.parentPath.scope.bindings[functionIdentifier.node.name]; | ||
// Likely an anonymous function not in a normal scope. | ||
// e.g. "['foo', function myFunction() { return 'foo'; }]" | ||
// Let's just ignore such case. | ||
if (!bindings) | ||
return null; | ||
// Try to find a withTranslation() call in parent scope | ||
for (const refPath of path.parentPath.scope.bindings[functionIdentifier.node.name].referencePaths) { | ||
for (const refPath of bindings.referencePaths) { | ||
const callExpr = refPath.findParent(parentPath => { | ||
@@ -1309,3 +1316,3 @@ if (!parentPath.isCallExpression()) | ||
fs.mkdirSync(directoryPath, { recursive: true }); | ||
fs.writeFileSync(filePath, JSON.stringify(deepTranslationFile, null, config.jsonSpace), { | ||
fs.writeFileSync(filePath, stringify(deepTranslationFile, { space: config.jsonSpace }), { | ||
encoding: 'utf8', | ||
@@ -1312,0 +1319,0 @@ }); |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var path = _interopDefault(require('path')); | ||
var stringify = _interopDefault(require('json-stable-stringify')); | ||
@@ -615,4 +616,10 @@ const COMMENT_HINT_PREFIX = 'i18next-extract-'; | ||
return null; | ||
const bindings = path.parentPath.scope.bindings[functionIdentifier.node.name]; | ||
// Likely an anonymous function not in a normal scope. | ||
// e.g. "['foo', function myFunction() { return 'foo'; }]" | ||
// Let's just ignore such case. | ||
if (!bindings) | ||
return null; | ||
// Try to find a withTranslation() call in parent scope | ||
for (const refPath of path.parentPath.scope.bindings[functionIdentifier.node.name].referencePaths) { | ||
for (const refPath of bindings.referencePaths) { | ||
const callExpr = refPath.findParent(parentPath => { | ||
@@ -1313,3 +1320,3 @@ if (!parentPath.isCallExpression()) | ||
fs.mkdirSync(directoryPath, { recursive: true }); | ||
fs.writeFileSync(filePath, JSON.stringify(deepTranslationFile, null, config.jsonSpace), { | ||
fs.writeFileSync(filePath, stringify(deepTranslationFile, { space: config.jsonSpace }), { | ||
encoding: 'utf8', | ||
@@ -1316,0 +1323,0 @@ }); |
{ | ||
"name": "babel-plugin-i18next-extract", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Statically extract translation keys from i18next application.", | ||
@@ -40,2 +40,3 @@ "repository": { | ||
"i18next": "^17.0.4", | ||
"json-stable-stringify": "^1.0.1", | ||
"node": "^12.4.0" | ||
@@ -51,2 +52,3 @@ }, | ||
"@types/jest-expect-message": "^1.0.0", | ||
"@types/json-stable-stringify": "^1.0.32", | ||
"@types/rimraf": "^2.0.2", | ||
@@ -53,0 +55,0 @@ "@typescript-eslint/eslint-plugin": "^1.10.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133812
3182
8
23
+ Addedjson-stable-stringify@^1.0.1
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcaniuse-lite@1.0.30001688(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.0(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjson-stable-stringify@1.1.1(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedmath-intrinsics@1.0.0(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
- Removedcaniuse-lite@1.0.30001689(transitive)