eslint-plugin-formatjs 6.4.19 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +78 -79
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/util.d.ts +8 -9
- package/util.js +1 -4
- package/util.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-formatjs",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "ESLint plugin for formatjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"./util": "./util.js"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@formatjs/icu-messageformat-parser": "3.5.
|
|
28
|
-
"@formatjs/ts-transformer": "4.4.
|
|
27
|
+
"@formatjs/icu-messageformat-parser": "3.5.17",
|
|
28
|
+
"@formatjs/ts-transformer": "4.4.19",
|
|
29
29
|
"@types/estree-jsx": "1",
|
|
30
30
|
"@types/picomatch": "4",
|
|
31
31
|
"@unicode/unicode-17.0.0": "1",
|
|
32
|
-
"magic-string": "
|
|
32
|
+
"magic-string": "1",
|
|
33
33
|
"picomatch": "2 || 3 || 4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/util.d.ts
CHANGED
|
@@ -619,18 +619,18 @@ interface JSXClosingFragment extends BaseNode {
|
|
|
619
619
|
}
|
|
620
620
|
//#endregion
|
|
621
621
|
//#region packages/eslint-plugin-formatjs/util.d.ts
|
|
622
|
-
interface MessageDescriptor {
|
|
622
|
+
export interface MessageDescriptor {
|
|
623
623
|
id?: string;
|
|
624
624
|
defaultMessage?: string;
|
|
625
625
|
description?: string | object;
|
|
626
626
|
}
|
|
627
|
-
interface Settings {
|
|
627
|
+
export interface Settings {
|
|
628
628
|
excludeMessageDeclCalls?: boolean;
|
|
629
629
|
additionalFunctionNames?: string[];
|
|
630
630
|
additionalComponentNames?: string[];
|
|
631
631
|
ignoreTag?: boolean;
|
|
632
632
|
}
|
|
633
|
-
interface MessageDescriptorNodeInfo {
|
|
633
|
+
export interface MessageDescriptorNodeInfo {
|
|
634
634
|
message: MessageDescriptor;
|
|
635
635
|
messageDescriptorNode: ObjectExpression | JSXOpeningElement;
|
|
636
636
|
messageNode?: Property["value"] | JSXAttribute["value"];
|
|
@@ -639,16 +639,15 @@ interface MessageDescriptorNodeInfo {
|
|
|
639
639
|
idValueNode?: Property["value"] | JSXAttribute["value"];
|
|
640
640
|
idPropNode?: Property | JSXAttribute;
|
|
641
641
|
}
|
|
642
|
-
declare function getSettings({ settings }: Rule.RuleContext): Settings;
|
|
643
|
-
declare function isIntlFormatMessageCall(node: Node): boolean;
|
|
644
|
-
declare function extractMessageDescriptor(node?: Expression): MessageDescriptorNodeInfo | undefined;
|
|
645
|
-
declare function extractMessages(node: Node, { additionalComponentNames, additionalFunctionNames, excludeMessageDeclCalls }?: Settings): Array<[MessageDescriptorNodeInfo, Expression | undefined]>;
|
|
642
|
+
export declare function getSettings({ settings }: Rule.RuleContext): Settings;
|
|
643
|
+
export declare function isIntlFormatMessageCall(node: Node): boolean;
|
|
644
|
+
export declare function extractMessageDescriptor(node?: Expression): MessageDescriptorNodeInfo | undefined;
|
|
645
|
+
export declare function extractMessages(node: Node, { additionalComponentNames, additionalFunctionNames, excludeMessageDeclCalls }?: Settings): Array<[MessageDescriptorNodeInfo, Expression | undefined]>;
|
|
646
646
|
/**
|
|
647
647
|
* Apply changes to the ICU message in code. The return value can be used in
|
|
648
648
|
* `fixer.replaceText(messageNode, <return value>)`. If the return value is null,
|
|
649
649
|
* it means that the patch cannot be applied.
|
|
650
650
|
*/
|
|
651
|
-
declare function patchMessage(messageNode: Node, ast: MessageFormatElement[], patcher: (messageContent: string, ast: MessageFormatElement[]) => string): string | null;
|
|
651
|
+
export declare function patchMessage(messageNode: Node, ast: MessageFormatElement[], patcher: (messageContent: string, ast: MessageFormatElement[]) => string): string | null;
|
|
652
652
|
//#endregion
|
|
653
|
-
export { MessageDescriptor, MessageDescriptorNodeInfo, Settings, extractMessageDescriptor, extractMessages, getSettings, isIntlFormatMessageCall, patchMessage };
|
|
654
653
|
//# sourceMappingURL=util.d.ts.map
|
package/util.js
CHANGED
|
@@ -101,7 +101,6 @@ function extractMessageDescriptor(node) {
|
|
|
101
101
|
result.message.id = value;
|
|
102
102
|
result.idValueNode = valueNode;
|
|
103
103
|
result.idPropNode = prop;
|
|
104
|
-
break;
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
return result;
|
|
@@ -148,9 +147,7 @@ function extractMessageDescriptorFromJSXElement(node) {
|
|
|
148
147
|
result.idPropNode = prop;
|
|
149
148
|
if (value) result.message.id = value;
|
|
150
149
|
break;
|
|
151
|
-
case "values":
|
|
152
|
-
if (valueNode?.type === "JSXExpressionContainer" && valueNode.expression.type === "ObjectExpression") values = valueNode.expression;
|
|
153
|
-
break;
|
|
150
|
+
case "values": if (valueNode?.type === "JSXExpressionContainer" && valueNode.expression.type === "ObjectExpression") values = valueNode.expression;
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
153
|
if (!result.messagePropNode && !result.descriptionNode && !result.idPropNode && hasSpreadAttribute) return;
|
package/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","names":[],"sources":["../util.ts"],"sourcesContent":["import type {MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nimport type {Rule} from 'eslint'\nimport type {\n BinaryExpression,\n Expression,\n Node,\n ObjectExpression,\n Property,\n TemplateLiteral,\n} from 'estree-jsx'\nimport type {JSXAttribute, JSXOpeningElement} from 'estree-jsx'\n\nexport interface MessageDescriptor {\n id?: string\n defaultMessage?: string\n description?: string | object\n}\n\nconst FORMAT_FUNCTION_NAMES = new Set(['$formatMessage', 'formatMessage', '$t'])\nconst COMPONENT_NAMES = new Set(['FormattedMessage'])\nconst DECLARATION_FUNCTION_NAMES = new Set(['defineMessage'])\n\nexport interface Settings {\n excludeMessageDeclCalls?: boolean\n additionalFunctionNames?: string[]\n additionalComponentNames?: string[]\n ignoreTag?: boolean\n}\nexport interface MessageDescriptorNodeInfo {\n message: MessageDescriptor\n messageDescriptorNode: ObjectExpression | JSXOpeningElement\n messageNode?: Property['value'] | JSXAttribute['value']\n messagePropNode?: Property | JSXAttribute\n descriptionNode?: Property['value'] | JSXAttribute['value']\n idValueNode?: Property['value'] | JSXAttribute['value']\n idPropNode?: Property | JSXAttribute\n}\n\nexport function getSettings({settings}: Rule.RuleContext): Settings {\n return settings.formatjs ?? settings\n}\n\ntype BinaryExpressionOperand =\n | BinaryExpression['left']\n | BinaryExpression['right']\n\nfunction isTemplateLiteralWithoutVar(node: Node): node is TemplateLiteral {\n return node.type === 'TemplateLiteral' && node.quasis.length === 1\n}\n\ntype TransparentTypeScriptExpressionType =\n | 'TSAsExpression'\n | 'TSSatisfiesExpression'\n | 'TSNonNullExpression'\n | 'TSTypeAssertion'\n\ninterface TypeScriptExpressionWrapper {\n type: TransparentTypeScriptExpressionType\n expression: StaticMessageExpression\n}\n\ninterface TypeScriptBinaryExpressionOperandWrapper {\n type: TransparentTypeScriptExpressionType\n expression: StaticStringConcatOperand\n}\n\ntype StaticMessageExpression = Expression | TypeScriptExpressionWrapper\ntype MessagePropertyValue = Property['value'] | TypeScriptExpressionWrapper\ntype StaticStringConcatOperand =\n | BinaryExpressionOperand\n | TypeScriptBinaryExpressionOperandWrapper\n\nfunction getStaticStringFromTemplateLiteral(\n node: TemplateLiteral\n): string | undefined {\n return node.quasis.length === 1\n ? (node.quasis[0].value.cooked ?? undefined)\n : undefined\n}\n\nfunction isStaticMessageExpression(\n node: MessagePropertyValue\n): node is StaticMessageExpression {\n switch (node.type) {\n case 'ArrayPattern':\n case 'AssignmentPattern':\n case 'ObjectPattern':\n return false\n default:\n return true\n }\n}\n\nfunction getStaticStringFromMessageExpression(\n node: StaticMessageExpression\n): string | undefined {\n switch (node.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return getStaticStringFromMessageExpression(node.expression)\n case 'Literal':\n return typeof node.value === 'string' ? node.value : undefined\n case 'TemplateLiteral':\n return getStaticStringFromTemplateLiteral(node)\n case 'TaggedTemplateExpression':\n if (!isTemplateLiteralWithoutVar(node.quasi)) {\n throw new Error('Tagged template expression must be no substitution')\n }\n return getStaticStringFromTemplateLiteral(node.quasi)\n case 'BinaryExpression': {\n const [result, isStaticallyEvaluatable] =\n staticallyEvaluateStringConcat(node)\n return isStaticallyEvaluatable ? result : undefined\n }\n }\n}\n\nfunction getStaticStringFromBinaryExpressionOperand(\n node: StaticStringConcatOperand\n): string | undefined {\n switch (node.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return getStaticStringFromBinaryExpressionOperand(node.expression)\n case 'Literal':\n return typeof node.value === 'string' ? node.value : undefined\n case 'BinaryExpression': {\n const [result, isStaticallyEvaluatable] =\n staticallyEvaluateStringConcat(node)\n return isStaticallyEvaluatable ? result : undefined\n }\n }\n}\n\nfunction staticallyEvaluateStringConcat(\n node: BinaryExpression\n): [result: string, isStaticallyEvaluatable: boolean] {\n const right = getStaticStringFromBinaryExpressionOperand(node.right)\n const left = getStaticStringFromBinaryExpressionOperand(node.left)\n return left !== undefined && right !== undefined\n ? [left + right, true]\n : ['', false]\n}\n\nexport function isIntlFormatMessageCall(node: Node): boolean {\n // GH #4890: Check for both MemberExpression (intl.formatMessage) and Identifier (formatMessage) patterns\n if (node.type !== 'CallExpression') {\n return false\n }\n\n // Check if call has at least one argument that is an object expression\n if (\n node.arguments.length < 1 ||\n node.arguments[0].type !== 'ObjectExpression'\n ) {\n return false\n }\n\n // Pattern 1: intl.formatMessage() or something.intl.formatMessage()\n if (node.callee.type === 'MemberExpression') {\n return (\n ((node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'intl') ||\n (node.callee.object.type === 'MemberExpression' &&\n node.callee.object.property.type === 'Identifier' &&\n node.callee.object.property.name === 'intl')) &&\n node.callee.property.type === 'Identifier' &&\n (node.callee.property.name === 'formatMessage' ||\n node.callee.property.name === '$t')\n )\n }\n\n // Pattern 2: formatMessage() (destructured from useIntl)\n if (node.callee.type === 'Identifier') {\n return FORMAT_FUNCTION_NAMES.has(node.callee.name)\n }\n\n return false\n}\n\nfunction isSingleMessageDescriptorDeclaration(\n node: Node,\n functionNames: Set<string>\n) {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n functionNames.has(node.callee.name)\n )\n}\n\nfunction isMultipleMessageDescriptorDeclaration(node: Node) {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineMessages'\n )\n}\n\nexport function extractMessageDescriptor(\n node?: Expression\n): MessageDescriptorNodeInfo | undefined {\n if (!node || node.type !== 'ObjectExpression') {\n return\n }\n const result: MessageDescriptorNodeInfo = {\n messageDescriptorNode: node,\n message: {},\n messageNode: undefined,\n messagePropNode: undefined,\n descriptionNode: undefined,\n idValueNode: undefined,\n }\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.key.type !== 'Identifier') {\n continue\n }\n\n // Only extract values for message-related props\n // GH #5069: Don't process other props like tagName, values, etc.\n const propName = prop.key.name\n if (\n propName !== 'id' &&\n propName !== 'defaultMessage' &&\n propName !== 'description'\n ) {\n continue\n }\n\n const valueNode: MessagePropertyValue = prop.value\n const value = isStaticMessageExpression(valueNode)\n ? getStaticStringFromMessageExpression(valueNode)\n : undefined\n\n switch (propName) {\n case 'defaultMessage':\n result.messagePropNode = prop\n result.messageNode = valueNode\n result.message.defaultMessage = value\n break\n case 'description':\n result.descriptionNode = valueNode\n result.message.description = value\n break\n case 'id':\n result.message.id = value\n result.idValueNode = valueNode\n result.idPropNode = prop\n break\n }\n }\n return result\n}\n\nfunction extractMessageDescriptorFromJSXElement(\n node?: JSXOpeningElement\n): [MessageDescriptorNodeInfo, ObjectExpression | undefined] | undefined {\n if (!node || !node.attributes) {\n return\n }\n let values: ObjectExpression | undefined\n const result: MessageDescriptorNodeInfo = {\n messageDescriptorNode: node,\n message: {},\n messageNode: undefined,\n messagePropNode: undefined,\n descriptionNode: undefined,\n idValueNode: undefined,\n idPropNode: undefined,\n }\n let hasSpreadAttribute = false\n for (const prop of node.attributes) {\n // We can't analyze spread attr\n if (prop.type === 'JSXSpreadAttribute') {\n hasSpreadAttribute = true\n }\n if (prop.type !== 'JSXAttribute' || prop.name.type !== 'JSXIdentifier') {\n continue\n }\n const key = prop.name\n const keyName = key.name\n\n // Only extract values for message-related props\n // GH #5069: Don't process other props like tagName, values, etc.\n // Allow them to have tagged templates with substitutions\n const isMessageProp =\n keyName === 'id' ||\n keyName === 'defaultMessage' ||\n keyName === 'description'\n\n let valueNode = prop.value\n let value: string | undefined = undefined\n if (valueNode && isMessageProp) {\n if (valueNode.type === 'Literal' && typeof valueNode.value === 'string') {\n value = valueNode.value\n } else if (valueNode?.type === 'JSXExpressionContainer') {\n const {expression} = valueNode\n if (expression.type !== 'JSXEmptyExpression') {\n value = getStaticStringFromMessageExpression(expression)\n }\n }\n }\n\n switch (keyName) {\n case 'defaultMessage':\n result.messagePropNode = prop\n result.messageNode = valueNode\n if (value) {\n result.message.defaultMessage = value\n }\n break\n case 'description':\n result.descriptionNode = valueNode\n if (value) {\n result.message.description = value\n }\n break\n case 'id':\n result.idValueNode = valueNode\n result.idPropNode = prop\n if (value) {\n result.message.id = value\n }\n break\n case 'values':\n if (\n valueNode?.type === 'JSXExpressionContainer' &&\n valueNode.expression.type === 'ObjectExpression'\n ) {\n values = valueNode.expression\n }\n break\n }\n }\n if (\n !result.messagePropNode &&\n !result.descriptionNode &&\n !result.idPropNode &&\n hasSpreadAttribute\n ) {\n return\n }\n return [result, values]\n}\n\nfunction extractMessageDescriptors(node?: Expression) {\n if (!node || node.type !== 'ObjectExpression' || !node.properties.length) {\n return []\n }\n const msgs = []\n for (const prop of node.properties) {\n if (prop.type !== 'Property') {\n continue\n }\n const msg = prop.value\n if (msg.type !== 'ObjectExpression') {\n continue\n }\n const nodeInfo = extractMessageDescriptor(msg as Expression)\n if (nodeInfo) {\n msgs.push(nodeInfo)\n }\n }\n return msgs\n}\n\nexport function extractMessages(\n node: Node,\n {\n additionalComponentNames,\n additionalFunctionNames,\n excludeMessageDeclCalls,\n }: Settings = {}\n): Array<[MessageDescriptorNodeInfo, Expression | undefined]> {\n const allFormatFunctionNames = Array.isArray(additionalFunctionNames)\n ? new Set([\n ...Array.from(FORMAT_FUNCTION_NAMES),\n ...additionalFunctionNames,\n ])\n : FORMAT_FUNCTION_NAMES\n const allComponentNames = Array.isArray(additionalComponentNames)\n ? new Set([...Array.from(COMPONENT_NAMES), ...additionalComponentNames])\n : COMPONENT_NAMES\n if (node.type === 'CallExpression') {\n const args0 = node.arguments[0]\n const args1 = node.arguments[1]\n // We can't really analyze spread element\n if (!args0 || args0.type === 'SpreadElement') {\n return []\n }\n if (\n (!excludeMessageDeclCalls &&\n isSingleMessageDescriptorDeclaration(\n node,\n DECLARATION_FUNCTION_NAMES\n )) ||\n isIntlFormatMessageCall(node) ||\n isSingleMessageDescriptorDeclaration(node, allFormatFunctionNames)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptor(args0)\n if (msgDescriptorNodeInfo && (!args1 || args1.type !== 'SpreadElement')) {\n return [[msgDescriptorNodeInfo, args1 as Expression]]\n }\n } else if (\n !excludeMessageDeclCalls &&\n isMultipleMessageDescriptorDeclaration(node)\n ) {\n return extractMessageDescriptors(args0).map(msg => [msg, undefined])\n }\n } else if (\n node.type === 'JSXOpeningElement' &&\n node.name &&\n node.name.type === 'JSXIdentifier' &&\n allComponentNames.has(node.name.name)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptorFromJSXElement(node)\n if (msgDescriptorNodeInfo) {\n return [msgDescriptorNodeInfo]\n }\n }\n return []\n}\n\n/**\n * Apply changes to the ICU message in code. The return value can be used in\n * `fixer.replaceText(messageNode, <return value>)`. If the return value is null,\n * it means that the patch cannot be applied.\n */\nexport function patchMessage(\n messageNode: Node,\n ast: MessageFormatElement[],\n patcher: (messageContent: string, ast: MessageFormatElement[]) => string\n): string | null {\n if (\n messageNode.type === 'Literal' &&\n messageNode.value &&\n typeof messageNode.value === 'string'\n ) {\n return (\n '\"' + patcher(messageNode.value as string, ast).replace('\"', '\\\\\"') + '\"'\n )\n } else if (\n messageNode.type === 'TemplateLiteral' &&\n messageNode.quasis.length === 1 &&\n messageNode.expressions.length === 0\n ) {\n return (\n '`' +\n patcher(messageNode.quasis[0].value.cooked!, ast)\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/`/g, '\\\\`') +\n '`'\n )\n }\n\n return null\n}\n"],"mappings":";AAkBA,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAkB;CAAiB;AAAI,CAAC;AAC/E,MAAM,kCAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC;AACpD,MAAM,6CAA6B,IAAI,IAAI,CAAC,eAAe,CAAC;AAkB5D,SAAgB,YAAY,EAAC,YAAuC;CAClE,OAAO,SAAS,YAAY;AAC9B;AAMA,SAAS,4BAA4B,MAAqC;CACxE,OAAO,KAAK,SAAS,qBAAqB,KAAK,OAAO,WAAW;AACnE;AAwBA,SAAS,mCACP,MACoB;CACpB,OAAO,KAAK,OAAO,WAAW,IACzB,KAAK,OAAO,EAAE,CAAC,MAAM,UAAU,KAAA,IAChC,KAAA;AACN;AAEA,SAAS,0BACP,MACiC;CACjC,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK,iBACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,SAAS,qCACP,MACoB;CACpB,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,mBACH,OAAO,qCAAqC,KAAK,UAAU;EAC7D,KAAK,WACH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,YAAY,SAAS,aACrB,YAAY,SACZ,OAAO,YAAY,UAAU,UAE7B,OACE,OAAM,QAAQ,YAAY,OAAiB,GAAG,CAAC,CAAC,QAAQ,MAAK,MAAK,IAAI;MAEnE,IACL,YAAY,SAAS,qBACrB,YAAY,OAAO,WAAW,KAC9B,YAAY,YAAY,WAAW,GAEnC,OACE,MACA,QAAQ,YAAY,OAAO,EAAE,CAAC,MAAM,QAAS,GAAG,CAAC,CAC9C,QAAQ,OAAO,MAAM,CAAC,CACtB,QAAQ,MAAM,KAAK,IACtB;CAIJ,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"util.js","names":[],"sources":["../util.ts"],"sourcesContent":["import type {MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nimport type {Rule} from 'eslint'\nimport type {\n BinaryExpression,\n Expression,\n Node,\n ObjectExpression,\n Property,\n TemplateLiteral,\n} from 'estree-jsx'\nimport type {JSXAttribute, JSXOpeningElement} from 'estree-jsx'\n\nexport interface MessageDescriptor {\n id?: string\n defaultMessage?: string\n description?: string | object\n}\n\nconst FORMAT_FUNCTION_NAMES = new Set(['$formatMessage', 'formatMessage', '$t'])\nconst COMPONENT_NAMES = new Set(['FormattedMessage'])\nconst DECLARATION_FUNCTION_NAMES = new Set(['defineMessage'])\n\nexport interface Settings {\n excludeMessageDeclCalls?: boolean\n additionalFunctionNames?: string[]\n additionalComponentNames?: string[]\n ignoreTag?: boolean\n}\nexport interface MessageDescriptorNodeInfo {\n message: MessageDescriptor\n messageDescriptorNode: ObjectExpression | JSXOpeningElement\n messageNode?: Property['value'] | JSXAttribute['value']\n messagePropNode?: Property | JSXAttribute\n descriptionNode?: Property['value'] | JSXAttribute['value']\n idValueNode?: Property['value'] | JSXAttribute['value']\n idPropNode?: Property | JSXAttribute\n}\n\nexport function getSettings({settings}: Rule.RuleContext): Settings {\n return settings.formatjs ?? settings\n}\n\ntype BinaryExpressionOperand =\n | BinaryExpression['left']\n | BinaryExpression['right']\n\nfunction isTemplateLiteralWithoutVar(node: Node): node is TemplateLiteral {\n return node.type === 'TemplateLiteral' && node.quasis.length === 1\n}\n\ntype TransparentTypeScriptExpressionType =\n | 'TSAsExpression'\n | 'TSSatisfiesExpression'\n | 'TSNonNullExpression'\n | 'TSTypeAssertion'\n\ninterface TypeScriptExpressionWrapper {\n type: TransparentTypeScriptExpressionType\n expression: StaticMessageExpression\n}\n\ninterface TypeScriptBinaryExpressionOperandWrapper {\n type: TransparentTypeScriptExpressionType\n expression: StaticStringConcatOperand\n}\n\ntype StaticMessageExpression = Expression | TypeScriptExpressionWrapper\ntype MessagePropertyValue = Property['value'] | TypeScriptExpressionWrapper\ntype StaticStringConcatOperand =\n | BinaryExpressionOperand\n | TypeScriptBinaryExpressionOperandWrapper\n\nfunction getStaticStringFromTemplateLiteral(\n node: TemplateLiteral\n): string | undefined {\n return node.quasis.length === 1\n ? (node.quasis[0].value.cooked ?? undefined)\n : undefined\n}\n\nfunction isStaticMessageExpression(\n node: MessagePropertyValue\n): node is StaticMessageExpression {\n switch (node.type) {\n case 'ArrayPattern':\n case 'AssignmentPattern':\n case 'ObjectPattern':\n return false\n default:\n return true\n }\n}\n\nfunction getStaticStringFromMessageExpression(\n node: StaticMessageExpression\n): string | undefined {\n switch (node.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return getStaticStringFromMessageExpression(node.expression)\n case 'Literal':\n return typeof node.value === 'string' ? node.value : undefined\n case 'TemplateLiteral':\n return getStaticStringFromTemplateLiteral(node)\n case 'TaggedTemplateExpression':\n if (!isTemplateLiteralWithoutVar(node.quasi)) {\n throw new Error('Tagged template expression must be no substitution')\n }\n return getStaticStringFromTemplateLiteral(node.quasi)\n case 'BinaryExpression': {\n const [result, isStaticallyEvaluatable] =\n staticallyEvaluateStringConcat(node)\n return isStaticallyEvaluatable ? result : undefined\n }\n }\n}\n\nfunction getStaticStringFromBinaryExpressionOperand(\n node: StaticStringConcatOperand\n): string | undefined {\n switch (node.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return getStaticStringFromBinaryExpressionOperand(node.expression)\n case 'Literal':\n return typeof node.value === 'string' ? node.value : undefined\n case 'BinaryExpression': {\n const [result, isStaticallyEvaluatable] =\n staticallyEvaluateStringConcat(node)\n return isStaticallyEvaluatable ? result : undefined\n }\n }\n}\n\nfunction staticallyEvaluateStringConcat(\n node: BinaryExpression\n): [result: string, isStaticallyEvaluatable: boolean] {\n const right = getStaticStringFromBinaryExpressionOperand(node.right)\n const left = getStaticStringFromBinaryExpressionOperand(node.left)\n return left !== undefined && right !== undefined\n ? [left + right, true]\n : ['', false]\n}\n\nexport function isIntlFormatMessageCall(node: Node): boolean {\n // GH #4890: Check for both MemberExpression (intl.formatMessage) and Identifier (formatMessage) patterns\n if (node.type !== 'CallExpression') {\n return false\n }\n\n // Check if call has at least one argument that is an object expression\n if (\n node.arguments.length < 1 ||\n node.arguments[0].type !== 'ObjectExpression'\n ) {\n return false\n }\n\n // Pattern 1: intl.formatMessage() or something.intl.formatMessage()\n if (node.callee.type === 'MemberExpression') {\n return (\n ((node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'intl') ||\n (node.callee.object.type === 'MemberExpression' &&\n node.callee.object.property.type === 'Identifier' &&\n node.callee.object.property.name === 'intl')) &&\n node.callee.property.type === 'Identifier' &&\n (node.callee.property.name === 'formatMessage' ||\n node.callee.property.name === '$t')\n )\n }\n\n // Pattern 2: formatMessage() (destructured from useIntl)\n if (node.callee.type === 'Identifier') {\n return FORMAT_FUNCTION_NAMES.has(node.callee.name)\n }\n\n return false\n}\n\nfunction isSingleMessageDescriptorDeclaration(\n node: Node,\n functionNames: Set<string>\n) {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n functionNames.has(node.callee.name)\n )\n}\n\nfunction isMultipleMessageDescriptorDeclaration(node: Node) {\n return (\n node.type === 'CallExpression' &&\n node.callee.type === 'Identifier' &&\n node.callee.name === 'defineMessages'\n )\n}\n\nexport function extractMessageDescriptor(\n node?: Expression\n): MessageDescriptorNodeInfo | undefined {\n if (!node || node.type !== 'ObjectExpression') {\n return\n }\n const result: MessageDescriptorNodeInfo = {\n messageDescriptorNode: node,\n message: {},\n messageNode: undefined,\n messagePropNode: undefined,\n descriptionNode: undefined,\n idValueNode: undefined,\n }\n for (const prop of node.properties) {\n if (prop.type !== 'Property' || prop.key.type !== 'Identifier') {\n continue\n }\n\n // Only extract values for message-related props\n // GH #5069: Don't process other props like tagName, values, etc.\n const propName = prop.key.name\n if (\n propName !== 'id' &&\n propName !== 'defaultMessage' &&\n propName !== 'description'\n ) {\n continue\n }\n\n const valueNode: MessagePropertyValue = prop.value\n const value = isStaticMessageExpression(valueNode)\n ? getStaticStringFromMessageExpression(valueNode)\n : undefined\n\n switch (propName) {\n case 'defaultMessage':\n result.messagePropNode = prop\n result.messageNode = valueNode\n result.message.defaultMessage = value\n break\n case 'description':\n result.descriptionNode = valueNode\n result.message.description = value\n break\n case 'id':\n result.message.id = value\n result.idValueNode = valueNode\n result.idPropNode = prop\n break\n }\n }\n return result\n}\n\nfunction extractMessageDescriptorFromJSXElement(\n node?: JSXOpeningElement\n): [MessageDescriptorNodeInfo, ObjectExpression | undefined] | undefined {\n if (!node || !node.attributes) {\n return\n }\n let values: ObjectExpression | undefined\n const result: MessageDescriptorNodeInfo = {\n messageDescriptorNode: node,\n message: {},\n messageNode: undefined,\n messagePropNode: undefined,\n descriptionNode: undefined,\n idValueNode: undefined,\n idPropNode: undefined,\n }\n let hasSpreadAttribute = false\n for (const prop of node.attributes) {\n // We can't analyze spread attr\n if (prop.type === 'JSXSpreadAttribute') {\n hasSpreadAttribute = true\n }\n if (prop.type !== 'JSXAttribute' || prop.name.type !== 'JSXIdentifier') {\n continue\n }\n const key = prop.name\n const keyName = key.name\n\n // Only extract values for message-related props\n // GH #5069: Don't process other props like tagName, values, etc.\n // Allow them to have tagged templates with substitutions\n const isMessageProp =\n keyName === 'id' ||\n keyName === 'defaultMessage' ||\n keyName === 'description'\n\n let valueNode = prop.value\n let value: string | undefined = undefined\n if (valueNode && isMessageProp) {\n if (valueNode.type === 'Literal' && typeof valueNode.value === 'string') {\n value = valueNode.value\n } else if (valueNode?.type === 'JSXExpressionContainer') {\n const {expression} = valueNode\n if (expression.type !== 'JSXEmptyExpression') {\n value = getStaticStringFromMessageExpression(expression)\n }\n }\n }\n\n switch (keyName) {\n case 'defaultMessage':\n result.messagePropNode = prop\n result.messageNode = valueNode\n if (value) {\n result.message.defaultMessage = value\n }\n break\n case 'description':\n result.descriptionNode = valueNode\n if (value) {\n result.message.description = value\n }\n break\n case 'id':\n result.idValueNode = valueNode\n result.idPropNode = prop\n if (value) {\n result.message.id = value\n }\n break\n case 'values':\n if (\n valueNode?.type === 'JSXExpressionContainer' &&\n valueNode.expression.type === 'ObjectExpression'\n ) {\n values = valueNode.expression\n }\n break\n }\n }\n if (\n !result.messagePropNode &&\n !result.descriptionNode &&\n !result.idPropNode &&\n hasSpreadAttribute\n ) {\n return\n }\n return [result, values]\n}\n\nfunction extractMessageDescriptors(node?: Expression) {\n if (!node || node.type !== 'ObjectExpression' || !node.properties.length) {\n return []\n }\n const msgs = []\n for (const prop of node.properties) {\n if (prop.type !== 'Property') {\n continue\n }\n const msg = prop.value\n if (msg.type !== 'ObjectExpression') {\n continue\n }\n const nodeInfo = extractMessageDescriptor(msg as Expression)\n if (nodeInfo) {\n msgs.push(nodeInfo)\n }\n }\n return msgs\n}\n\nexport function extractMessages(\n node: Node,\n {\n additionalComponentNames,\n additionalFunctionNames,\n excludeMessageDeclCalls,\n }: Settings = {}\n): Array<[MessageDescriptorNodeInfo, Expression | undefined]> {\n const allFormatFunctionNames = Array.isArray(additionalFunctionNames)\n ? new Set([\n ...Array.from(FORMAT_FUNCTION_NAMES),\n ...additionalFunctionNames,\n ])\n : FORMAT_FUNCTION_NAMES\n const allComponentNames = Array.isArray(additionalComponentNames)\n ? new Set([...Array.from(COMPONENT_NAMES), ...additionalComponentNames])\n : COMPONENT_NAMES\n if (node.type === 'CallExpression') {\n const args0 = node.arguments[0]\n const args1 = node.arguments[1]\n // We can't really analyze spread element\n if (!args0 || args0.type === 'SpreadElement') {\n return []\n }\n if (\n (!excludeMessageDeclCalls &&\n isSingleMessageDescriptorDeclaration(\n node,\n DECLARATION_FUNCTION_NAMES\n )) ||\n isIntlFormatMessageCall(node) ||\n isSingleMessageDescriptorDeclaration(node, allFormatFunctionNames)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptor(args0)\n if (msgDescriptorNodeInfo && (!args1 || args1.type !== 'SpreadElement')) {\n return [[msgDescriptorNodeInfo, args1 as Expression]]\n }\n } else if (\n !excludeMessageDeclCalls &&\n isMultipleMessageDescriptorDeclaration(node)\n ) {\n return extractMessageDescriptors(args0).map(msg => [msg, undefined])\n }\n } else if (\n node.type === 'JSXOpeningElement' &&\n node.name &&\n node.name.type === 'JSXIdentifier' &&\n allComponentNames.has(node.name.name)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptorFromJSXElement(node)\n if (msgDescriptorNodeInfo) {\n return [msgDescriptorNodeInfo]\n }\n }\n return []\n}\n\n/**\n * Apply changes to the ICU message in code. The return value can be used in\n * `fixer.replaceText(messageNode, <return value>)`. If the return value is null,\n * it means that the patch cannot be applied.\n */\nexport function patchMessage(\n messageNode: Node,\n ast: MessageFormatElement[],\n patcher: (messageContent: string, ast: MessageFormatElement[]) => string\n): string | null {\n if (\n messageNode.type === 'Literal' &&\n messageNode.value &&\n typeof messageNode.value === 'string'\n ) {\n return (\n '\"' + patcher(messageNode.value as string, ast).replace('\"', '\\\\\"') + '\"'\n )\n } else if (\n messageNode.type === 'TemplateLiteral' &&\n messageNode.quasis.length === 1 &&\n messageNode.expressions.length === 0\n ) {\n return (\n '`' +\n patcher(messageNode.quasis[0].value.cooked!, ast)\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/`/g, '\\\\`')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