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

eslint-plugin-formatjs

Package Overview
Dependencies
Maintainers
3
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-formatjs - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

11

CHANGELOG.md

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

## [2.2.2](https://github.com/formatjs/formatjs/compare/eslint-plugin-formatjs@2.2.1...eslint-plugin-formatjs@2.2.2) (2020-04-25)
### Bug Fixes
* **eslint-plugin-formatjs:** rm hard dep on @typescript-eslint/typescript-estree, fix [#666](https://github.com/formatjs/formatjs/issues/666) ([ed40a8b](https://github.com/formatjs/formatjs/commit/ed40a8b366d370783fcf75e6c98dc6356a9aa03f))
## [2.2.1](https://github.com/formatjs/formatjs/compare/eslint-plugin-formatjs@2.2.0...eslint-plugin-formatjs@2.2.1) (2020-04-24)

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

49

dist/util.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
function isStringLiteral(node) {
return node.type === typescript_estree_1.AST_NODE_TYPES.Literal && typeof node.value === 'string';
return node.type === 'Literal' && typeof node.value === 'string';
}

@@ -11,13 +10,13 @@ function findReferenceImport(id, importedVars) {

function isIntlFormatMessageCall(node) {
return (node.type === typescript_estree_1.AST_NODE_TYPES.CallExpression &&
node.callee.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
return (node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'intl' &&
node.callee.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'formatMessage' &&
node.arguments.length >= 1 &&
node.arguments[0].type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression);
node.arguments[0].type === 'ObjectExpression');
}
function isSingleMessageDescriptorDeclaration(id, importedVars) {
if (id.type !== typescript_estree_1.AST_NODE_TYPES.Identifier) {
if (id.type !== 'Identifier') {
return false;

@@ -32,3 +31,3 @@ }

function isMultipleMessageDescriptorDeclaration(id, importedVars) {
if (id.type !== typescript_estree_1.AST_NODE_TYPES.Identifier) {
if (id.type !== 'Identifier') {
return false;

@@ -43,3 +42,3 @@ }

function extractMessageDescriptor(node) {
if (!node || node.type !== typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
if (!node || node.type !== 'ObjectExpression') {
return;

@@ -53,4 +52,3 @@ }

for (const prop of node.properties) {
if (prop.type !== typescript_estree_1.AST_NODE_TYPES.Property ||
prop.key.type !== typescript_estree_1.AST_NODE_TYPES.Identifier) {
if (prop.type !== 'Property' || prop.key.type !== 'Identifier') {
continue;

@@ -87,4 +85,3 @@ }

for (const prop of node.attributes) {
if (prop.type !== typescript_estree_1.AST_NODE_TYPES.JSXAttribute ||
prop.name.type !== typescript_estree_1.AST_NODE_TYPES.JSXIdentifier) {
if (prop.type !== 'JSXAttribute' || prop.name.type !== 'JSXIdentifier') {
continue;

@@ -96,3 +93,3 @@ }

result.messageNode = prop.value;
if (((_a = prop.value) === null || _a === void 0 ? void 0 : _a.type) === typescript_estree_1.AST_NODE_TYPES.Literal &&
if (((_a = prop.value) === null || _a === void 0 ? void 0 : _a.type) === 'Literal' &&
typeof prop.value.value === 'string') {

@@ -104,3 +101,3 @@ result.message.defaultMessage = prop.value.value;

result.descriptionNode = prop.value;
if (((_b = prop.value) === null || _b === void 0 ? void 0 : _b.type) === typescript_estree_1.AST_NODE_TYPES.Literal &&
if (((_b = prop.value) === null || _b === void 0 ? void 0 : _b.type) === 'Literal' &&
typeof prop.value.value === 'string') {

@@ -111,3 +108,3 @@ result.message.description = prop.value.value;

case 'id':
if (((_c = prop.value) === null || _c === void 0 ? void 0 : _c.type) === typescript_estree_1.AST_NODE_TYPES.Literal &&
if (((_c = prop.value) === null || _c === void 0 ? void 0 : _c.type) === 'Literal' &&
typeof prop.value.value === 'string') {

@@ -118,4 +115,4 @@ result.message.id = prop.value.value;

case 'values':
if (((_d = prop.value) === null || _d === void 0 ? void 0 : _d.type) === typescript_estree_1.AST_NODE_TYPES.JSXExpressionContainer &&
prop.value.expression.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
if (((_d = prop.value) === null || _d === void 0 ? void 0 : _d.type) === 'JSXExpressionContainer' &&
prop.value.expression.type === 'ObjectExpression') {
values = prop.value.expression;

@@ -132,5 +129,3 @@ }

function extractMessageDescriptors(node) {
if (!node ||
node.type !== typescript_estree_1.AST_NODE_TYPES.ObjectExpression ||
!node.properties.length) {
if (!node || node.type !== 'ObjectExpression' || !node.properties.length) {
return [];

@@ -140,7 +135,7 @@ }

for (const prop of node.properties) {
if (prop.type !== typescript_estree_1.AST_NODE_TYPES.Property) {
if (prop.type !== 'Property') {
continue;
}
const msg = prop.value;
if (msg.type !== typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
if (msg.type !== 'ObjectExpression') {
continue;

@@ -156,3 +151,3 @@ }

function extractMessages(node, importedMacroVars, excludeMessageDeclCalls = false) {
if (node.type === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
if (node.type === 'CallExpression') {
const expr = node;

@@ -176,5 +171,5 @@ const fnId = expr.callee;

}
else if (node.type === typescript_estree_1.AST_NODE_TYPES.JSXOpeningElement &&
else if (node.type === 'JSXOpeningElement' &&
node.name &&
node.name.type === typescript_estree_1.AST_NODE_TYPES.JSXIdentifier &&
node.name.type === 'JSXIdentifier' &&
node.name.name === 'FormattedMessage') {

@@ -181,0 +176,0 @@ const msgDescriptorNodeInfo = extractMessageDescriptorFromJSXElement(node);

{
"name": "eslint-plugin-formatjs",
"version": "2.2.1",
"version": "2.2.2",
"description": "ESLint plugin for formatjs",

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

},
"gitHead": "9c83c2c89c3fcf8d68da29be3f1be8f516b21ae0"
"gitHead": "a35249ca1f5a7db3207e8c383df5958ab2e3c0b4"
}

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

import {TSESTree, AST_NODE_TYPES} from '@typescript-eslint/typescript-estree';
import {TSESTree} from '@typescript-eslint/typescript-estree';
import {Scope} from 'eslint';

@@ -17,3 +17,3 @@

function isStringLiteral(node: TSESTree.Node): node is TSESTree.StringLiteral {
return node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string';
return node.type === 'Literal' && typeof node.value === 'string';
}

@@ -32,10 +32,10 @@

return (
node.type === AST_NODE_TYPES.CallExpression &&
node.callee.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === AST_NODE_TYPES.Identifier &&
node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'intl' &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'formatMessage' &&
node.arguments.length >= 1 &&
node.arguments[0].type === AST_NODE_TYPES.ObjectExpression
node.arguments[0].type === 'ObjectExpression'
);

@@ -48,3 +48,3 @@ }

) {
if (id.type !== AST_NODE_TYPES.Identifier) {
if (id.type !== 'Identifier') {
return false;

@@ -62,3 +62,3 @@ }

) {
if (id.type !== AST_NODE_TYPES.Identifier) {
if (id.type !== 'Identifier') {
return false;

@@ -76,3 +76,3 @@ }

): MessageDescriptorNodeInfo | undefined {
if (!node || node.type !== AST_NODE_TYPES.ObjectExpression) {
if (!node || node.type !== 'ObjectExpression') {
return;

@@ -86,6 +86,3 @@ }

for (const prop of node.properties) {
if (
prop.type !== AST_NODE_TYPES.Property ||
prop.key.type !== AST_NODE_TYPES.Identifier
) {
if (prop.type !== 'Property' || prop.key.type !== 'Identifier') {
continue;

@@ -126,6 +123,3 @@ }

for (const prop of node.attributes) {
if (
prop.type !== AST_NODE_TYPES.JSXAttribute ||
prop.name.type !== AST_NODE_TYPES.JSXIdentifier
) {
if (prop.type !== 'JSXAttribute' || prop.name.type !== 'JSXIdentifier') {
continue;

@@ -138,3 +132,3 @@ }

if (
prop.value?.type === AST_NODE_TYPES.Literal &&
prop.value?.type === 'Literal' &&
typeof prop.value.value === 'string'

@@ -148,3 +142,3 @@ ) {

if (
prop.value?.type === AST_NODE_TYPES.Literal &&
prop.value?.type === 'Literal' &&
typeof prop.value.value === 'string'

@@ -157,3 +151,3 @@ ) {

if (
prop.value?.type === AST_NODE_TYPES.Literal &&
prop.value?.type === 'Literal' &&
typeof prop.value.value === 'string'

@@ -166,4 +160,4 @@ ) {

if (
prop.value?.type === AST_NODE_TYPES.JSXExpressionContainer &&
prop.value.expression.type === AST_NODE_TYPES.ObjectExpression
prop.value?.type === 'JSXExpressionContainer' &&
prop.value.expression.type === 'ObjectExpression'
) {

@@ -182,7 +176,3 @@ values = prop.value.expression;

function extractMessageDescriptors(node?: TSESTree.Expression) {
if (
!node ||
node.type !== AST_NODE_TYPES.ObjectExpression ||
!node.properties.length
) {
if (!node || node.type !== 'ObjectExpression' || !node.properties.length) {
return [];

@@ -192,7 +182,7 @@ }

for (const prop of node.properties) {
if (prop.type !== AST_NODE_TYPES.Property) {
if (prop.type !== 'Property') {
continue;
}
const msg = prop.value;
if (msg.type !== AST_NODE_TYPES.ObjectExpression) {
if (msg.type !== 'ObjectExpression') {
continue;

@@ -213,3 +203,3 @@ }

): Array<[MessageDescriptorNodeInfo, TSESTree.Expression | undefined]> {
if (node.type === AST_NODE_TYPES.CallExpression) {
if (node.type === 'CallExpression') {
const expr = node;

@@ -236,5 +226,5 @@ const fnId = expr.callee;

} else if (
node.type === AST_NODE_TYPES.JSXOpeningElement &&
node.type === 'JSXOpeningElement' &&
node.name &&
node.name.type === AST_NODE_TYPES.JSXIdentifier &&
node.name.type === 'JSXIdentifier' &&
node.name.name === 'FormattedMessage'

@@ -241,0 +231,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