eslint-plugin-formatjs 8.1.2 → 8.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-formatjs",
3
- "version": "8.1.2",
3
+ "version": "8.1.4",
4
4
  "description": "ESLint plugin for formatjs",
5
5
  "keywords": [
6
6
  "eslint",
@@ -24,8 +24,8 @@
24
24
  "./util": "./util.js"
25
25
  },
26
26
  "dependencies": {
27
- "@formatjs/icu-messageformat-parser": "3.5.22",
28
- "@formatjs/ts-transformer": "4.5.1",
27
+ "@formatjs/icu-messageformat-parser": "3.5.23",
28
+ "@formatjs/ts-transformer": "4.5.3",
29
29
  "@types/estree-jsx": "1",
30
30
  "@types/picomatch": "4",
31
31
  "@unicode/unicode-17.0.0": "2",
package/util.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { MessageFormatElement } from "@formatjs/icu-messageformat-parser";
2
2
  import { Rule } from "eslint";
3
- //#region node_modules/.aspect_rules_js/@types+estree@1.0.9/node_modules/@types/estree/index.d.ts
4
3
  // This definition file follows a somewhat unusual format. ESTree allows
5
4
  // runtime type checks based on the `type` parameter. In order to explain this
6
5
  // to typescript we want to use discriminated union types:
@@ -70,10 +69,16 @@ interface Position {
70
69
  /** >= 0 */
71
70
  column: number;
72
71
  }
72
+ interface ProgramBodyMap {
73
+ Directive: Directive;
74
+ ModuleDeclaration: ModuleDeclaration;
75
+ Statement: Statement;
76
+ }
77
+ type ProgramBody = ProgramBodyMap[keyof ProgramBodyMap];
73
78
  interface Program extends BaseNode {
74
79
  type: "Program";
75
80
  sourceType: "script" | "module";
76
- body: Array<Directive | Statement | ModuleDeclaration>;
81
+ body: ProgramBody[];
77
82
  comments?: Comment[] | undefined;
78
83
  }
79
84
  interface Directive extends BaseNode {
@@ -525,8 +530,6 @@ interface AwaitExpression extends BaseExpression {
525
530
  type: "AwaitExpression";
526
531
  argument: Expression;
527
532
  }
528
- //#endregion
529
- //#region node_modules/.aspect_rules_js/@types+estree-jsx@1.0.5/node_modules/@types/estree-jsx/index.d.ts
530
533
  declare module "estree" {
531
534
  interface ExpressionMap {
532
535
  JSXElement: JSXElement;
@@ -617,8 +620,6 @@ interface JSXOpeningFragment extends BaseNode {
617
620
  interface JSXClosingFragment extends BaseNode {
618
621
  type: "JSXClosingFragment";
619
622
  }
620
- //#endregion
621
- //#region packages/eslint-plugin-formatjs/util.d.ts
622
623
  export interface MessageDescriptor {
623
624
  id?: string;
624
625
  defaultMessage?: string;
@@ -656,6 +657,5 @@ export declare function extractMessages(node: Node, { additionalComponentNames,
656
657
  * it means that the patch cannot be applied.
657
658
  */
658
659
  export declare function patchMessage(messageNode: Node, ast: MessageFormatElement[], patcher: (messageContent: string, ast: MessageFormatElement[]) => string): string | null;
659
- //#endregion
660
660
  export {};
661
661
  //# sourceMappingURL=util.d.ts.map
package/util.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region packages/eslint-plugin-formatjs/util.ts
1
+ // packages/eslint-plugin-formatjs/util.ts
2
2
  const FORMAT_FUNCTION_NAMES = /* @__PURE__ */ new Set([
3
3
  "$formatMessage",
4
4
  "formatMessage",
@@ -201,7 +201,6 @@ function patchMessage(messageNode, ast, patcher) {
201
201
  else if (messageNode.type === "TemplateLiteral" && messageNode.quasis.length === 1 && messageNode.expressions.length === 0) return "`" + patcher(messageNode.quasis[0].value.cooked, ast).replace(/\\/g, "\\\\").replace(/`/g, "\\`") + "`";
202
202
  return null;
203
203
  }
204
- //#endregion
205
204
  export { extractMessageDescriptor, extractMessages, getSettings, isIntlFormatMessageCall, patchMessage };
206
205
 
207
206
  //# sourceMappingURL=util.js.map
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'])\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\nfunction unwrapObjectExpression(\n node?: MessagePropertyValue\n): ObjectExpression | undefined {\n switch (node?.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return unwrapObjectExpression(node.expression)\n case 'ObjectExpression':\n return node\n }\n}\n\nfunction getCalleeName(node: Node): string | undefined {\n if (node.type === 'Identifier') {\n return node.name\n }\n if (node.type === 'MemberExpression' && node.property.type === 'Identifier') {\n return node.property.name\n }\n}\n\nexport function isIntlFormatMessageCall(\n node: Node,\n additionalFunctionNames: string[] = []\n): boolean {\n if (node.type === 'ChainExpression') {\n return isIntlFormatMessageCall(node.expression, additionalFunctionNames)\n }\n if (node.type !== 'CallExpression') {\n return false\n }\n const descriptor = node.arguments[0]\n const calleeName = getCalleeName(node.callee)\n return !!(\n calleeName &&\n (FORMAT_FUNCTION_NAMES.has(calleeName) ||\n additionalFunctionNames.includes(calleeName)) &&\n descriptor?.type !== 'SpreadElement' &&\n unwrapObjectExpression(descriptor)\n )\n}\n\nexport function extractMessageDescriptor(\n expression?: MessagePropertyValue\n): MessageDescriptorNodeInfo | undefined {\n const node = unwrapObjectExpression(expression)\n if (!node) {\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') {\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 =\n prop.key.type === 'Identifier'\n ? prop.key.name\n : prop.key.type === 'Literal'\n ? prop.key.value\n : undefined\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(expression?: Expression) {\n const node = unwrapObjectExpression(expression)\n if (!node) {\n return []\n }\n const msgs = []\n for (const prop of node.properties) {\n if (prop.type !== 'Property') {\n continue\n }\n const nodeInfo = extractMessageDescriptor(prop.value)\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 const calleeName = getCalleeName(node.callee)\n if (!calleeName) {\n return []\n }\n if (calleeName === 'defineMessages') {\n return excludeMessageDeclCalls\n ? []\n : extractMessageDescriptors(args0).map(msg => [msg, undefined])\n }\n if (\n calleeName === 'defineMessage'\n ? !excludeMessageDeclCalls\n : allFormatFunctionNames.has(calleeName)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptor(args0)\n if (msgDescriptorNodeInfo && (!args1 || args1.type !== 'SpreadElement')) {\n return [[msgDescriptorNodeInfo, args1 as Expression]]\n }\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;AAkBpD,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,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,KAAA;EACvD,KAAK,mBACH,OAAO,mCAAmC,IAAI;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,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":["sources/packages/eslint-plugin-formatjs/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'])\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\nfunction unwrapObjectExpression(\n node?: MessagePropertyValue\n): ObjectExpression | undefined {\n switch (node?.type) {\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n return unwrapObjectExpression(node.expression)\n case 'ObjectExpression':\n return node\n }\n}\n\nfunction getCalleeName(node: Node): string | undefined {\n if (node.type === 'Identifier') {\n return node.name\n }\n if (node.type === 'MemberExpression' && node.property.type === 'Identifier') {\n return node.property.name\n }\n}\n\nexport function isIntlFormatMessageCall(\n node: Node,\n additionalFunctionNames: string[] = []\n): boolean {\n if (node.type === 'ChainExpression') {\n return isIntlFormatMessageCall(node.expression, additionalFunctionNames)\n }\n if (node.type !== 'CallExpression') {\n return false\n }\n const descriptor = node.arguments[0]\n const calleeName = getCalleeName(node.callee)\n return !!(\n calleeName &&\n (FORMAT_FUNCTION_NAMES.has(calleeName) ||\n additionalFunctionNames.includes(calleeName)) &&\n descriptor?.type !== 'SpreadElement' &&\n unwrapObjectExpression(descriptor)\n )\n}\n\nexport function extractMessageDescriptor(\n expression?: MessagePropertyValue\n): MessageDescriptorNodeInfo | undefined {\n const node = unwrapObjectExpression(expression)\n if (!node) {\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') {\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 =\n prop.key.type === 'Identifier'\n ? prop.key.name\n : prop.key.type === 'Literal'\n ? prop.key.value\n : undefined\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(expression?: Expression) {\n const node = unwrapObjectExpression(expression)\n if (!node) {\n return []\n }\n const msgs = []\n for (const prop of node.properties) {\n if (prop.type !== 'Property') {\n continue\n }\n const nodeInfo = extractMessageDescriptor(prop.value)\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 const calleeName = getCalleeName(node.callee)\n if (!calleeName) {\n return []\n }\n if (calleeName === 'defineMessages') {\n return excludeMessageDeclCalls\n ? []\n : extractMessageDescriptors(args0).map(msg => [msg, undefined])\n }\n if (\n calleeName === 'defineMessage'\n ? !excludeMessageDeclCalls\n : allFormatFunctionNames.has(calleeName)\n ) {\n const msgDescriptorNodeInfo = extractMessageDescriptor(args0)\n if (msgDescriptorNodeInfo && (!args1 || args1.type !== 'SpreadElement')) {\n return [[msgDescriptorNodeInfo, args1 as Expression]]\n }\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;AAkBpD,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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