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

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-parser - npm Package Compare versions

Comparing version 8.7.0 to 8.8.0

4

dist/index.d.ts

@@ -97,3 +97,3 @@ import EventEmitter from "events";

defaultNamespace?: string;
defaultValue?: string | ((locale?: string, namespace?: string, key?: string) => string);
defaultValue?: string | ((locale?: string, namespace?: string, key?: string, value?: string) => string);
indentation?: number;

@@ -121,4 +121,2 @@ keepRemoved?: boolean | readonly RegExp[];

sort?: boolean | ((a: string, b: string) => -1 | 0 | 1);
skipDefaultValues?: boolean | ((locale?: string, namespace?: string) => boolean);
useKeysAsDefaultValue?: boolean | ((locale?: string, namespace?: string) => boolean);
verbose?: boolean;

@@ -125,0 +123,0 @@ failOnWarnings?: boolean;

@@ -211,5 +211,12 @@ import _typeof from "@babel/runtime/helpers/typeof";import _defineProperty from "@babel/runtime/helpers/defineProperty";import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";import _classCallCheck from "@babel/runtime/helpers/classCallCheck";import _createClass from "@babel/runtime/helpers/createClass";import _inherits from "@babel/runtime/helpers/inherits";import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";function _createForOfIteratorHelper(o, allowArrayLike) {var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];if (!it) {if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {if (it) o = it;var i = 0;var F = function F() {};return { s: F, n: function n() {if (i >= o.length) return { done: true };return { done: false, value: o[i++] };}, e: function e(_e) {throw _e;}, f: F };}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion = true,didErr = false,err;return { s: function s() {it = it.call(o);}, n: function n() {var step = it.next();normalCompletion = step.done;return step;}, e: function e(_e2) {didErr = true;err = _e2;}, f: function f() {try {if (!normalCompletion && it["return"] != null) it["return"]();} finally {if (didErr) throw err;}} };}function _unsupportedIterableToArray(o, minLen) {if (!o) return;if (typeof o === "string") return _arrayLikeToArray(o, minLen);var n = Object.prototype.toString.call(o).slice(8, -1);if (n === "Object" && o.constructor) n = o.constructor.name;if (n === "Map" || n === "Set") return Array.from(o);if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);}function _arrayLikeToArray(arr, len) {if (len == null || len > arr.length) len = arr.length;for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];return arr2;}function ownKeys(object, enumerableOnly) {var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {var symbols = Object.getOwnPropertySymbols(object);enumerableOnly && (symbols = symbols.filter(function (sym) {return Object.getOwnPropertyDescriptor(object, sym).enumerable;})), keys.push.apply(keys, symbols);}return keys;}function _objectSpread(target) {for (var i = 1; i < arguments.length; i++) {var source = null != arguments[i] ? arguments[i] : {};i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {_defineProperty(target, key, source[key]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));});}return target;}function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !Reflect.construct) return false;if (Reflect.construct.sham) return false;if (typeof Proxy === "function") return true;try {Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));return true;} catch (e) {return false;}}import BaseLexer from './base-lexer.js';

var isTranslationFunction =
// If the expression is a string literal, we can just check if it's in the
// list of functions
node.expression.text && this.functions.includes(node.expression.text) ||
// Support the case where the function is contained in a namespace, i.e.
// match `i18n.t()` when this.functions = ['t'].
node.expression.name &&
this.functions.includes(node.expression.name.text);
this.functions.includes(node.expression.name.text) ||
// Support matching the namespace as well, i.e. match `i18n.t()` but _not_
// `l10n.t()` when this.functions = ['i18n.t']
this.functions.includes(this.expressionToName(node.expression));

@@ -379,3 +386,23 @@ if (isTranslationFunction) {

return string;
}
/**
* Recursively computes the name of a dot-separated expression, e.g. `t` or `t.ns`
* @type {(expression: ts.LeftHandSideExpression | ts.JsxTagNameExpression) => string}
*/ }, { key: "expressionToName", value:
function expressionToName(expression) {
if (expression) {
if (expression.text) {
return expression.text;
} else if (expression.name) {
return [
this.expressionToName(expression.expression),
this.expressionToName(expression.name)].
filter(function (s) {return s && s.length > 0;}).
join('.');
}
}
return undefined;
} }]);return JavascriptLexer;}(BaseLexer);export { JavascriptLexer as default };
//# sourceMappingURL=javascript-lexer.js.map

@@ -84,2 +84,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";import _createClass from "@babel/runtime/helpers/createClass";import _inherits from "@babel/runtime/helpers/inherits";import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _isNativeReflectConstruct() {if (typeof Reflect === "undefined" || !Reflect.construct) return false;if (Reflect.construct.sham) return false;if (typeof Proxy === "function") return true;try {Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));return true;} catch (e) {return false;}}import JavascriptLexer from './javascript-lexer.js';

);
return undefined;

@@ -95,3 +96,5 @@ }

if (this.componentFunctions.includes(tagNode.tagName.text)) {
if (
this.componentFunctions.includes(this.expressionToName(tagNode.tagName)))
{
var entry = {};

@@ -180,3 +183,8 @@ entry.key = getKey(tagNode);

function nodeToString(node, sourceText) {var _this4 = this;
var children = this.parseChildren.call(this, node.children, sourceText);
var children = this.parseChildren.call(
this,
node,
node.children,
sourceText
);

@@ -215,3 +223,3 @@ var elemsToString = function elemsToString(children) {return (

function parseChildren() {var _this5 = this;var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];var sourceText = arguments.length > 1 ? arguments[1] : undefined;
function parseChildren(node) {var _this5 = this;var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];var sourceText = arguments.length > 2 ? arguments[2] : undefined;
return children.

@@ -232,3 +240,5 @@ map(function (child) {

var hasDynamicChildren = element.attributes.properties.find(
function (prop) {return prop.name.escapedText === 'i18nIsDynamicList';}
function (prop) {return (
prop.kind === ts.SyntaxKind.JsxAttribute &&
prop.name.escapedText === 'i18nIsDynamicList');}
);

@@ -239,3 +249,3 @@ return {

[] :
_this5.parseChildren(child.children, sourceText),
_this5.parseChildren(child, child.children, sourceText),
name: name,

@@ -336,4 +346,14 @@ isBasic: isBasic,

_this5.emit('warning', "Child is not literal: ".concat(slicedExpression));
var tagNode = node.openingElement || node;
var attrValues = tagNode.attributes.properties.
filter(function (attr) {var _attr$name;return [_this5.attr, 'defaults'].includes((_attr$name = attr.name) === null || _attr$name === void 0 ? void 0 : _attr$name.text);}).
map(
function (attr) {var _attr$initializer$exp, _attr$initializer$exp2;return (_attr$initializer$exp = (_attr$initializer$exp2 =
attr.initializer.expression) === null || _attr$initializer$exp2 === void 0 ? void 0 : _attr$initializer$exp2.text) !== null && _attr$initializer$exp !== void 0 ? _attr$initializer$exp : attr.initializer.text;}
);
if (attrValues.some(function (attr) {return !attr;})) {
_this5.emit('warning', "Child is not literal: ".concat(slicedExpression));
}
return {

@@ -340,0 +360,0 @@ type: 'js',

{
"name": "i18next-parser",
"description": "Command Line tool for i18next",
"version": "8.7.0",
"version": "8.8.0",
"type": "module",

@@ -67,3 +67,3 @@ "license": "MIT",

"p-event": "^6.0.0",
"prettier": "3.0.1",
"prettier": "3.0.3",
"sinon": "^15.0.1"

@@ -70,0 +70,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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