@nkzw/eslint-plugin-fbtee 0.1.4 → 0.2.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.
- package/README.md +1 -1
- package/lib/index.cjs +16 -6
- package/lib/index.js +13 -3
- package/package.json +3 -3
- package/src/__tests__/no-untranslated-strings-test.tsx +57 -1
- package/src/utils.tsx +14 -0
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ The open-source version of `fbt`, however, became unmaintained, difficult to set
|
|
|
200
200
|
- **Easier Setup:** fbtee works with modern tools like Vite.
|
|
201
201
|
- **Statically Typed:** The fbtee compiler ensures correct usage of fbtee, libary TypeScript types are provided, and an eslint plugin helps fix common mistakes.
|
|
202
202
|
- **Improved React Compatibility:** Removed React-specific hacks and added support for implicit React fragments (`<>`).
|
|
203
|
-
- **Enhanced Features:** Fixed and exported `
|
|
203
|
+
- **Enhanced Features:** Fixed and exported `inltList` as a new `<fbt:list>` construt, which was not functional in the original `fbt`.
|
|
204
204
|
- **Modernized Codebase:** Rewritten using TypeScript, ES modules (ESM), eslint, and modern JavaScript standards. Removed cruft and legacy code.
|
|
205
205
|
- **Updated Tooling:** Uses modern tools like pnpm, Vite, and esbuild for faster and more efficient development of **fbtee**.
|
|
206
206
|
|
package/lib/index.cjs
CHANGED
|
@@ -18,18 +18,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.tsx
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
configs: () => configs,
|
|
24
24
|
meta: () => meta,
|
|
25
25
|
rules: () => rules
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var package_default = {
|
|
31
31
|
name: "@nkzw/eslint-plugin-fbtee",
|
|
32
|
-
version: "0.
|
|
32
|
+
version: "0.2.0",
|
|
33
33
|
description: "",
|
|
34
34
|
keywords: [],
|
|
35
35
|
repository: {
|
|
@@ -47,10 +47,10 @@ var package_default = {
|
|
|
47
47
|
build: "tsup src/index.tsx -d lib --target=node22 --format=esm,cjs --clean --no-splitting --dts"
|
|
48
48
|
},
|
|
49
49
|
dependencies: {
|
|
50
|
-
"@typescript-eslint/utils": "^8.18.
|
|
50
|
+
"@typescript-eslint/utils": "^8.18.2"
|
|
51
51
|
},
|
|
52
52
|
devDependencies: {
|
|
53
|
-
"@typescript-eslint/rule-tester": "^8.18.
|
|
53
|
+
"@typescript-eslint/rule-tester": "^8.18.2"
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -121,6 +121,16 @@ function resolveNodeValue(node) {
|
|
|
121
121
|
if (node.type === "JSXExpressionContainer") {
|
|
122
122
|
return resolveNodeValue(node.expression);
|
|
123
123
|
}
|
|
124
|
+
if (node.type === "ConditionalExpression") {
|
|
125
|
+
const consequent = resolveNodeValue(node.consequent);
|
|
126
|
+
const alternate = resolveNodeValue(node.alternate);
|
|
127
|
+
return consequent || alternate || null;
|
|
128
|
+
}
|
|
129
|
+
if (node.type === "LogicalExpression") {
|
|
130
|
+
const left = resolveNodeValue(node.left);
|
|
131
|
+
const right = resolveNodeValue(node.right);
|
|
132
|
+
return left || right || null;
|
|
133
|
+
}
|
|
124
134
|
return null;
|
|
125
135
|
}
|
|
126
136
|
function getPropName(prop) {
|
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.
|
|
4
|
+
version: "0.2.0",
|
|
5
5
|
description: "",
|
|
6
6
|
keywords: [],
|
|
7
7
|
repository: {
|
|
@@ -19,10 +19,10 @@ var package_default = {
|
|
|
19
19
|
build: "tsup src/index.tsx -d lib --target=node22 --format=esm,cjs --clean --no-splitting --dts"
|
|
20
20
|
},
|
|
21
21
|
dependencies: {
|
|
22
|
-
"@typescript-eslint/utils": "^8.18.
|
|
22
|
+
"@typescript-eslint/utils": "^8.18.2"
|
|
23
23
|
},
|
|
24
24
|
devDependencies: {
|
|
25
|
-
"@typescript-eslint/rule-tester": "^8.18.
|
|
25
|
+
"@typescript-eslint/rule-tester": "^8.18.2"
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -93,6 +93,16 @@ function resolveNodeValue(node) {
|
|
|
93
93
|
if (node.type === "JSXExpressionContainer") {
|
|
94
94
|
return resolveNodeValue(node.expression);
|
|
95
95
|
}
|
|
96
|
+
if (node.type === "ConditionalExpression") {
|
|
97
|
+
const consequent = resolveNodeValue(node.consequent);
|
|
98
|
+
const alternate = resolveNodeValue(node.alternate);
|
|
99
|
+
return consequent || alternate || null;
|
|
100
|
+
}
|
|
101
|
+
if (node.type === "LogicalExpression") {
|
|
102
|
+
const left = resolveNodeValue(node.left);
|
|
103
|
+
const right = resolveNodeValue(node.right);
|
|
104
|
+
return left || right || null;
|
|
105
|
+
}
|
|
96
106
|
return null;
|
|
97
107
|
}
|
|
98
108
|
function getPropName(prop) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkzw/eslint-plugin-fbtee",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"require": "./lib/index.cjs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@typescript-eslint/utils": "^8.18.
|
|
18
|
+
"@typescript-eslint/utils": "^8.18.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@typescript-eslint/rule-tester": "^8.18.
|
|
21
|
+
"@typescript-eslint/rule-tester": "^8.18.2"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsup src/index.tsx -d lib --target=node22 --format=esm,cjs --clean --no-splitting --dts"
|
|
@@ -72,7 +72,48 @@ ruleTester.run('no-untranslated-strings', rule, {
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
code: `
|
|
75
|
-
<>Hello world
|
|
75
|
+
<>Hello world</>;
|
|
76
|
+
`,
|
|
77
|
+
errors: [
|
|
78
|
+
{
|
|
79
|
+
messageId: 'unwrappedString',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
code: `
|
|
85
|
+
<span>{foo ? 'bar' : 'baz'}</span>;
|
|
86
|
+
`,
|
|
87
|
+
errors: [
|
|
88
|
+
{
|
|
89
|
+
messageId: 'unwrappedString',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
code: `
|
|
95
|
+
<span>{foo ?? 'bar'}</span>;
|
|
96
|
+
`,
|
|
97
|
+
errors: [
|
|
98
|
+
{
|
|
99
|
+
messageId: 'unwrappedString',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
code: `
|
|
105
|
+
<span>{foo || 'bar'}</span>;
|
|
106
|
+
`,
|
|
107
|
+
errors: [
|
|
108
|
+
{
|
|
109
|
+
messageId: 'unwrappedString',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
code: `
|
|
115
|
+
const foo = true;
|
|
116
|
+
<span>{foo && 'bar'}</span>;
|
|
76
117
|
`,
|
|
77
118
|
errors: [
|
|
78
119
|
{
|
|
@@ -219,5 +260,20 @@ ruleTester.run('no-untranslated-strings', rule, {
|
|
|
219
260
|
foo.bar('Baz')
|
|
220
261
|
`,
|
|
221
262
|
},
|
|
263
|
+
{
|
|
264
|
+
code: `
|
|
265
|
+
const foo = isGreeting ? 'Hello' : 'Goodbye'
|
|
266
|
+
`,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
code: `
|
|
270
|
+
const foo = helloGreeting ?? 'goodbye'
|
|
271
|
+
`,
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
code: `
|
|
275
|
+
const foo = helloGreeting || 'goodbye'
|
|
276
|
+
`,
|
|
277
|
+
},
|
|
222
278
|
],
|
|
223
279
|
});
|
package/src/utils.tsx
CHANGED
|
@@ -105,6 +105,20 @@ export function resolveNodeValue(
|
|
|
105
105
|
return resolveNodeValue(node.expression);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
if (node.type === 'ConditionalExpression') {
|
|
109
|
+
const consequent = resolveNodeValue(node.consequent);
|
|
110
|
+
const alternate = resolveNodeValue(node.alternate);
|
|
111
|
+
|
|
112
|
+
return consequent || alternate || null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (node.type === 'LogicalExpression') {
|
|
116
|
+
const left = resolveNodeValue(node.left);
|
|
117
|
+
const right = resolveNodeValue(node.right);
|
|
118
|
+
|
|
119
|
+
return left || right || null;
|
|
120
|
+
}
|
|
121
|
+
|
|
108
122
|
return null;
|
|
109
123
|
}
|
|
110
124
|
|