Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rule 'attribute-names' is also applied to internal reactive state #202

Closed
HerrDietz opened this issue May 24, 2024 · 5 comments
Closed

rule 'attribute-names' is also applied to internal reactive state #202

HerrDietz opened this issue May 24, 2024 · 5 comments

Comments

@HerrDietz
Copy link
Contributor

In the following class, the attribute-names” rule is applied to the isFoo property, although it is decorated with @state and therefore has no public attribute.

import {LitElement} from "lit";
import {customElement, state} from "lit/decorators.js";

@customElement('my-component')
export class MyComponent extends LitElement {

  @state()
  private isFoo = false;
  
}

The rule is applied as well if the static properties syntax is used.

@customElement('my-component2')
export class MyComponent2 extends LitElement {

  static properties={
    isFoo: {type: Boolean, state: true}
  }

}
@HerrDietz HerrDietz changed the title rule 'attribute-names' is also applied to properties decorated with @state rule 'attribute-names' is also applied to internal reactive state May 24, 2024
@43081j
Copy link
Owner

43081j commented May 24, 2024

good catch. seems like a bug for sure

contributions welcome, but if not, ill try take a look soon 👍

@HerrDietz
Copy link
Contributor Author

I'll see if I can get around to taking a look at it this weekend. If I do, I'll be happy to post a pull request.

@43081j
Copy link
Owner

43081j commented May 24, 2024

its probably as simple as changing this condition to also check for !propConfig.state:

if (!propConfig.attribute) {
continue;
}

but i'd start by adding a test with similar code to your example and go from there

HerrDietz pushed a commit to HerrDietz/eslint-plugin-lit that referenced this issue May 26, 2024
HerrDietz pushed a commit to HerrDietz/eslint-plugin-lit that referenced this issue May 26, 2024
@HerrDietz HerrDietz mentioned this issue May 26, 2024
@HerrDietz
Copy link
Contributor Author

I have opened a pullrequest. Would you be so kind to review it?

43081j pushed a commit that referenced this issue May 28, 2024
Allows properties with `state: true` to have non-lowercase names without an attribute being specified
@43081j
Copy link
Owner

43081j commented May 29, 2024

Fixed by #203

@43081j 43081j closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants