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

Support https://typescript-eslint.io/rules/unbound-method in lit/no-template-arrow rule #188

Open
jpzwarte opened this issue Nov 20, 2023 · 3 comments

Comments

@jpzwarte
Copy link

This is similar to https://github.com/jest-community/eslint-plugin-jest/blob/main/src/rules/unbound-method.ts

The jest plugin checks whether the unbound method is valid in the context of jest, or it falls back to the typescript-eslint/unbound-method rule.

It would be helpful if the lit/no-template-arrow rule did the same. Especially now that the latest eslint-config-standard-with-typescript version now includes the @typescript-eslint/unbound-method rule.

@43081j
Copy link
Owner

43081j commented Nov 27, 2023

if i understand correctly, this is because if you do:

html`
  ${this.someMethod}
`;

unbound-method in tseslint will trigger since it wants us to pass () => this.someMethod() or this.someMethod.bind(this)?

i do wonder if we'll be forever playing catch up with that rule since it conflicts directly with how lit code is written. maybe we should just recommend turning the tseslint rule off?

@jpzwarte
Copy link
Author

unbound-method in tseslint will trigger since it wants us to pass () => this.someMethod() or this.someMethod.bind(this)?

Correct. The jest plugin I link to disables it where it does make sense in the context of jest.

i do wonder if we'll be forever playing catch up with that rule since it conflicts directly with how lit code is written. maybe we should just recommend turning the tseslint rule off?

I think it only conflicts with code inside templates, right? Outside of templates, it is a perfectly valid rule?

@43081j
Copy link
Owner

43081j commented Dec 4, 2023

what i mean is the no-template-arrow rule is stylistic really - pushing people to move functions into methods or variables instead of inlining them

i think we should just remove it from the recommended rule set and users of tseslint's recommended config would just not enable it (no-template-arrow).

anyone who does want to enable it should probably disable unbound-method too since the two usages will always conflict.

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