diff --git a/src/jsii-diagnostic.ts b/src/jsii-diagnostic.ts index bf9e6087..d60a1892 100644 --- a/src/jsii-diagnostic.ts +++ b/src/jsii-diagnostic.ts @@ -86,13 +86,13 @@ export class Code = new Map(); + private static readonly byName: Map = new Map(); // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility readonly #defaultCategory: ts.DiagnosticCategory; @@ -126,7 +126,8 @@ export class Code { code.category = DiagnosticCategory.Suggestion; }); + test('throws on __proto__ key', () => { + expect(() => configureCategories(JSON.parse('{"__proto__":{"pollutedKey":123}}'))).toThrow( + `Unrecognized diagnostic code '__proto__'`, + ); + }); + test('diagnostic by name', () => { configureCategories({ 'metadata/package-json-missing-description': DiagnosticCategory.Error,