eslint-plugin-formatjs 8.2.0 → 8.3.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.
Files changed (3) hide show
  1. package/index.js +175 -111
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -334,8 +334,8 @@ function checkPlaceholders(context, node) {
334
334
  // packages/eslint-plugin-formatjs/messages.ts
335
335
  const CORE_MESSAGES = { parseError: `Failed to parse message string {{error}}` };
336
336
  // packages/eslint-plugin-formatjs/rules/enforce-placeholders.ts
337
- const name$25 = "enforce-placeholders";
338
- const rule$23 = {
337
+ const name$26 = "enforce-placeholders";
338
+ const rule$24 = {
339
339
  meta: {
340
340
  type: "problem",
341
341
  docs: {
@@ -367,7 +367,7 @@ const rule$23 = {
367
367
  }
368
368
  };
369
369
  // packages/eslint-plugin-formatjs/rules/enforce-message-types.ts
370
- const name$24 = "enforce-message-types";
370
+ const name$25 = "enforce-message-types";
371
371
  const modules = /* @__PURE__ */ new Set([
372
372
  "@formatjs/intl",
373
373
  "react-intl",
@@ -788,7 +788,7 @@ function checkInlineMessage(context, node) {
788
788
  });
789
789
  return true;
790
790
  }
791
- const rule$22 = {
791
+ const rule$23 = {
792
792
  meta: {
793
793
  type: "problem",
794
794
  docs: { description: "Check ICU placeholders and optionally generate TypeScript argument contracts" },
@@ -809,7 +809,7 @@ const rule$22 = {
809
809
  additionalProperties: false
810
810
  }],
811
811
  messages: {
812
- ...rule$23.meta.messages,
812
+ ...rule$24.meta.messages,
813
813
  contract: "Generate or refresh the ICU argument contract.",
814
814
  invalid: "Cannot generate message types: {{error}}.",
815
815
  manual: "Unsupported number of generic arguments; update the call manually.",
@@ -1017,7 +1017,7 @@ const rule$22 = {
1017
1017
  }
1018
1018
  };
1019
1019
  // packages/eslint-plugin-formatjs/rules/blocklist-elements.ts
1020
- const name$23 = "blocklist-elements";
1020
+ const name$24 = "blocklist-elements";
1021
1021
  function getMessage(type) {
1022
1022
  return {
1023
1023
  messageId: "blocklist",
@@ -1070,7 +1070,7 @@ function verifyAst$8(blocklist, ast) {
1070
1070
  }
1071
1071
  return errors;
1072
1072
  }
1073
- function checkNode$18(context, node) {
1073
+ function checkNode$19(context, node) {
1074
1074
  const settings = getSettings(context);
1075
1075
  const msgs = extractMessages(node, settings);
1076
1076
  if (!msgs.length) return;
@@ -1096,7 +1096,7 @@ function checkNode$18(context, node) {
1096
1096
  });
1097
1097
  }
1098
1098
  }
1099
- const rule$21 = {
1099
+ const rule$22 = {
1100
1100
  meta: {
1101
1101
  type: "problem",
1102
1102
  docs: {
@@ -1140,11 +1140,11 @@ const rule$21 = {
1140
1140
  }
1141
1141
  },
1142
1142
  create(context) {
1143
- const callExpressionVisitor = (node) => checkNode$18(context, node);
1143
+ const callExpressionVisitor = (node) => checkNode$19(context, node);
1144
1144
  const parserServices = context.sourceCode.parserServices;
1145
1145
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1146
1146
  return {
1147
- JSXOpeningElement: (node) => checkNode$18(context, node),
1147
+ JSXOpeningElement: (node) => checkNode$19(context, node),
1148
1148
  CallExpression: callExpressionVisitor
1149
1149
  };
1150
1150
  }
@@ -1155,8 +1155,8 @@ let Option$1 = /* @__PURE__ */ function(Option) {
1155
1155
  Option["anything"] = "anything";
1156
1156
  return Option;
1157
1157
  }({});
1158
- const name$22 = "enforce-default-message";
1159
- function checkNode$17(context, node) {
1158
+ const name$23 = "enforce-default-message";
1159
+ function checkNode$18(context, node) {
1160
1160
  const msgs = extractMessages(node, getSettings(context));
1161
1161
  const { options: [type] } = context;
1162
1162
  for (const [{ message: { defaultMessage }, messageNode, messageDescriptorNode }] of msgs) if (!defaultMessage) {
@@ -1170,7 +1170,7 @@ function checkNode$17(context, node) {
1170
1170
  });
1171
1171
  }
1172
1172
  }
1173
- const rule$20 = {
1173
+ const rule$21 = {
1174
1174
  meta: {
1175
1175
  type: "problem",
1176
1176
  docs: {
@@ -1190,11 +1190,11 @@ const rule$20 = {
1190
1190
  }
1191
1191
  },
1192
1192
  create(context) {
1193
- const callExpressionVisitor = (node) => checkNode$17(context, node);
1193
+ const callExpressionVisitor = (node) => checkNode$18(context, node);
1194
1194
  const parserServices = context.sourceCode.parserServices;
1195
1195
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1196
1196
  return {
1197
- JSXOpeningElement: (node) => checkNode$17(context, node),
1197
+ JSXOpeningElement: (node) => checkNode$18(context, node),
1198
1198
  CallExpression: callExpressionVisitor
1199
1199
  };
1200
1200
  }
@@ -1219,7 +1219,7 @@ function normalizeOptions(raw) {
1219
1219
  minLength: void 0
1220
1220
  };
1221
1221
  }
1222
- function checkNode$16(context, node) {
1222
+ function checkNode$17(context, node) {
1223
1223
  const msgs = extractMessages(node, getSettings(context));
1224
1224
  const { mode: type, minLength } = normalizeOptions(context.options[0]);
1225
1225
  for (const [{ message: { description }, descriptionNode, messageDescriptorNode }] of msgs) if (!description) {
@@ -1240,8 +1240,8 @@ function checkNode$16(context, node) {
1240
1240
  }
1241
1241
  });
1242
1242
  }
1243
- const name$21 = "enforce-description";
1244
- const rule$19 = {
1243
+ const name$22 = "enforce-description";
1244
+ const rule$20 = {
1245
1245
  meta: {
1246
1246
  type: "problem",
1247
1247
  docs: {
@@ -1274,17 +1274,17 @@ const rule$19 = {
1274
1274
  }
1275
1275
  },
1276
1276
  create(context) {
1277
- const callExpressionVisitor = (node) => checkNode$16(context, node);
1277
+ const callExpressionVisitor = (node) => checkNode$17(context, node);
1278
1278
  const parserServices = context.sourceCode.parserServices;
1279
1279
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1280
1280
  return {
1281
- JSXOpeningElement: (node) => checkNode$16(context, node),
1281
+ JSXOpeningElement: (node) => checkNode$17(context, node),
1282
1282
  CallExpression: callExpressionVisitor
1283
1283
  };
1284
1284
  }
1285
1285
  };
1286
1286
  // packages/eslint-plugin-formatjs/rules/enforce-id.ts
1287
- function checkNode$15(context, node, { idInterpolationPattern, idWhitelistRegexps, quoteStyle }) {
1287
+ function checkNode$16(context, node, { idInterpolationPattern, idWhitelistRegexps, quoteStyle }) {
1288
1288
  const msgs = extractMessages(node, getSettings(context));
1289
1289
  for (const [{ message: { defaultMessage, description, id }, idPropNode, descriptionNode, messagePropNode, messageDescriptorNode }] of msgs) {
1290
1290
  if (!idInterpolationPattern && !idPropNode) {
@@ -1342,8 +1342,8 @@ function checkNode$15(context, node, { idInterpolationPattern, idWhitelistRegexp
1342
1342
  }
1343
1343
  }
1344
1344
  }
1345
- const name$20 = "enforce-id";
1346
- const rule$18 = {
1345
+ const name$21 = "enforce-id";
1346
+ const rule$19 = {
1347
1347
  meta: {
1348
1348
  type: "problem",
1349
1349
  docs: {
@@ -1394,11 +1394,11 @@ Actual: {{actual}}`
1394
1394
  const { idWhitelist } = tmp;
1395
1395
  opts.idWhitelistRegexps = idWhitelist.map((str) => new RegExp(str, "i"));
1396
1396
  }
1397
- const callExpressionVisitor = (node) => checkNode$15(context, node, opts);
1397
+ const callExpressionVisitor = (node) => checkNode$16(context, node, opts);
1398
1398
  const parserServices = context.sourceCode.parserServices;
1399
1399
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1400
1400
  return {
1401
- JSXOpeningElement: (node) => checkNode$15(context, node, opts),
1401
+ JSXOpeningElement: (node) => checkNode$16(context, node, opts),
1402
1402
  CallExpression: callExpressionVisitor
1403
1403
  };
1404
1404
  }
@@ -1432,7 +1432,7 @@ function verifyAst$7(plConfig, ast) {
1432
1432
  }
1433
1433
  return errors;
1434
1434
  }
1435
- function checkNode$14(context, node) {
1435
+ function checkNode$15(context, node) {
1436
1436
  const settings = getSettings(context);
1437
1437
  const msgs = extractMessages(node, settings);
1438
1438
  if (!msgs.length) return;
@@ -1458,8 +1458,8 @@ function checkNode$14(context, node) {
1458
1458
  });
1459
1459
  }
1460
1460
  }
1461
- const name$19 = "enforce-plural-rules";
1462
- const rule$17 = {
1461
+ const name$20 = "enforce-plural-rules";
1462
+ const rule$18 = {
1463
1463
  meta: {
1464
1464
  type: "problem",
1465
1465
  docs: {
@@ -1482,17 +1482,17 @@ const rule$17 = {
1482
1482
  }
1483
1483
  },
1484
1484
  create(context) {
1485
- const callExpressionVisitor = (node) => checkNode$14(context, node);
1485
+ const callExpressionVisitor = (node) => checkNode$15(context, node);
1486
1486
  const parserServices = context.sourceCode.parserServices;
1487
1487
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1488
1488
  return {
1489
- JSXOpeningElement: (node) => checkNode$14(context, node),
1489
+ JSXOpeningElement: (node) => checkNode$15(context, node),
1490
1490
  CallExpression: callExpressionVisitor
1491
1491
  };
1492
1492
  }
1493
1493
  };
1494
1494
  // packages/eslint-plugin-formatjs/rules/no-camel-case.ts
1495
- const name$18 = "no-camel-case";
1495
+ const name$19 = "no-camel-case";
1496
1496
  const CAMEL_CASE_REGEX = /[A-Z]/;
1497
1497
  function verifyAst$6(ast) {
1498
1498
  const errors = [];
@@ -1515,7 +1515,7 @@ function verifyAst$6(ast) {
1515
1515
  }
1516
1516
  return errors;
1517
1517
  }
1518
- function checkNode$13(context, node) {
1518
+ function checkNode$14(context, node) {
1519
1519
  const settings = getSettings(context);
1520
1520
  const msgs = extractMessages(node, settings);
1521
1521
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
@@ -1538,7 +1538,7 @@ function checkNode$13(context, node) {
1538
1538
  });
1539
1539
  }
1540
1540
  }
1541
- const rule$16 = {
1541
+ const rule$17 = {
1542
1542
  meta: {
1543
1543
  type: "problem",
1544
1544
  docs: {
@@ -1553,11 +1553,11 @@ const rule$16 = {
1553
1553
  }
1554
1554
  },
1555
1555
  create(context) {
1556
- const callExpressionVisitor = (node) => checkNode$13(context, node);
1556
+ const callExpressionVisitor = (node) => checkNode$14(context, node);
1557
1557
  const parserServices = context.sourceCode.parserServices;
1558
1558
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1559
1559
  return {
1560
- JSXOpeningElement: (node) => checkNode$13(context, node),
1560
+ JSXOpeningElement: (node) => checkNode$14(context, node),
1561
1561
  CallExpression: callExpressionVisitor
1562
1562
  };
1563
1563
  }
@@ -1589,7 +1589,7 @@ function calculateComplexity(ast) {
1589
1589
  return complexity;
1590
1590
  }
1591
1591
  }
1592
- function checkNode$12(context, node) {
1592
+ function checkNode$13(context, node) {
1593
1593
  const settings = getSettings(context);
1594
1594
  const msgs = extractMessages(node, settings);
1595
1595
  if (!msgs.length) return;
@@ -1621,8 +1621,8 @@ function checkNode$12(context, node) {
1621
1621
  });
1622
1622
  }
1623
1623
  }
1624
- const name$17 = "no-complex-selectors";
1625
- const rule$15 = {
1624
+ const name$18 = "no-complex-selectors";
1625
+ const rule$16 = {
1626
1626
  meta: {
1627
1627
  type: "problem",
1628
1628
  docs: {
@@ -1649,11 +1649,11 @@ Default complexity limit is 20
1649
1649
  }
1650
1650
  },
1651
1651
  create(context) {
1652
- const callExpressionVisitor = (node) => checkNode$12(context, node);
1652
+ const callExpressionVisitor = (node) => checkNode$13(context, node);
1653
1653
  const parserServices = context.sourceCode.parserServices;
1654
1654
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
1655
1655
  return {
1656
- JSXOpeningElement: (node) => checkNode$12(context, node),
1656
+ JSXOpeningElement: (node) => checkNode$13(context, node),
1657
1657
  CallExpression: callExpressionVisitor
1658
1658
  };
1659
1659
  }
@@ -4280,8 +4280,8 @@ function parseVersion(version) {
4280
4280
  return parseFloat(version);
4281
4281
  }
4282
4282
  // packages/eslint-plugin-formatjs/rules/no-emoji.ts
4283
- const name$16 = "no-emoji";
4284
- function checkNode$11(context, node) {
4283
+ const name$17 = "no-emoji";
4284
+ function checkNode$12(context, node) {
4285
4285
  const msgs = extractMessages(node, getSettings(context));
4286
4286
  let versionAbove;
4287
4287
  const [emojiConfig] = context.options;
@@ -4306,7 +4306,7 @@ function checkNode$11(context, node) {
4306
4306
  }
4307
4307
  }
4308
4308
  }
4309
- const rule$14 = {
4309
+ const rule$15 = {
4310
4310
  meta: {
4311
4311
  type: "problem",
4312
4312
  docs: {
@@ -4343,11 +4343,11 @@ const rule$14 = {
4343
4343
  }
4344
4344
  },
4345
4345
  create(context) {
4346
- const callExpressionVisitor = (node) => checkNode$11(context, node);
4346
+ const callExpressionVisitor = (node) => checkNode$12(context, node);
4347
4347
  const parserServices = context.sourceCode.parserServices;
4348
4348
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4349
4349
  return {
4350
- JSXOpeningElement: (node) => checkNode$11(context, node),
4350
+ JSXOpeningElement: (node) => checkNode$12(context, node),
4351
4351
  CallExpression: callExpressionVisitor
4352
4352
  };
4353
4353
  }
@@ -4356,8 +4356,8 @@ const rule$14 = {
4356
4356
  function isComment(token) {
4357
4357
  return !!token && (token.type === "Block" || token.type === "Line");
4358
4358
  }
4359
- const name$15 = "no-id";
4360
- function checkNode$10(context, node) {
4359
+ const name$16 = "no-id";
4360
+ function checkNode$11(context, node) {
4361
4361
  const msgs = extractMessages(node, getSettings(context));
4362
4362
  for (const [{ idPropNode }] of msgs) if (idPropNode) context.report({
4363
4363
  node: idPropNode,
@@ -4370,7 +4370,7 @@ function checkNode$10(context, node) {
4370
4370
  }
4371
4371
  });
4372
4372
  }
4373
- const rule$13 = {
4373
+ const rule$14 = {
4374
4374
  meta: {
4375
4375
  type: "problem",
4376
4376
  docs: {
@@ -4382,18 +4382,18 @@ const rule$13 = {
4382
4382
  messages: { noId: "Manual `id` are not allowed in message descriptor" }
4383
4383
  },
4384
4384
  create(context) {
4385
- const callExpressionVisitor = (node) => checkNode$10(context, node);
4385
+ const callExpressionVisitor = (node) => checkNode$11(context, node);
4386
4386
  const parserServices = context.sourceCode.parserServices;
4387
4387
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4388
4388
  return {
4389
- JSXOpeningElement: (node) => checkNode$10(context, node),
4389
+ JSXOpeningElement: (node) => checkNode$11(context, node),
4390
4390
  CallExpression: callExpressionVisitor
4391
4391
  };
4392
4392
  }
4393
4393
  };
4394
4394
  // packages/eslint-plugin-formatjs/rules/no-invalid-icu.ts
4395
- const name$14 = "no-invalid-icu";
4396
- function checkNode$9(context, node) {
4395
+ const name$15 = "no-invalid-icu";
4396
+ function checkNode$10(context, node) {
4397
4397
  const settings = getSettings(context);
4398
4398
  let msgs;
4399
4399
  try {
@@ -4420,7 +4420,7 @@ function checkNode$9(context, node) {
4420
4420
  }
4421
4421
  }
4422
4422
  }
4423
- const rule$12 = {
4423
+ const rule$13 = {
4424
4424
  meta: {
4425
4425
  type: "problem",
4426
4426
  docs: { description: `Make sure ICU messages are formatted correctly with no bad select statements, plurals, etc.` },
@@ -4429,11 +4429,11 @@ const rule$12 = {
4429
4429
  messages: CORE_MESSAGES
4430
4430
  },
4431
4431
  create(context) {
4432
- const callExpressionVisitor = (node) => checkNode$9(context, node);
4432
+ const callExpressionVisitor = (node) => checkNode$10(context, node);
4433
4433
  const parserServices = context.sourceCode.parserServices;
4434
4434
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4435
4435
  return {
4436
- JSXOpeningElement: (node) => checkNode$9(context, node),
4436
+ JSXOpeningElement: (node) => checkNode$10(context, node),
4437
4437
  CallExpression: callExpressionVisitor
4438
4438
  };
4439
4439
  }
@@ -4465,8 +4465,8 @@ function compilePropMatcher(propMatcher) {
4465
4465
  return [picomatch.makeRe(tagNamePattern, { contains: false }), picomatch.makeRe(propNamePattern, { contains: false })];
4466
4466
  });
4467
4467
  }
4468
- const name$13 = "no-literal-string-in-jsx";
4469
- const rule$11 = {
4468
+ const name$14 = "no-literal-string-in-jsx";
4469
+ const rule$12 = {
4470
4470
  meta: {
4471
4471
  type: "problem",
4472
4472
  docs: {
@@ -4562,7 +4562,7 @@ const rule$11 = {
4562
4562
  }
4563
4563
  };
4564
4564
  // packages/eslint-plugin-formatjs/rules/no-missing-icu-plural-one-placeholders.ts
4565
- const name$12 = "no-missing-icu-plural-one-placeholders";
4565
+ const name$13 = "no-missing-icu-plural-one-placeholders";
4566
4566
  function verifyAst$5(context, messageNode, ast) {
4567
4567
  const patches = [];
4568
4568
  _verifyAstAndReplace(ast);
@@ -4597,7 +4597,7 @@ function verifyAst$5(context, messageNode, ast) {
4597
4597
  }
4598
4598
  }
4599
4599
  }
4600
- function checkNode$8(context, node) {
4600
+ function checkNode$9(context, node) {
4601
4601
  const msgs = extractMessages(node);
4602
4602
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
4603
4603
  if (!defaultMessage || !messageNode) continue;
@@ -4615,7 +4615,7 @@ function checkNode$8(context, node) {
4615
4615
  verifyAst$5(context, messageNode, ast);
4616
4616
  }
4617
4617
  }
4618
- const rule$10 = {
4618
+ const rule$11 = {
4619
4619
  meta: {
4620
4620
  type: "problem",
4621
4621
  docs: {
@@ -4630,11 +4630,11 @@ const rule$10 = {
4630
4630
  schema: []
4631
4631
  },
4632
4632
  create(context) {
4633
- const callExpressionVisitor = (node) => checkNode$8(context, node);
4633
+ const callExpressionVisitor = (node) => checkNode$9(context, node);
4634
4634
  const parserServices = context.sourceCode.parserServices;
4635
4635
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4636
4636
  return {
4637
- JSXOpeningElement: (node) => checkNode$8(context, node),
4637
+ JSXOpeningElement: (node) => checkNode$9(context, node),
4638
4638
  CallExpression: callExpressionVisitor
4639
4639
  };
4640
4640
  }
@@ -4653,7 +4653,7 @@ function verifyAst$4(ast, pluralCount = { count: 0 }) {
4653
4653
  }
4654
4654
  return errors;
4655
4655
  }
4656
- function checkNode$7(context, node) {
4656
+ function checkNode$8(context, node) {
4657
4657
  const settings = getSettings(context);
4658
4658
  const msgs = extractMessages(node, settings);
4659
4659
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
@@ -4676,8 +4676,8 @@ function checkNode$7(context, node) {
4676
4676
  });
4677
4677
  }
4678
4678
  }
4679
- const name$11 = "no-multiple-plurals";
4680
- const rule$9 = {
4679
+ const name$12 = "no-multiple-plurals";
4680
+ const rule$10 = {
4681
4681
  meta: {
4682
4682
  type: "problem",
4683
4683
  docs: {
@@ -4692,11 +4692,11 @@ const rule$9 = {
4692
4692
  }
4693
4693
  },
4694
4694
  create(context) {
4695
- const callExpressionVisitor = (node) => checkNode$7(context, node);
4695
+ const callExpressionVisitor = (node) => checkNode$8(context, node);
4696
4696
  const parserServices = context.sourceCode.parserServices;
4697
4697
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4698
4698
  return {
4699
- JSXOpeningElement: (node) => checkNode$7(context, node),
4699
+ JSXOpeningElement: (node) => checkNode$8(context, node),
4700
4700
  CallExpression: callExpressionVisitor
4701
4701
  };
4702
4702
  }
@@ -4753,7 +4753,7 @@ function trimMultiWhitespaces(message, ast) {
4753
4753
  trimmedFragments.push(message.slice(currentOffset));
4754
4754
  return trimmedFragments.join("");
4755
4755
  }
4756
- function checkNode$6(context, node) {
4756
+ function checkNode$7(context, node) {
4757
4757
  const msgs = extractMessages(node, getSettings(context));
4758
4758
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
4759
4759
  if (!defaultMessage || !messageNode) continue;
@@ -4778,8 +4778,8 @@ function checkNode$6(context, node) {
4778
4778
  }
4779
4779
  }
4780
4780
  }
4781
- const name$10 = "no-multiple-whitespaces";
4782
- const rule$8 = {
4781
+ const name$11 = "no-multiple-whitespaces";
4782
+ const rule$9 = {
4783
4783
  meta: {
4784
4784
  type: "problem",
4785
4785
  docs: {
@@ -4794,11 +4794,11 @@ const rule$8 = {
4794
4794
  schema: []
4795
4795
  },
4796
4796
  create(context) {
4797
- const callExpressionVisitor = (node) => checkNode$6(context, node);
4797
+ const callExpressionVisitor = (node) => checkNode$7(context, node);
4798
4798
  const parserServices = context.sourceCode.parserServices;
4799
4799
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4800
4800
  return {
4801
- JSXOpeningElement: (node) => checkNode$6(context, node),
4801
+ JSXOpeningElement: (node) => checkNode$7(context, node),
4802
4802
  CallExpression: callExpressionVisitor
4803
4803
  };
4804
4804
  }
@@ -4816,7 +4816,7 @@ function verifyAst$3(ast) {
4816
4816
  }
4817
4817
  return errors;
4818
4818
  }
4819
- function checkNode$5(context, node) {
4819
+ function checkNode$6(context, node) {
4820
4820
  const settings = getSettings(context);
4821
4821
  const msgs = extractMessages(node, settings);
4822
4822
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
@@ -4839,8 +4839,8 @@ function checkNode$5(context, node) {
4839
4839
  });
4840
4840
  }
4841
4841
  }
4842
- const name$9 = "no-offset";
4843
- const rule$7 = {
4842
+ const name$10 = "no-offset";
4843
+ const rule$8 = {
4844
4844
  meta: {
4845
4845
  type: "problem",
4846
4846
  docs: {
@@ -4855,11 +4855,11 @@ const rule$7 = {
4855
4855
  schema: []
4856
4856
  },
4857
4857
  create(context) {
4858
- const callExpressionVisitor = (node) => checkNode$5(context, node);
4858
+ const callExpressionVisitor = (node) => checkNode$6(context, node);
4859
4859
  const parserServices = context.sourceCode.parserServices;
4860
4860
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4861
4861
  return {
4862
- JSXOpeningElement: (node) => checkNode$5(context, node),
4862
+ JSXOpeningElement: (node) => checkNode$6(context, node),
4863
4863
  CallExpression: callExpressionVisitor
4864
4864
  };
4865
4865
  }
@@ -4874,7 +4874,7 @@ function verifyAst$2(ast) {
4874
4874
  case TYPE.time: return "unnecessaryFormatTime";
4875
4875
  }
4876
4876
  }
4877
- function checkNode$4(context, node) {
4877
+ function checkNode$5(context, node) {
4878
4878
  const settings = getSettings(context);
4879
4879
  const msgs = extractMessages(node, settings);
4880
4880
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
@@ -4897,8 +4897,8 @@ function checkNode$4(context, node) {
4897
4897
  });
4898
4898
  }
4899
4899
  }
4900
- const name$8 = "no-useless-message";
4901
- const rule$6 = {
4900
+ const name$9 = "no-useless-message";
4901
+ const rule$7 = {
4902
4902
  meta: {
4903
4903
  type: "problem",
4904
4904
  docs: {
@@ -4916,17 +4916,17 @@ const rule$6 = {
4916
4916
  }
4917
4917
  },
4918
4918
  create(context) {
4919
- const callExpressionVisitor = (node) => checkNode$4(context, node);
4919
+ const callExpressionVisitor = (node) => checkNode$5(context, node);
4920
4920
  const parserServices = context.sourceCode.parserServices;
4921
4921
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
4922
4922
  return {
4923
- JSXOpeningElement: (node) => checkNode$4(context, node),
4923
+ JSXOpeningElement: (node) => checkNode$5(context, node),
4924
4924
  CallExpression: callExpressionVisitor
4925
4925
  };
4926
4926
  }
4927
4927
  };
4928
4928
  // packages/eslint-plugin-formatjs/rules/prefer-formatted-message.ts
4929
- const name$7 = "prefer-formatted-message";
4929
+ const name$8 = "prefer-formatted-message";
4930
4930
  function binding(context, node, name) {
4931
4931
  let scope = context.sourceCode.getScope(node);
4932
4932
  while (scope) {
@@ -4977,7 +4977,7 @@ function component(context, node) {
4977
4977
  insert: (fixer) => fixer.insertTextBefore(anchor, specifier + ", ")
4978
4978
  };
4979
4979
  }
4980
- const rule$5 = {
4980
+ const rule$6 = {
4981
4981
  meta: {
4982
4982
  type: "suggestion",
4983
4983
  fixable: "code",
@@ -5105,7 +5105,7 @@ function verifyAst$1(context, messageNode, ast) {
5105
5105
  });
5106
5106
  }
5107
5107
  }
5108
- function checkNode$3(context, node) {
5108
+ function checkNode$4(context, node) {
5109
5109
  const msgs = extractMessages(node, getSettings(context));
5110
5110
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
5111
5111
  if (!defaultMessage || !messageNode) continue;
@@ -5123,8 +5123,8 @@ function checkNode$3(context, node) {
5123
5123
  verifyAst$1(context, messageNode, ast);
5124
5124
  }
5125
5125
  }
5126
- const name$6 = "prefer-pound-in-plural";
5127
- const rule$4 = {
5126
+ const name$7 = "prefer-pound-in-plural";
5127
+ const rule$5 = {
5128
5128
  meta: {
5129
5129
  type: "suggestion",
5130
5130
  docs: {
@@ -5139,18 +5139,18 @@ const rule$4 = {
5139
5139
  schema: []
5140
5140
  },
5141
5141
  create(context) {
5142
- const callExpressionVisitor = (node) => checkNode$3(context, node);
5142
+ const callExpressionVisitor = (node) => checkNode$4(context, node);
5143
5143
  const parserServices = context.sourceCode.parserServices;
5144
5144
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
5145
5145
  return {
5146
- JSXOpeningElement: (node) => checkNode$3(context, node),
5146
+ JSXOpeningElement: (node) => checkNode$4(context, node),
5147
5147
  CallExpression: callExpressionVisitor
5148
5148
  };
5149
5149
  }
5150
5150
  };
5151
5151
  // packages/eslint-plugin-formatjs/rules/no-literal-string-in-object.ts
5152
- const name$5 = "no-literal-string-in-object";
5153
- const rule$3 = {
5152
+ const name$6 = "no-literal-string-in-object";
5153
+ const rule$4 = {
5154
5154
  meta: {
5155
5155
  type: "problem",
5156
5156
  docs: {
@@ -5247,7 +5247,7 @@ function findMessageIssues(ast) {
5247
5247
  }
5248
5248
  return issues;
5249
5249
  }
5250
- function checkNode$2(context, node) {
5250
+ function checkNode$3(context, node) {
5251
5251
  const msgs = extractMessages(node, getSettings(context));
5252
5252
  for (const [{ message: { defaultMessage }, messageNode }] of msgs) {
5253
5253
  if (!defaultMessage || !messageNode) continue;
@@ -5274,8 +5274,8 @@ function checkNode$2(context, node) {
5274
5274
  }
5275
5275
  }
5276
5276
  }
5277
- const name$4 = "prefer-full-sentence";
5278
- const rule$2 = {
5277
+ const name$5 = "prefer-full-sentence";
5278
+ const rule$3 = {
5279
5279
  meta: {
5280
5280
  type: "suggestion",
5281
5281
  docs: {
@@ -5291,11 +5291,11 @@ const rule$2 = {
5291
5291
  schema: []
5292
5292
  },
5293
5293
  create(context) {
5294
- const callExpressionVisitor = (node) => checkNode$2(context, node);
5294
+ const callExpressionVisitor = (node) => checkNode$3(context, node);
5295
5295
  const parserServices = context.sourceCode.parserServices;
5296
5296
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
5297
5297
  return {
5298
- JSXOpeningElement: (node) => checkNode$2(context, node),
5298
+ JSXOpeningElement: (node) => checkNode$3(context, node),
5299
5299
  CallExpression: callExpressionVisitor
5300
5300
  };
5301
5301
  }
@@ -5384,7 +5384,7 @@ function verifyAst(ast, errors) {
5384
5384
  case TYPE.tag: verifyAst(element.children, errors);
5385
5385
  }
5386
5386
  }
5387
- function checkNode$1(context, node) {
5387
+ function checkNode$2(context, node) {
5388
5388
  const settings = getSettings(context);
5389
5389
  for (const [{ message, messageNode }] of extractMessages(node, settings)) {
5390
5390
  if (!message.defaultMessage || !messageNode) continue;
@@ -5407,8 +5407,8 @@ function checkNode$1(context, node) {
5407
5407
  });
5408
5408
  }
5409
5409
  }
5410
- const name$3 = "no-literal-number-symbol";
5411
- const rule$1 = {
5410
+ const name$4 = "no-literal-number-symbol";
5411
+ const rule$2 = {
5412
5412
  meta: {
5413
5413
  type: "problem",
5414
5414
  docs: {
@@ -5426,11 +5426,11 @@ const rule$1 = {
5426
5426
  schema: []
5427
5427
  },
5428
5428
  create(context) {
5429
- const callExpressionVisitor = (node) => checkNode$1(context, node);
5429
+ const callExpressionVisitor = (node) => checkNode$2(context, node);
5430
5430
  const parserServices = context.sourceCode.parserServices;
5431
5431
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
5432
5432
  return {
5433
- JSXOpeningElement: (node) => checkNode$1(context, node),
5433
+ JSXOpeningElement: (node) => checkNode$2(context, node),
5434
5434
  CallExpression: callExpressionVisitor
5435
5435
  };
5436
5436
  }
@@ -5473,7 +5473,7 @@ function findCount(ast, countPattern) {
5473
5473
  }
5474
5474
  }
5475
5475
  }
5476
- function checkNode(context, node, countPattern) {
5476
+ function checkNode$1(context, node, countPattern) {
5477
5477
  const settings = getSettings(context);
5478
5478
  for (const [{ message, messageNode }] of extractMessages(node, settings)) {
5479
5479
  if (!message.defaultMessage || !messageNode) continue;
@@ -5496,8 +5496,8 @@ function checkNode(context, node, countPattern) {
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const name$2 = "no-count-without-plural";
5500
- const rule = {
5499
+ const name$3 = "no-count-without-plural";
5500
+ const rule$1 = {
5501
5501
  meta: {
5502
5502
  type: "problem",
5503
5503
  docs: {
@@ -5517,11 +5517,73 @@ const rule = {
5517
5517
  create(context) {
5518
5518
  const options = context.options[0] ?? {};
5519
5519
  const countPattern = new RegExp(options.countPattern ?? DEFAULT_COUNT_PATTERN, "u");
5520
- const callExpressionVisitor = (node) => checkNode(context, node, countPattern);
5520
+ const callExpressionVisitor = (node) => checkNode$1(context, node, countPattern);
5521
5521
  const parserServices = context.sourceCode.parserServices;
5522
5522
  if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
5523
5523
  return {
5524
- JSXOpeningElement: (node) => checkNode(context, node, countPattern),
5524
+ JSXOpeningElement: (node) => checkNode$1(context, node, countPattern),
5525
+ CallExpression: callExpressionVisitor
5526
+ };
5527
+ }
5528
+ };
5529
+ // packages/eslint-plugin-formatjs/rules/no-literal-template-placeholder.ts
5530
+ const TEMPLATE_PLACEHOLDER = new RegExp([String.raw`\{\{\s*[\p{L}_$][\p{L}\p{N}_$.]*\s*\}\}`, String.raw`%(?:%|(?:\d+\$)?(?:\([\p{L}_][\p{L}\p{N}_]*\))?[sd@])`].join("|"), "gu");
5531
+ function findTokens(ast, tokens) {
5532
+ for (const element of ast) switch (element.type) {
5533
+ case TYPE.literal:
5534
+ for (const [token] of element.value.matchAll(TEMPLATE_PLACEHOLDER)) if (token !== "%%") tokens.add(token);
5535
+ break;
5536
+ case TYPE.plural:
5537
+ case TYPE.select:
5538
+ for (const option of Object.values(element.options)) findTokens(option.value, tokens);
5539
+ break;
5540
+ case TYPE.tag: findTokens(element.children, tokens);
5541
+ }
5542
+ }
5543
+ function checkNode(context, node) {
5544
+ const settings = getSettings(context);
5545
+ for (const [{ message, messageNode }] of extractMessages(node, settings)) {
5546
+ if (!message.defaultMessage || !messageNode) continue;
5547
+ let ast;
5548
+ try {
5549
+ ast = parse(message.defaultMessage, { ignoreTag: settings.ignoreTag });
5550
+ } catch (e) {
5551
+ context.report({
5552
+ node: messageNode,
5553
+ messageId: "parseError",
5554
+ data: { error: e.message }
5555
+ });
5556
+ continue;
5557
+ }
5558
+ const tokens = /* @__PURE__ */ new Set();
5559
+ findTokens(ast, tokens);
5560
+ for (const token of tokens) context.report({
5561
+ node: messageNode,
5562
+ messageId: "literalTemplatePlaceholder",
5563
+ data: { token }
5564
+ });
5565
+ }
5566
+ }
5567
+ const name$2 = "no-literal-template-placeholder";
5568
+ const rule = {
5569
+ meta: {
5570
+ type: "problem",
5571
+ docs: {
5572
+ description: "Disallow non-ICU template placeholders like `{{name}}` or `%s` in message text",
5573
+ url: "https://formatjs.github.io/docs/tooling/linter#no-literal-template-placeholder"
5574
+ },
5575
+ messages: {
5576
+ ...CORE_MESSAGES,
5577
+ literalTemplatePlaceholder: "`{{token}}` is literal text in ICU, not a placeholder. Use an ICU argument like `{name}` and pass the value when formatting, instead of replacing the token after translation."
5578
+ },
5579
+ schema: []
5580
+ },
5581
+ create(context) {
5582
+ const callExpressionVisitor = (node) => checkNode(context, node);
5583
+ const parserServices = context.sourceCode.parserServices;
5584
+ if (parserServices?.defineTemplateBodyVisitor) return parserServices.defineTemplateBodyVisitor({ CallExpression: callExpressionVisitor }, { CallExpression: callExpressionVisitor });
5585
+ return {
5586
+ JSXOpeningElement: (node) => checkNode(context, node),
5525
5587
  CallExpression: callExpressionVisitor
5526
5588
  };
5527
5589
  }
@@ -5546,7 +5608,7 @@ var package_exports = /* @__PURE__ */ __exportAll({
5546
5608
  version: () => version$1
5547
5609
  });
5548
5610
  var name$1 = "eslint-plugin-formatjs";
5549
- var version$1 = "8.2.0";
5611
+ var version$1 = "8.3.0";
5550
5612
  var description = "ESLint plugin for formatjs";
5551
5613
  var keywords = [
5552
5614
  "eslint",
@@ -5601,26 +5663,27 @@ const plugin = {
5601
5663
  version
5602
5664
  },
5603
5665
  rules: {
5666
+ [name$25]: rule$23,
5604
5667
  [name$24]: rule$22,
5605
5668
  [name$23]: rule$21,
5606
5669
  [name$22]: rule$20,
5607
5670
  [name$21]: rule$19,
5671
+ [name$26]: rule$24,
5608
5672
  [name$20]: rule$18,
5609
- [name$25]: rule$23,
5610
5673
  [name$19]: rule$17,
5611
5674
  [name$18]: rule$16,
5612
5675
  [name$17]: rule$15,
5613
5676
  [name$16]: rule$14,
5614
5677
  [name$15]: rule$13,
5615
5678
  [name$14]: rule$12,
5616
- [name$13]: rule$11,
5679
+ [name$12]: rule$10,
5617
5680
  [name$11]: rule$9,
5618
5681
  [name$10]: rule$8,
5619
5682
  [name$9]: rule$7,
5620
5683
  [name$8]: rule$6,
5621
5684
  [name$7]: rule$5,
5685
+ [name$13]: rule$11,
5622
5686
  [name$6]: rule$4,
5623
- [name$12]: rule$10,
5624
5687
  [name$5]: rule$3,
5625
5688
  [name$4]: rule$2,
5626
5689
  [name$3]: rule$1,
@@ -5663,7 +5726,8 @@ plugin.configs = {
5663
5726
  }]],
5664
5727
  "formatjs/prefer-full-sentence": "error",
5665
5728
  "formatjs/no-literal-number-symbol": "error",
5666
- "formatjs/no-count-without-plural": "error"
5729
+ "formatjs/no-count-without-plural": "error",
5730
+ "formatjs/no-literal-template-placeholder": "error"
5667
5731
  }
5668
5732
  },
5669
5733
  recommended: {