Closed LarsDenBakker closed 5 years ago
An example of when you need an arrow function:
class MyElement extends LitElement {
render() {
return html`
${this.items.map((item, i)=> html`
<my-child @something=${() => this._onSomething(item, i)}></my-child>
`}
`;
}
}
It was introduced as a rule to catch all inline functions and binds essentially. To enforce the practice of separating your function out into methods or constants further up in the render method.
So I would probably prefer an option to allow arrow functions as opposed to a separate rule, something we can add quite easily.
@43081j Any plans to implement this? Running into the exact same issue. All I'm doing is setting a single property, so there's not really any reason to extract it into a full method.
Fixed in #41. Will go out in 1.0.0 soon
Currently the
no-template-bind
rule also takes care of inline arrow functions.Binding in templates is completely unnecessary, and should always be avoided. Arrow functions however are definitely needed in some cases, such as to pass arguments when repeating a template.
It would be nice if these were split up, so that they can be configured separately.