Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-i18next-extract

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-i18next-extract - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

11

lib/index.es.js

@@ -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 @@ });

4

package.json
{
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc