New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsx-i18n

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-i18n - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

temp.js

2

index.js

@@ -1,1 +0,1 @@

exports.visitorList = require('./transforms/react').visitorList;
module.exports = require('./transforms/react');
{
"name": "jsx-i18n",
"version": "0.0.0",
"version": "0.0.1",
"dependencies": {
"esprima-fb": "~6001.1001.0-dev-harmony-fb",
"jstransform": "~6.3.2"
"jstransform": "~6.3.2",
"react-tools": "^0.12.0"
},
"main": "index.js"
"main": "index.js",
"description": "Simple [jstransform](https://github.com/facebook/jstransform) pass for use with the JSX transformer in React 0.12+ to convert JSX `<$_>...</$_>` tags (only) to `$_(...)` calls, to simulate how React 0.11 behaved.",
"devDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/Khan/jsx-i18n.git"
},
"author": "Ben Alpert",
"license": "MIT",
"bugs": {
"url": "https://github.com/Khan/jsx-i18n/issues"
},
"homepage": "https://github.com/Khan/jsx-i18n"
}

@@ -24,3 +24,5 @@ # jsx-i18n

process.stdin.on("end", function() {
var visitorList = jsxI18n.visitorList.concat(visitors.getAllVisitors());
var visitorList = jsxI18n.getVisitorList([
"$_"
]).concat(visitors.getAllVisitors());
js = jstransform.transform(visitorList, js).code;

@@ -36,6 +38,6 @@

// in
var x = <div><$_ name={WORLD}>hello %(name)s</$_></div>;
var x = <div><$_ name={world}>hello %(name)s</$_></div>;
// out
var x = React.createElement("div", null, $_({name: "WORLD"}, "hello %(name)s"));
var x = React.createElement("div", null, $_({name: world}, "hello %(name)s"));
```

@@ -71,3 +71,3 @@ /**

if (hasAtLeastOneSpreadProperty) {
utils.append('Object.assign({', state);
utils.append('React.__spread({', state);
} else if (hasAttributes) {

@@ -227,12 +227,40 @@ utils.append('{', state);

visitReactTag.test = function(object, path, state) {
if (object.type === Syntax.XJSElement) {
var openingElement = object.openingElement;
var nameObject = openingElement.name;
return nameObject.type === Syntax.XJSIdentifier && nameObject.name === "$_";
var getVisitorList = function(i18nFuncList) {
var i18nTestHash = {};
for (var i = 0; i < i18nFuncList.length; i++) {
i18nTestHash["__i18n__" + i18nFuncList[i]] = true;
}
var visitor = function(traverse, object, path, state) {
return visitReactTag(traverse, object, path, state);
};
visitor.test = function(object, path, state) {
if (object.type === Syntax.XJSElement) {
var openingElement = object.openingElement;
var nameObject = openingElement.name;
return nameObject.type === Syntax.XJSIdentifier &&
i18nTestHash["__i18n__" + nameObject.name];
}
};
return [visitor];
};
exports.visitorList = [
visitReactTag
];
/**
* Takes an array of i18n function names as strings,
* and returns an array of visitors.
*
* getVisitorList(["$_", "$i18nDoNotTranslate"])
* => [<visitor>]
*/
exports.getVisitorList = getVisitorList;
/**
* deprecated: visitorList
*
* For backwards compatibility, this returns the list with just
* the i18n function `$_`
*/
exports.visitorList = getVisitorList(["$_"]);
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