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

@formatjs/ts-transformer

Package Overview
Dependencies
Maintainers
3
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/ts-transformer - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

tests/fixtures/extractFromFormatMessageStateless.tsx

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.1.7](https://github.com/formatjs/formatjs/compare/@formatjs/ts-transformer@1.1.6...@formatjs/ts-transformer@1.1.7) (2020-05-06)
### Bug Fixes
* **@formatjs/ts-transformer:** expand extraction to `formatMessage()` as well ([146f1d3](https://github.com/formatjs/formatjs/commit/146f1d39fe0f42cba04dc25c391d03a5fbb39d28))
## 1.1.6 (2020-04-28)

@@ -8,0 +19,0 @@

23

dist/transform.js

@@ -81,3 +81,3 @@ "use strict";

// We extracted nothing
if (!Object.keys(msg).length) {
if (!Object.entries(msg).find(([_, v]) => v)) {
return;

@@ -104,12 +104,19 @@ }

}
/**
* Check if node is `intl.formatMessage` node
* @param node
* @param sf
*/
function isIntlFormatMessageCall(node, sf) {
const method = node.expression;
if (!ts.isPropertyAccessExpression(method)) {
return false;
// Handle intl.formatMessage()
if (ts.isPropertyAccessExpression(method)) {
return ((method.name.getText(sf) === 'formatMessage' &&
ts.isIdentifier(method.expression) &&
method.expression.getText(sf) === 'intl') ||
(ts.isPropertyAccessExpression(method.expression) &&
method.expression.name.getText(sf) === 'intl'));
}
return ((method.name.getText(sf) === 'formatMessage' &&
ts.isIdentifier(method.expression) &&
method.expression.getText(sf) === 'intl') ||
(ts.isPropertyAccessExpression(method.expression) &&
method.expression.name.getText(sf) === 'intl'));
// Handle formatMessage()
return ts.isIdentifier(method) && method.getText(sf) === 'formatMessage';
}

@@ -116,0 +123,0 @@ function extractMessageFromJsxComponent(node, program, sf, opts) {

{
"name": "@formatjs/ts-transformer",
"version": "1.1.6",
"version": "1.1.7",
"description": "TS Compiler transformer for formatjs",

@@ -39,3 +39,3 @@ "main": "dist/index.js",

},
"gitHead": "84e7cc6f3723801271661fdbdb5391fac7e6f74c"
"gitHead": "31693b2c2371274e2371bcf4e82700bcad53ca74"
}

@@ -177,3 +177,3 @@ import * as ts from 'typescript';

// We extracted nothing
if (!Object.keys(msg).length) {
if (!Object.entries(msg).find(([_, v]) => v)) {
return;

@@ -210,15 +210,23 @@ }

/**
* Check if node is `intl.formatMessage` node
* @param node
* @param sf
*/
function isIntlFormatMessageCall(node: ts.CallExpression, sf: ts.SourceFile) {
const method = node.expression;
if (!ts.isPropertyAccessExpression(method)) {
return false;
// Handle intl.formatMessage()
if (ts.isPropertyAccessExpression(method)) {
return (
(method.name.getText(sf) === 'formatMessage' &&
ts.isIdentifier(method.expression) &&
method.expression.getText(sf) === 'intl') ||
(ts.isPropertyAccessExpression(method.expression) &&
method.expression.name.getText(sf) === 'intl')
);
}
return (
(method.name.getText(sf) === 'formatMessage' &&
ts.isIdentifier(method.expression) &&
method.expression.getText(sf) === 'intl') ||
(ts.isPropertyAccessExpression(method.expression) &&
method.expression.name.getText(sf) === 'intl')
);
// Handle formatMessage()
return ts.isIdentifier(method) && method.getText(sf) === 'formatMessage';
}

@@ -225,0 +233,0 @@

@@ -14,2 +14,5 @@ import {join} from 'path';

},
extractFromFormatMessageStateless: {
extractFromFormatMessageCall: true,
},
extractSourceLocation: {

@@ -16,0 +19,0 @@ extractSourceLocation: true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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