@nkzw/eslint-plugin-fbtee 0.0.1 → 0.1.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/lib/index.cjs CHANGED
@@ -29,7 +29,7 @@ module.exports = __toCommonJS(src_exports);
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@nkzw/eslint-plugin-fbtee",
32
- version: "0.0.1",
32
+ version: "0.1.1",
33
33
  description: "",
34
34
  keywords: [],
35
35
  repository: {
@@ -182,7 +182,9 @@ function validateChildren(node, nodesToReport) {
182
182
  }
183
183
  }
184
184
  if (child.type === "JSXExpressionContainer" && child.expression.type !== "JSXEmptyExpression") {
185
- if (isEmptyString(child.expression)) {
185
+ if (isEmptyString(child.expression) && (node.children.length === 1 || node.children.every(
186
+ (otherChild) => child === otherChild || otherChild.type === "JSXText" && otherChild.value.trim() === ""
187
+ ))) {
186
188
  nodesToReport.add(child.expression);
187
189
  } else {
188
190
  hasTextContent = true;
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@nkzw/eslint-plugin-fbtee",
4
- version: "0.0.1",
4
+ version: "0.1.1",
5
5
  description: "",
6
6
  keywords: [],
7
7
  repository: {
@@ -154,7 +154,9 @@ function validateChildren(node, nodesToReport) {
154
154
  }
155
155
  }
156
156
  if (child.type === "JSXExpressionContainer" && child.expression.type !== "JSXEmptyExpression") {
157
- if (isEmptyString(child.expression)) {
157
+ if (isEmptyString(child.expression) && (node.children.length === 1 || node.children.every(
158
+ (otherChild) => child === otherChild || otherChild.type === "JSXText" && otherChild.value.trim() === ""
159
+ ))) {
158
160
  nodesToReport.add(child.expression);
159
161
  } else {
160
162
  hasTextContent = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkzw/eslint-plugin-fbtee",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -206,5 +206,12 @@ ruleTester.run('no-empty-strings', rule, {
206
206
  </fbt>;
207
207
  `,
208
208
  },
209
+ {
210
+ code: `
211
+ <fbt desc="Greeting">
212
+ Apple{' '}Banana
213
+ </fbt>;
214
+ `,
215
+ },
209
216
  ],
210
217
  });
@@ -78,7 +78,15 @@ function validateChildren(
78
78
  child.type === 'JSXExpressionContainer' &&
79
79
  child.expression.type !== 'JSXEmptyExpression'
80
80
  ) {
81
- if (isEmptyString(child.expression)) {
81
+ if (
82
+ isEmptyString(child.expression) &&
83
+ (node.children.length === 1 ||
84
+ node.children.every(
85
+ (otherChild) =>
86
+ child === otherChild ||
87
+ (otherChild.type === 'JSXText' && otherChild.value.trim() === ''),
88
+ ))
89
+ ) {
82
90
  nodesToReport.add(child.expression);
83
91
  } else {
84
92
  hasTextContent = true;