feima-shortcuts 0.3.0-beta.2 → 0.3.0-beta.4
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/package.json
CHANGED
|
@@ -29,7 +29,6 @@ function loadLocaleKeys(localePath) {
|
|
|
29
29
|
ts.isExportAssignment(node) &&
|
|
30
30
|
ts.isObjectLiteralExpression(node.expression)
|
|
31
31
|
) {
|
|
32
|
-
// eval 需要谨慎,这里保持原逻辑
|
|
33
32
|
obj = eval(`(${node.expression.getText()})`)
|
|
34
33
|
}
|
|
35
34
|
ts.forEachChild(node, visit)
|
|
@@ -110,25 +109,16 @@ function checkPageLocale(pageDir) {
|
|
|
110
109
|
|
|
111
110
|
const localeKeys = loadLocaleKeys(localePath)
|
|
112
111
|
const usedKeys = extractUsedKeys(code)
|
|
113
|
-
|
|
114
|
-
// locale.ts 中定义但未使用的 key
|
|
115
112
|
const unused = localeKeys.filter((k) => !usedKeys.has(k))
|
|
113
|
+
|
|
116
114
|
if (unused.length) {
|
|
117
115
|
console.log(`\n❌ 页面未使用 locale key`)
|
|
118
116
|
console.log(` ${localePath}`)
|
|
119
117
|
unused.forEach((k) => console.log(` - ${k}`))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 页面中用到了 locale.ts 中未定义的 key
|
|
123
|
-
const undefinedKeys = [...usedKeys].filter((k) => !localeKeys.includes(k))
|
|
124
|
-
if (undefinedKeys.length) {
|
|
125
|
-
console.log(`\n❌ 页面使用了 locale.ts 中未定义的 key`)
|
|
126
|
-
console.log(` ${indexVue}`)
|
|
127
|
-
undefinedKeys.forEach((k) => console.log(` - ${k}`))
|
|
128
118
|
return true
|
|
129
119
|
}
|
|
130
120
|
|
|
131
|
-
return
|
|
121
|
+
return false
|
|
132
122
|
}
|
|
133
123
|
|
|
134
124
|
/* 组件 locale 检测 */
|
|
@@ -167,7 +157,6 @@ function checkComponentLocale(componentDir) {
|
|
|
167
157
|
|
|
168
158
|
let hasError = false
|
|
169
159
|
|
|
170
|
-
// locale.ts 中定义但未使用的 key
|
|
171
160
|
const unused = localeKeys.filter((k) => !usedKeys.has(k))
|
|
172
161
|
if (unused.length) {
|
|
173
162
|
hasError = true
|
|
@@ -176,15 +165,6 @@ function checkComponentLocale(componentDir) {
|
|
|
176
165
|
unused.forEach((k) => console.log(` - ${k}`))
|
|
177
166
|
}
|
|
178
167
|
|
|
179
|
-
// 组件代码中使用但 locale.ts 未定义的 key
|
|
180
|
-
const undefinedKeys = [...usedKeys].filter((k) => !localeKeys.includes(k))
|
|
181
|
-
if (undefinedKeys.length) {
|
|
182
|
-
hasError = true
|
|
183
|
-
console.log(`\n❌ 组件使用了 locale.ts 中未定义的 key`)
|
|
184
|
-
console.log(` ${componentDir}`)
|
|
185
|
-
undefinedKeys.forEach((k) => console.log(` - ${k}`))
|
|
186
|
-
}
|
|
187
|
-
|
|
188
168
|
if (invalidFiles.length) {
|
|
189
169
|
hasError = true
|
|
190
170
|
console.log(`\n🚫 组件存在错误的 locale 引入方式`)
|
|
@@ -194,12 +174,12 @@ function checkComponentLocale(componentDir) {
|
|
|
194
174
|
})
|
|
195
175
|
}
|
|
196
176
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
177
|
+
if (skippedFiles.length) {
|
|
178
|
+
console.log(`\n⚠️ 组件中以下文件未绑定本地 locale(已跳过)`)
|
|
179
|
+
skippedFiles.forEach((f) =>
|
|
180
|
+
console.log(` ${path.relative(process.cwd(), f)}`)
|
|
181
|
+
)
|
|
182
|
+
}
|
|
203
183
|
|
|
204
184
|
return hasError
|
|
205
185
|
}
|