Skip to content

Commit bfd9f5e

Browse files
committed
Fix editorconfig helper lint
1 parent f88bae2 commit bfd9f5e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎Extension/src/LanguageServer/includeCleanupEditorConfig.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ export interface IncludeCleanupPreferences {
77

88
function getStringSetting(settings: any, key: string): string {
99
const value: unknown = settings?.[key];
10-
return typeof value === 'string' && value.toLowerCase() !== 'unset' ? value : '';
10+
if (typeof value !== 'string' || value.toLowerCase() === 'unset') {
11+
return '';
12+
}
13+
return value;
1114
}
1215

1316
export function getIncludeCleanupPreferences(settings: any): IncludeCleanupPreferences {
@@ -17,4 +20,4 @@ export function getIncludeCleanupPreferences(settings: any): IncludeCleanupPrefe
1720
replacementFiles: getStringSetting(settings, 'cpp_include_cleanup_replacement_files'),
1821
requiredFiles: getStringSetting(settings, 'cpp_include_cleanup_required_files')
1922
};
20-
}
23+
}

‎Extension/test/unit/includeCleanupEditorConfig.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Include Cleanup editorconfig settings', () => {
1717
});
1818
});
1919

20-
it('ignores unset and non-string values', () => {
20+
it('maps unset and non-string values to empty strings', () => {
2121
deepStrictEqual(getIncludeCleanupPreferences({
2222
cpp_include_cleanup_alternate_files: 'unset',
2323
cpp_include_cleanup_excluded_files: true,
@@ -29,4 +29,4 @@ describe('Include Cleanup editorconfig settings', () => {
2929
requiredFiles: ''
3030
});
3131
});
32-
});
32+
});

0 commit comments

Comments
 (0)