eslint-plugin-formatjs 6.6.1 → 6.6.3

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": "6.6.1",
3
+ "version": "6.6.3",
4
4
  "description": "ESLint plugin for formatjs",
5
5
  "keywords": [
6
6
  "eslint",
@@ -24,11 +24,11 @@
24
24
  "./util": "./util.js"
25
25
  },
26
26
  "dependencies": {
27
- "@formatjs/icu-messageformat-parser": "3.5.17",
28
- "@formatjs/ts-transformer": "4.4.19",
27
+ "@formatjs/icu-messageformat-parser": "3.5.18",
28
+ "@formatjs/ts-transformer": "4.4.20",
29
29
  "@types/estree-jsx": "1",
30
30
  "@types/picomatch": "4",
31
- "@unicode/unicode-17.0.0": "1",
31
+ "@unicode/unicode-17.0.0": "2",
32
32
  "magic-string": "1",
33
33
  "picomatch": "2 || 3 || 4"
34
34
  },
package/util.d.ts CHANGED
@@ -640,8 +640,15 @@ export interface MessageDescriptorNodeInfo {
640
640
  idPropNode?: Property | JSXAttribute;
641
641
  }
642
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;
643
+ type TransparentTypeScriptExpressionType = "TSAsExpression" | "TSSatisfiesExpression" | "TSNonNullExpression" | "TSTypeAssertion";
644
+ interface TypeScriptExpressionWrapper {
645
+ type: TransparentTypeScriptExpressionType;
646
+ expression: StaticMessageExpression;
647
+ }
648
+ type StaticMessageExpression = Expression | TypeScriptExpressionWrapper;
649
+ type MessagePropertyValue = Property["value"] | TypeScriptExpressionWrapper;
650
+ export declare function isIntlFormatMessageCall(node: Node, additionalFunctionNames?: string[]): boolean;
651
+ export declare function extractMessageDescriptor(expression?: MessagePropertyValue): MessageDescriptorNodeInfo | undefined;
645
652
  export declare function extractMessages(node: Node, { additionalComponentNames, additionalFunctionNames, excludeMessageDeclCalls }?: Settings): Array<[MessageDescriptorNodeInfo, Expression | undefined]>;
646
653
  /**
647
654
  * Apply changes to the ICU message in code. The return value can be used in
package/util.js CHANGED
@@ -5,7 +5,6 @@ const FORMAT_FUNCTION_NAMES = /* @__PURE__ */ new Set([
5
5
  "$t"
6
6
  ]);
7
7
  const COMPONENT_NAMES = /* @__PURE__ */ new Set(["FormattedMessage"]);
8
- const DECLARATION_FUNCTION_NAMES = /* @__PURE__ */ new Set(["defineMessage"]);
9
8
  function getSettings({ settings }) {
10
9
  return settings.formatjs ?? settings;
11
10
  }
@@ -58,21 +57,29 @@ function staticallyEvaluateStringConcat(node) {
58
57
  const left = getStaticStringFromBinaryExpressionOperand(node.left);
59
58
  return left !== void 0 && right !== void 0 ? [left + right, true] : ["", false];
60
59
  }
61
- function isIntlFormatMessageCall(node) {
62
- if (node.type !== "CallExpression") return false;
63
- if (node.arguments.length < 1 || node.arguments[0].type !== "ObjectExpression") return false;
64
- if (node.callee.type === "MemberExpression") return (node.callee.object.type === "Identifier" && node.callee.object.name === "intl" || node.callee.object.type === "MemberExpression" && node.callee.object.property.type === "Identifier" && node.callee.object.property.name === "intl") && node.callee.property.type === "Identifier" && (node.callee.property.name === "formatMessage" || node.callee.property.name === "$t");
65
- if (node.callee.type === "Identifier") return FORMAT_FUNCTION_NAMES.has(node.callee.name);
66
- return false;
60
+ function unwrapObjectExpression(node) {
61
+ switch (node?.type) {
62
+ case "TSAsExpression":
63
+ case "TSSatisfiesExpression":
64
+ case "TSNonNullExpression":
65
+ case "TSTypeAssertion": return unwrapObjectExpression(node.expression);
66
+ case "ObjectExpression": return node;
67
+ }
67
68
  }
68
- function isSingleMessageDescriptorDeclaration(node, functionNames) {
69
- return node.type === "CallExpression" && node.callee.type === "Identifier" && functionNames.has(node.callee.name);
69
+ function getCalleeName(node) {
70
+ if (node.type === "Identifier") return node.name;
71
+ if (node.type === "MemberExpression" && node.property.type === "Identifier") return node.property.name;
70
72
  }
71
- function isMultipleMessageDescriptorDeclaration(node) {
72
- return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "defineMessages";
73
+ function isIntlFormatMessageCall(node, additionalFunctionNames = []) {
74
+ if (node.type === "ChainExpression") return isIntlFormatMessageCall(node.expression, additionalFunctionNames);
75
+ if (node.type !== "CallExpression") return false;
76
+ const descriptor = node.arguments[0];
77
+ const calleeName = getCalleeName(node.callee);
78
+ return !!(calleeName && (FORMAT_FUNCTION_NAMES.has(calleeName) || additionalFunctionNames.includes(calleeName)) && descriptor?.type !== "SpreadElement" && unwrapObjectExpression(descriptor));
73
79
  }
74
- function extractMessageDescriptor(node) {
75
- if (!node || node.type !== "ObjectExpression") return;
80
+ function extractMessageDescriptor(expression) {
81
+ const node = unwrapObjectExpression(expression);
82
+ if (!node) return;
76
83
  const result = {
77
84
  messageDescriptorNode: node,
78
85
  message: {},
@@ -82,8 +89,8 @@ function extractMessageDescriptor(node) {
82
89
  idValueNode: void 0
83
90
  };
84
91
  for (const prop of node.properties) {
85
- if (prop.type !== "Property" || prop.key.type !== "Identifier") continue;
86
- const propName = prop.key.name;
92
+ if (prop.type !== "Property") continue;
93
+ const propName = prop.key.type === "Identifier" ? prop.key.name : prop.key.type === "Literal" ? prop.key.value : void 0;
87
94
  if (propName !== "id" && propName !== "defaultMessage" && propName !== "description") continue;
88
95
  const valueNode = prop.value;
89
96
  const value = isStaticMessageExpression(valueNode) ? getStaticStringFromMessageExpression(valueNode) : void 0;
@@ -153,14 +160,13 @@ function extractMessageDescriptorFromJSXElement(node) {
153
160
  if (!result.messagePropNode && !result.descriptionNode && !result.idPropNode && hasSpreadAttribute) return;
154
161
  return [result, values];
155
162
  }
156
- function extractMessageDescriptors(node) {
157
- if (!node || node.type !== "ObjectExpression" || !node.properties.length) return [];
163
+ function extractMessageDescriptors(expression) {
164
+ const node = unwrapObjectExpression(expression);
165
+ if (!node) return [];
158
166
  const msgs = [];
159
167
  for (const prop of node.properties) {
160
168
  if (prop.type !== "Property") continue;
161
- const msg = prop.value;
162
- if (msg.type !== "ObjectExpression") continue;
163
- const nodeInfo = extractMessageDescriptor(msg);
169
+ const nodeInfo = extractMessageDescriptor(prop.value);
164
170
  if (nodeInfo) msgs.push(nodeInfo);
165
171
  }
166
172
  return msgs;
@@ -172,10 +178,13 @@ function extractMessages(node, { additionalComponentNames, additionalFunctionNam
172
178
  const args0 = node.arguments[0];
173
179
  const args1 = node.arguments[1];
174
180
  if (!args0 || args0.type === "SpreadElement") return [];
175
- if (!excludeMessageDeclCalls && isSingleMessageDescriptorDeclaration(node, DECLARATION_FUNCTION_NAMES) || isIntlFormatMessageCall(node) || isSingleMessageDescriptorDeclaration(node, allFormatFunctionNames)) {
181
+ const calleeName = getCalleeName(node.callee);
182
+ if (!calleeName) return [];
183
+ if (calleeName === "defineMessages") return excludeMessageDeclCalls ? [] : extractMessageDescriptors(args0).map((msg) => [msg, void 0]);
184
+ if (calleeName === "defineMessage" ? !excludeMessageDeclCalls : allFormatFunctionNames.has(calleeName)) {
176
185
  const msgDescriptorNodeInfo = extractMessageDescriptor(args0);
177
186
  if (msgDescriptorNodeInfo && (!args1 || args1.type !== "SpreadElement")) return [[msgDescriptorNodeInfo, args1]];
178
- } else if (!excludeMessageDeclCalls && isMultipleMessageDescriptorDeclaration(node)) return extractMessageDescriptors(args0).map((msg) => [msg, void 0]);
187
+ }
179
188
  } else if (node.type === "JSXOpeningElement" && node.name && node.name.type === "JSXIdentifier" && allComponentNames.has(node.name.name)) {
180
189
  const msgDescriptorNodeInfo = extractMessageDescriptorFromJSXElement(node);
181
190
  if (msgDescriptorNodeInfo) return [msgDescriptorNodeInfo];
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,KA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uBACd,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,kBAAkB,IAAI,KAAK,KAAK,IAAI,GACpC;EACA,MAAM,wBAAwB,uCAAuC,IAAI;EACzE,IAAI,uBACF,OAAO,CAAC,qBAAqB;CAEjC;CACA,OAAO,CAAC;AACV;;;;;;AAOA,SAAgB,aACd,aACA,KACA,SACe;CACf,IACE,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'])\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,wC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