@nkzw/eslint-plugin-fbtee 3.0.1 → 3.1.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 +54 -22
- package/lib/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,14 +10,14 @@ const Greeting = ({ name }) => (
|
|
|
10
10
|
);
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
_fbtee_ is a modern continuation of Facebook's `fbt`, rebuilt for TypeScript, ESM, React 19, Vite, Next.js
|
|
13
|
+
_fbtee_ is a modern continuation of Facebook's `fbt`, rebuilt for TypeScript, ESM, React 19, Vite, Babel, SWC, Next.js & Oxc.
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
17
|
- **Inline translations for Better Developer Experience:** Embed translations directly into your code. No need to manage translation keys or wrap your code with `t()` functions. **fbtee** uses a compiler to extract strings from your code and prepare them for translation providers.
|
|
18
18
|
- **Proven in Production:** Built on Facebook's `fbt`, with over a decade of production usage serving billions of users, plus years in production at [Athena Crisis](https://athenacrisis.com).
|
|
19
19
|
- **Optimized Performance with IR:** Compiles translations into an Intermediate Representation (IR) for extracting strings, then optimizes the runtime output for performance.
|
|
20
|
-
- **Easy Setup:** Quick integration with Babel, SWC,
|
|
20
|
+
- **Easy Setup:** Quick integration with Vite, Babel, SWC, Oxc, Next.js, and Expo.
|
|
21
21
|
|
|
22
22
|
## Getting Started
|
|
23
23
|
|
|
@@ -34,49 +34,51 @@ npm install fbtee
|
|
|
34
34
|
|
|
35
35
|
_fbtee_ requires Node 22+. React apps should use React 19+.
|
|
36
36
|
|
|
37
|
-
###
|
|
37
|
+
### Vite
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Most projects should install the ready-to-use Vite plugin and the CLI:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npm install -D @nkzw/
|
|
42
|
+
npm install -D @nkzw/vite-plugin-fbtee @nkzw/fbtee-cli
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Add the fbtee plugin before the React plugin:
|
|
46
46
|
|
|
47
|
-
```
|
|
48
|
-
import
|
|
49
|
-
import babel from '@rolldown/plugin-babel';
|
|
47
|
+
```js
|
|
48
|
+
import fbtee from '@nkzw/vite-plugin-fbtee';
|
|
50
49
|
import react from '@vitejs/plugin-react';
|
|
51
50
|
import { defineConfig } from 'vite';
|
|
52
51
|
|
|
53
52
|
export default defineConfig({
|
|
54
53
|
plugins: [
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
fbtee({
|
|
55
|
+
fbtCommon: {
|
|
56
|
+
Accept: 'Button label for accepting terms',
|
|
57
|
+
},
|
|
58
|
+
fbtEnumManifest: {},
|
|
57
59
|
}),
|
|
58
60
|
react(),
|
|
59
61
|
],
|
|
60
62
|
});
|
|
61
63
|
```
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
### Babel
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
Install the Babel preset and the CLI:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm install -D @nkzw/babel-preset-fbtee @nkzw/fbtee-cli
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
Add the preset to your Babel configuration:
|
|
72
74
|
|
|
73
75
|
```js
|
|
74
76
|
export default {
|
|
75
|
-
presets: ['
|
|
77
|
+
presets: ['@nkzw/babel-preset-fbtee'],
|
|
76
78
|
};
|
|
77
79
|
```
|
|
78
80
|
|
|
79
|
-
### SWC
|
|
81
|
+
### SWC
|
|
80
82
|
|
|
81
83
|
Install the SWC runtime compiler and the CLI:
|
|
82
84
|
|
|
@@ -87,24 +89,54 @@ npm install -D @nkzw/swc-plugin-fbtee @nkzw/fbtee-cli
|
|
|
87
89
|
For Next.js SWC plugins:
|
|
88
90
|
|
|
89
91
|
```js
|
|
92
|
+
import { createFbteePluginOptions } from '@nkzw/swc-plugin-fbtee/index.js';
|
|
93
|
+
|
|
90
94
|
export default {
|
|
91
95
|
experimental: {
|
|
92
96
|
swcPlugins: [
|
|
93
97
|
[
|
|
94
98
|
'@nkzw/swc-plugin-fbtee',
|
|
95
|
-
{
|
|
99
|
+
createFbteePluginOptions({
|
|
96
100
|
fbtCommon: {
|
|
97
101
|
Accept: 'Button label for accepting terms',
|
|
98
102
|
},
|
|
99
103
|
fbtEnumManifest: {},
|
|
100
|
-
},
|
|
104
|
+
}),
|
|
101
105
|
],
|
|
102
106
|
],
|
|
103
107
|
},
|
|
104
108
|
};
|
|
105
109
|
```
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
### Low-level Oxc Transform
|
|
112
|
+
|
|
113
|
+
For custom build-system integrations, install the native Oxc transform:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install -D @nkzw/oxc-transform-fbtee @nkzw/fbtee-cli oxc-transform
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Apply the fbtee transform before the standard Oxc transform:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import { transformSync as transformFbtee } from '@nkzw/oxc-transform-fbtee';
|
|
123
|
+
import { transformSync as transformOxc } from 'oxc-transform';
|
|
124
|
+
|
|
125
|
+
const fbteeResult = transformFbtee(filename, sourceText, {
|
|
126
|
+
fbtCommon: {
|
|
127
|
+
Accept: 'Button label for accepting terms',
|
|
128
|
+
},
|
|
129
|
+
fbtEnumManifest: {},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (fbteeResult.errors.length > 0) {
|
|
133
|
+
throw new Error(fbteeResult.errors.map(({ message }) => message).join('\n'));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const result = transformOxc(filename, fbteeResult.code, {
|
|
137
|
+
jsx: { runtime: 'automatic' },
|
|
138
|
+
});
|
|
139
|
+
```
|
|
108
140
|
|
|
109
141
|
### TypeScript JSX Types
|
|
110
142
|
|
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
2
|
//#region package.json
|
|
3
3
|
var name = "@nkzw/eslint-plugin-fbtee";
|
|
4
|
-
var version = "3.0
|
|
4
|
+
var version = "3.1.0";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/utils.tsx
|
|
7
7
|
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/nkzw-tech/fbtee/blob/main/packages/eslint-plugin-fbtee/docs/rules/${name}.md`);
|