From 830c651bff0a2e855df669482102244cedaba4dc Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Wed, 18 Sep 2024 16:55:19 +0100 Subject: [PATCH] linting --- src/parsers/attribute-parser.js | 16 +--------------- test/tests/valid/enum.test.js | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/parsers/attribute-parser.js b/src/parsers/attribute-parser.js index e8d7278..2531f80 100644 --- a/src/parsers/attribute-parser.js +++ b/src/parsers/attribute-parser.js @@ -256,21 +256,7 @@ export class AttributeParser { if (ts.isPropertyAssignment(property)) { const name = property.name && ts.isIdentifier(property.name) && property.name.text; - let value; - - const node = property.initializer; - - value = getLiteralValue(node, this.typeChecker); - - // Enums can only contain primitives (string|number|boolean) - // if (ts.isNumericLiteral(node)) { - // value = parseFloat(node.getText()); - // } else if (node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) { - // value = node.kind === ts.SyntaxKind.TrueKeyword; - // } else { - // value = node.getText(); - // } - + const value = getLiteralValue(property.initializer, this.typeChecker); members.push({ [name]: value }); } }); diff --git a/test/tests/valid/enum.test.js b/test/tests/valid/enum.test.js index 696574f..656c2f7 100644 --- a/test/tests/valid/enum.test.js +++ b/test/tests/valid/enum.test.js @@ -51,7 +51,7 @@ describe('VALID: Enum attribute', function () { expect(data[0].example.attributes.h.name).to.equal('h'); expect(data[0].example.attributes.h.type).to.equal('string'); expect(data[0].example.attributes.h.array).to.equal(false); - expect(data[0].example.attributes.h.enum).to.be.an('array').with.lengthOf(3) + expect(data[0].example.attributes.h.enum).to.be.an('array').with.lengthOf(3); expect(data[0].example.attributes.h.enum[0]).to.deep.equal({ A: 'a' }); expect(data[0].example.attributes.h.enum[1]).to.deep.equal({ B: 'b' }); expect(data[0].example.attributes.h.enum[2]).to.deep.equal({ C: 'c' });