@ai-i18n/eslint-plugin 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
Files changed (2) hide show
  1. package/README.md +30 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -160,6 +160,36 @@ export default { computed: { label: tComputed('保存') } }; // 纯 Options:
160
160
  export default { data: () => ({ label: t('保存') }) }; // warning:Options data 快照
161
161
  ```
162
162
 
163
+ 配置对象也要按生命周期选择写法。模块顶层直接保存图表或菜单配置会得到初始化快照;改成工厂函数,
164
+ 并在首次渲染和语言变化后重新创建配置:
165
+
166
+ ```ts
167
+ // warning
168
+ export const chartOptions = { title: { text: t('销量') } };
169
+
170
+ // 允许:调用时读取当前语言
171
+ export const createChartOptions = () => ({
172
+ title: { text: t('销量') },
173
+ });
174
+ ```
175
+
176
+ 集中管理有限标题时,使用 `defineI18nMessages()` 声明静态集合,并在 getter 或普通函数执行时
177
+ 调用 `t(ROUTE_TITLES[name])`。这样既能完整提取,也不会长期保存初始化译文。
178
+
179
+ 第三方配置明确支持函数值时,可以把翻译放进该回调。例如 async-validator 的校验消息:
180
+
181
+ ```ts
182
+ const rules = {
183
+ password: {
184
+ required: true,
185
+ message: () => t('请输入旧密码'),
186
+ },
187
+ };
188
+ ```
189
+
190
+ 规则只判断 `t()` 的执行位置,不会推断某个第三方字段是否接受函数。API 不支持延迟回调时,
191
+ 使用工厂函数或框架提供的响应式 API;不要改回固定的源语言字面量。
192
+
163
193
  `recommended`、`vue`、`vue-auto-import` 与 `react-auto-import` 还启用
164
194
  `ai-i18n/no-unsubscribed-t`。Vue template、render 与 JSX / TSX 中的 Runtime `t` 会追踪
165
195
  adapter revision,可以直接使用。React JSX / TSX 的组件渲染函数仍应从 `useI18n()` 获取
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-i18n/eslint-plugin",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.15",
4
4
  "description": "ESLint static-argument checks aligned with ai-i18n extraction semantics.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "get-tsconfig": "^4.14.0",
37
37
  "picomatch": "^4.0.5",
38
- "@ai-i18n/analyzer": "1.0.0-alpha.12"
38
+ "@ai-i18n/analyzer": "1.0.0-alpha.13"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@vue/compiler-sfc": ">=3.2.0",