fix: prevent client-side crashes from null/undefined plugin data in workflow (#23154) (#23182)

This commit is contained in:
lyzno1 2025-07-31 10:03:33 +08:00 • committed by GitHub
commit 1b2046da3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 260 additions and 14 deletions

View file

@ -49,9 +49,9 @@ describe('check-i18n script functionality', () => {
}
vm.runInNewContext(transpile(content), context)
const translationObj = moduleExports.default || moduleExports
const translationObj = (context.module.exports as any).default || context.module.exports
if(!translationObj || typeof translationObj !== 'object')
if (!translationObj || typeof translationObj !== 'object')
throw new Error(`Error parsing file: ${filePath}`)
const nestedKeys: string[] = []
@ -62,7 +62,7 @@ describe('check-i18n script functionality', () => {
// This is an object (but not array), recurse into it but don't add it as a key
iterateKeys(obj[key], nestedKey)
}
else {
else {
// This is a leaf node (string, number, boolean, array, etc.), add it as a key
nestedKeys.push(nestedKey)
}
@ -73,7 +73,7 @@ describe('check-i18n script functionality', () => {
const fileKeys = nestedKeys.map(key => `${camelCaseFileName}.${key}`)
allKeys.push(...fileKeys)
}
catch (error) {
catch (error) {
reject(error)
}
})
@ -272,9 +272,6 @@ export default translation
const filteredEnKeys = allEnKeys.filter(key =>
key.startsWith(targetFile.replace(/[-_](.)/g, (_, c) => c.toUpperCase())),
)
const filteredZhKeys = allZhKeys.filter(key =>
key.startsWith(targetFile.replace(/[-_](.)/g, (_, c) => c.toUpperCase())),
)
expect(allEnKeys).toHaveLength(4) // 2 keys from each file
expect(filteredEnKeys).toHaveLength(2) // only components keys