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

static properties typo #38

Open
LarsDenBakker opened this issue Mar 20, 2019 · 5 comments
Open

static properties typo #38

LarsDenBakker opened this issue Mar 20, 2019 · 5 comments

Comments

@LarsDenBakker
Copy link

A good linting rule could be to ensure people aren't making a typo in the static properties getter, or use incorrect modifiers:

// a function
static properties() {
  return {};
}

// a function
properties() { }

// not static
get properties() {
  return {};
}

// not static
properties = {}

// typo
static get proporties() {
 return {};
}
@stramel
Copy link
Contributor

stramel commented Mar 20, 2019

This would align with the work @43081j and I had discussed related to typos. Would be able to handle lit specific lifecycle hooks and public members. Would be similar to the eslint-plugin-wc no-typos rule.

I'm not sure if we want to cover the static vs non-standard case as it is valid to have a non-static properties getter

@43081j
Copy link
Owner

43081j commented Mar 20, 2019

it is valid to have a non-static properties getter

Are you sure? the properties getter is accessed in the observedAttributes static method, before an instance exists. It shouldn't be possible to have a non-static properties getter in that case.

Should indeed be a no-typos equivalent for lit, though, like the wc plugin has.

@stramel
Copy link
Contributor

stramel commented Mar 20, 2019

@43081j So you want to say a user is incorrect for using something else named properties? Even though it is perfectly valid?

You are correct that if they want to use it for the lit-element properties declaration it should be static but I don't know that we should enforce that Or if we do, it should be a separate rule IMO.

@43081j
Copy link
Owner

43081j commented Mar 20, 2019

i don't want to say a properties method is invalid, i just meant its not used by lit (not valid by lit).

sorry for the confusion. i wouldn't disallow it as its fine to have yourself. i thought you meant it was valid to have it for lit to use it

@LarsDenBakker
Copy link
Author

LarsDenBakker commented Mar 20, 2019

It can be an option. I would not recommend having the same property name for instance and static.

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

3 participants