From ba7794c61c6198f38648b0baa7867407f277c8b1 Mon Sep 17 00:00:00 2001 From: HerrDietz <32846564+HerrDietz@users.noreply.github.com> Date: Tue, 28 May 2024 11:15:01 +0200 Subject: [PATCH] fix: ignore state properties in attribute rule #202 (#203) Allows properties with `state: true` to have non-lowercase names without an attribute being specified --- src/rules/attribute-names.ts | 2 +- src/test/rules/attribute-names_test.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rules/attribute-names.ts b/src/rules/attribute-names.ts index c0b1ed8..70277d1 100644 --- a/src/rules/attribute-names.ts +++ b/src/rules/attribute-names.ts @@ -37,7 +37,7 @@ const rule: Rule.RuleModule = { const propertyMap = getPropertyMap(node); for (const [prop, propConfig] of propertyMap.entries()) { - if (!propConfig.attribute) { + if (!propConfig.attribute || propConfig.state) { continue; } diff --git a/src/test/rules/attribute-names_test.ts b/src/test/rules/attribute-names_test.ts index 7c41445..80ee3f3 100644 --- a/src/test/rules/attribute-names_test.ts +++ b/src/test/rules/attribute-names_test.ts @@ -38,7 +38,14 @@ ruleTester.run('attribute-names', rule, { }; } }`, - `class Foo extends Litelement { + `class Foo extends LitElement { + static get properties() { + return { + internalState: {type: String, state: true} + }; + } + }`, + `class Foo extends LitElement { static get properties() { return { camelCase: {type: String, attribute: 'lowercase'}