@nkzw/eslint-plugin-fbtee 0.1.2 → 0.1.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/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.1.
|
|
32
|
+
version: "0.1.3",
|
|
33
33
|
description: "",
|
|
34
34
|
keywords: [],
|
|
35
35
|
repository: {
|
|
@@ -191,6 +191,11 @@ function validateChildren(node, nodesToReport) {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
194
|
+
const childName = elementType(child);
|
|
195
|
+
if (/^[A-Z]/.test(childName) || childName.startsWith("fbt:")) {
|
|
196
|
+
hasTextContent = true;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
194
199
|
hasTextContent ||= validateChildren(child, nodesToReport);
|
|
195
200
|
}
|
|
196
201
|
if (hasTextContent) {
|
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.1.
|
|
4
|
+
version: "0.1.3",
|
|
5
5
|
description: "",
|
|
6
6
|
keywords: [],
|
|
7
7
|
repository: {
|
|
@@ -163,6 +163,11 @@ function validateChildren(node, nodesToReport) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
166
|
+
const childName = elementType(child);
|
|
167
|
+
if (/^[A-Z]/.test(childName) || childName.startsWith("fbt:")) {
|
|
168
|
+
hasTextContent = true;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
166
171
|
hasTextContent ||= validateChildren(child, nodesToReport);
|
|
167
172
|
}
|
|
168
173
|
if (hasTextContent) {
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ const ruleTester = new RuleTester({
|
|
|
13
13
|
|
|
14
14
|
ruleTester.run('no-empty-strings', rule, {
|
|
15
15
|
invalid: [
|
|
16
|
+
// <fbt>
|
|
16
17
|
{
|
|
17
18
|
code: `
|
|
18
19
|
<fbt desc="Greeting"></fbt>;
|
|
@@ -96,6 +97,8 @@ ruleTester.run('no-empty-strings', rule, {
|
|
|
96
97
|
},
|
|
97
98
|
],
|
|
98
99
|
},
|
|
100
|
+
|
|
101
|
+
// fbt()
|
|
99
102
|
{
|
|
100
103
|
code: `
|
|
101
104
|
fbt('', 'Greeting');
|
|
@@ -140,6 +143,8 @@ ruleTester.run('no-empty-strings', rule, {
|
|
|
140
143
|
},
|
|
141
144
|
],
|
|
142
145
|
},
|
|
146
|
+
|
|
147
|
+
// fbs()
|
|
143
148
|
{
|
|
144
149
|
code: `
|
|
145
150
|
fbs('', 'Greeting');
|
|
@@ -153,6 +158,7 @@ ruleTester.run('no-empty-strings', rule, {
|
|
|
153
158
|
},
|
|
154
159
|
],
|
|
155
160
|
valid: [
|
|
161
|
+
// <fbt>
|
|
156
162
|
{
|
|
157
163
|
code: `
|
|
158
164
|
<fbt desc="Greeting">Hello world</fbt>;
|
|
@@ -175,44 +181,79 @@ ruleTester.run('no-empty-strings', rule, {
|
|
|
175
181
|
},
|
|
176
182
|
{
|
|
177
183
|
code: `
|
|
178
|
-
fbt
|
|
184
|
+
<fbt desc="Greeting">
|
|
185
|
+
<span>Non-empty child</span>
|
|
186
|
+
</fbt>;
|
|
179
187
|
`,
|
|
180
188
|
},
|
|
181
189
|
{
|
|
182
190
|
code: `
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
<fbt desc="Greeting">
|
|
192
|
+
<span>Non-empty child with empty sibling</span>
|
|
193
|
+
<span></span>
|
|
194
|
+
</fbt>;
|
|
185
195
|
`,
|
|
186
196
|
},
|
|
187
197
|
{
|
|
188
198
|
code: `
|
|
189
199
|
<fbt desc="Greeting">
|
|
190
|
-
|
|
200
|
+
<>Hello</>
|
|
191
201
|
</fbt>;
|
|
192
202
|
`,
|
|
193
203
|
},
|
|
194
204
|
{
|
|
195
205
|
code: `
|
|
196
206
|
<fbt desc="Greeting">
|
|
197
|
-
|
|
198
|
-
<span></span>
|
|
207
|
+
Apple{' '}Banana
|
|
199
208
|
</fbt>;
|
|
200
209
|
`,
|
|
201
210
|
},
|
|
202
211
|
{
|
|
203
212
|
code: `
|
|
204
|
-
<fbt desc="
|
|
205
|
-
|
|
213
|
+
<fbt desc="buy prompt">
|
|
214
|
+
Buy a new
|
|
215
|
+
<fbt:enum
|
|
216
|
+
enum-range={{
|
|
217
|
+
CAR: 'car',
|
|
218
|
+
HOUSE: 'house',
|
|
219
|
+
BOAT: 'boat',
|
|
220
|
+
HOUSEBOAT: 'houseboat',
|
|
221
|
+
}}
|
|
222
|
+
value={enumVal}
|
|
223
|
+
/>!
|
|
206
224
|
</fbt>;
|
|
207
225
|
`,
|
|
208
226
|
},
|
|
209
227
|
{
|
|
210
228
|
code: `
|
|
211
|
-
<fbt desc="
|
|
212
|
-
|
|
229
|
+
<fbt desc="welcome message">
|
|
230
|
+
Hello
|
|
231
|
+
<fbt:param name="name" value="Steve" />
|
|
232
|
+
</fbt>;
|
|
233
|
+
`,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
code: `
|
|
237
|
+
<fbt desc="greeting">
|
|
238
|
+
<Component />
|
|
213
239
|
</fbt>;
|
|
214
240
|
`,
|
|
215
241
|
},
|
|
242
|
+
|
|
243
|
+
// fbt()
|
|
244
|
+
{
|
|
245
|
+
code: `
|
|
246
|
+
fbt('Hello world', 'Greeting');
|
|
247
|
+
`,
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
code: `
|
|
251
|
+
const text = 'Hello';
|
|
252
|
+
fbt(text, 'Greeting');
|
|
253
|
+
`,
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
// other
|
|
216
257
|
{
|
|
217
258
|
code: `
|
|
218
259
|
name.replaceAll(' ', '-');
|
|
@@ -94,6 +94,13 @@ function validateChildren(
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (child.type === 'JSXElement' || child.type === 'JSXFragment') {
|
|
97
|
+
const childName = elementType(child);
|
|
98
|
+
|
|
99
|
+
if (/^[A-Z]/.test(childName) || childName.startsWith('fbt:')) {
|
|
100
|
+
hasTextContent = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
97
104
|
hasTextContent ||= validateChildren(child, nodesToReport);
|
|
98
105
|
}
|
|
99
106
|
|