eslint-plugin-formatjs 2.18.0 → 2.20.1

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": "2.18.0",
3
+ "version": "2.20.1",
4
4
  "description": "ESLint plugin for formatjs",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -20,15 +20,15 @@
20
20
  },
21
21
  "homepage": "https://github.com/formatjs/formatjs#readme",
22
22
  "dependencies": {
23
- "@formatjs/icu-messageformat-parser": "2.0.14",
24
- "@formatjs/ts-transformer": "3.6.0",
25
- "@types/eslint": "^7.2.0",
23
+ "@formatjs/icu-messageformat-parser": "2.0.16",
24
+ "@formatjs/ts-transformer": "3.8.1",
25
+ "@types/eslint": "8",
26
26
  "@typescript-eslint/typescript-estree": "^4.11.0",
27
27
  "emoji-regex": "^9.2.0",
28
28
  "tslib": "^2.1.0",
29
- "typescript": "^4.4"
29
+ "typescript": "^4.5"
30
30
  },
31
31
  "peerDependencies": {
32
- "eslint": "^7.4.0"
32
+ "eslint": "8"
33
33
  }
34
34
  }
@@ -7,7 +7,7 @@ var BlacklistElement = /** @class */ (function (_super) {
7
7
  (0, tslib_1.__extends)(BlacklistElement, _super);
8
8
  function BlacklistElement(type) {
9
9
  var _this = _super.call(this) || this;
10
- _this.message = type + " element is blacklisted";
10
+ _this.message = "".concat(type, " element is blacklisted");
11
11
  return _this;
12
12
  }
13
13
  return BlacklistElement;
@@ -32,25 +32,25 @@ function checkNode(context, node) {
32
32
  resourcePath: context.getFilename(),
33
33
  }, idInterpolationPattern, {
34
34
  content: description
35
- ? defaultMessage + "#" + description
35
+ ? "".concat(defaultMessage, "#").concat(description)
36
36
  : defaultMessage,
37
37
  });
38
38
  if (id !== correctId_1) {
39
39
  context.report({
40
40
  node: node,
41
- message: "\"id\" does not match with hash pattern " + idInterpolationPattern + ".\nExpected: " + correctId_1 + "\nActual: " + id,
41
+ message: "\"id\" does not match with hash pattern ".concat(idInterpolationPattern, ".\nExpected: ").concat(correctId_1, "\nActual: ").concat(id),
42
42
  fix: function (fixer) {
43
43
  if (idPropNode) {
44
44
  if (idPropNode.type === 'JSXAttribute') {
45
- return fixer.replaceText(idPropNode, "id=\"" + correctId_1 + "\"");
45
+ return fixer.replaceText(idPropNode, "id=\"".concat(correctId_1, "\""));
46
46
  }
47
- return fixer.replaceText(idPropNode, "id: '" + correctId_1 + "'");
47
+ return fixer.replaceText(idPropNode, "id: '".concat(correctId_1, "'"));
48
48
  }
49
49
  // Insert after default message node
50
50
  if (messagePropNode.type === 'JSXAttribute') {
51
- return fixer.insertTextAfter(messagePropNode, " id=\"" + correctId_1 + "\"");
51
+ return fixer.insertTextAfter(messagePropNode, " id=\"".concat(correctId_1, "\""));
52
52
  }
53
- return fixer.replaceText(messagePropNode, "defaultMessage: '" + defaultMessage + "', id: '" + correctId_1 + "'");
53
+ return fixer.replaceText(messagePropNode, "defaultMessage: '".concat(defaultMessage, "', id: '").concat(correctId_1, "'"));
54
54
  },
55
55
  });
56
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enforce-placeholders.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-formatjs/rules/enforce-placeholders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AA2G3B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA6ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"enforce-placeholders.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-formatjs/rules/enforce-placeholders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAgH3B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA6ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -43,7 +43,7 @@ function verifyAst(ast, values, ignoreList) {
43
43
  }
44
44
  var key = el.value;
45
45
  if (!ignoreList.has(key) && !keyExistsInExpression(key, values)) {
46
- throw new PlaceholderEnforcement("Missing value for placeholder \"" + el.value + "\"");
46
+ throw new PlaceholderEnforcement("Missing value for placeholder \"".concat(el.value, "\""));
47
47
  }
48
48
  if ((0, icu_messageformat_parser_1.isPluralElement)(el) || (0, icu_messageformat_parser_1.isSelectElement)(el)) {
49
49
  for (var _a = 0, _b = Object.keys(el.options); _a < _b.length; _a++) {
@@ -51,6 +51,9 @@ function verifyAst(ast, values, ignoreList) {
51
51
  verifyAst(el.options[selector].value, values, ignoreList);
52
52
  }
53
53
  }
54
+ if ((0, icu_messageformat_parser_1.isTagElement)(el)) {
55
+ verifyAst(el.children, values, ignoreList);
56
+ }
54
57
  }
55
58
  }
56
59
  function checkNode(context, node) {
@@ -29,10 +29,10 @@ function verifyAst(plConfig, ast) {
29
29
  for (var _a = 0, rules_1 = rules; _a < rules_1.length; _a++) {
30
30
  var rule_1 = rules_1[_a];
31
31
  if (plConfig[rule_1] && !el.options[rule_1]) {
32
- throw new PluralRulesEnforcement("Missing plural rule \"" + rule_1 + "\"");
32
+ throw new PluralRulesEnforcement("Missing plural rule \"".concat(rule_1, "\""));
33
33
  }
34
34
  if (!plConfig[rule_1] && el.options[rule_1]) {
35
- throw new PluralRulesEnforcement("Plural rule \"" + rule_1 + "\" is forbidden");
35
+ throw new PluralRulesEnforcement("Plural rule \"".concat(rule_1, "\" is forbidden"));
36
36
  }
37
37
  }
38
38
  var options = el.options;
@@ -33,7 +33,7 @@ function checkNode(context, node) {
33
33
  if (complexity > config.limit) {
34
34
  context.report({
35
35
  node: messageNode,
36
- message: "Message complexity is too high (" + complexity + " vs limit at " + config.limit + ")",
36
+ message: "Message complexity is too high (".concat(complexity, " vs limit at ").concat(config.limit, ")"),
37
37
  });
38
38
  }
39
39
  }
package/util.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["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@@ -106,8 +106,13 @@ function extractMessageDescriptorFromJSXElement(node) {
106
106
  idValueNode: undefined,
107
107
  idPropNode: undefined,
108
108
  };
109
+ var hasSpreadAttribute = false;
109
110
  for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) {
110
111
  var prop = _a[_i];
112
+ // We can't analyze spread attr
113
+ if (prop.type === 'JSXSpreadAttribute') {
114
+ hasSpreadAttribute = true;
115
+ }
111
116
  if (prop.type !== 'JSXAttribute' || prop.name.type !== 'JSXIdentifier') {
112
117
  continue;
113
118
  }
@@ -162,7 +167,8 @@ function extractMessageDescriptorFromJSXElement(node) {
162
167
  }
163
168
  if (!result.messagePropNode &&
164
169
  !result.descriptionNode &&
165
- !result.idPropNode) {
170
+ !result.idPropNode &&
171
+ hasSpreadAttribute) {
166
172
  return;
167
173
  }
168
174
  return [result, values];