chore(settings): update legacy settings alias implementation and tests

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-01-12 14:29:40 +08:00
parent 8c56b612fb
commit 5f8e1ebc94
2 changed files with 12 additions and 10 deletions

View file

@ -419,7 +419,7 @@ describe('Settings Loading and Merging', () => {
});
});
it('should warn about deprecated legacy keys in a v2 settings file', () => {
it('should warn about ignored legacy keys in a v2 settings file', () => {
(mockFsExistsSync as Mock).mockImplementation(
(p: fs.PathLike) => p === USER_SETTINGS_PATH,
);
@ -440,7 +440,7 @@ describe('Settings Loading and Merging', () => {
expect(getSettingsWarnings(settings)).toEqual(
expect.arrayContaining([
expect.stringContaining(
"Deprecated setting 'usageStatisticsEnabled'",
"Legacy setting 'usageStatisticsEnabled' will be ignored",
),
]),
);
@ -471,7 +471,9 @@ describe('Settings Loading and Merging', () => {
expect(getSettingsWarnings(settings)).toEqual(
expect.arrayContaining([
expect.stringContaining("Unknown setting 'someUnknownKey'"),
expect.stringContaining(
"Unknown setting 'someUnknownKey' will be ignored",
),
]),
);
});

View file

@ -354,9 +354,9 @@ function getSettingsFileKeyWarnings(
}
const warnings: string[] = [];
const deprecatedKeys = new Set<string>();
const ignoredLegacyKeys = new Set<string>();
// Deprecated keys (V1 top-level keys that moved to a nested V2 path).
// Ignored legacy keys (V1 top-level keys that moved to a nested V2 path).
for (const [oldKey, newPath] of Object.entries(MIGRATION_MAP)) {
if (oldKey === newPath) {
continue;
@ -378,9 +378,9 @@ function getSettingsFileKeyWarnings(
continue;
}
deprecatedKeys.add(oldKey);
ignoredLegacyKeys.add(oldKey);
warnings.push(
`⚠️ Warning: Deprecated setting '${oldKey}' in ${settingsFilePath}. Please use '${newPath}' instead.`,
`⚠️ Legacy setting '${oldKey}' will be ignored in ${settingsFilePath}. Please use '${newPath}' instead.`,
);
}
@ -390,7 +390,7 @@ function getSettingsFileKeyWarnings(
if (key === SETTINGS_VERSION_KEY) {
continue;
}
if (deprecatedKeys.has(key)) {
if (ignoredLegacyKeys.has(key)) {
continue;
}
if (schemaKeys.has(key)) {
@ -398,7 +398,7 @@ function getSettingsFileKeyWarnings(
}
warnings.push(
`⚠️ Warning: Unknown setting '${key}' in ${settingsFilePath}. This setting will be ignored.`,
`⚠️ Unknown setting '${key}' will be ignored in ${settingsFilePath}.`,
);
}
@ -406,7 +406,7 @@ function getSettingsFileKeyWarnings(
}
/**
* Collects warnings for deprecated and unknown settings keys.
* Collects warnings for ignored legacy and unknown settings keys.
*
* For `$version: 2` settings files, we do not apply implicit migrations.
* Instead, we surface actionable, de-duplicated warnings in the terminal UI.