jsx-eslint/eslint-plugin-react

[jsx-handler-names] Option to enforce only for class methods

Open

#358 aberto em 11 de dez. de 2015

Ver no GitHub
 (6 comments) (5 reactions) (0 assignees)JavaScript (2.797 forks)batch import
enhancementhelp wantedrule

Métricas do repositório

Stars
 (8.630 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

This is a useful rule, but it can sometimes get annoying when I want to use a prop or a method from a library directly as a handler. I think the real benefit to the rule is to force me to name my component's methods appropriately, but as it currently works, I sometimes need to do silly things like const handleSelect = props.entities.toggleItem;.

I would really like an option which prevents:

<MyComponent onChange={this.doSomething} />

// or in a stateless component:

<MyComponent onChange={doSomething} />

but still allows:

<MyComponent onChange={library.doSomething} />

<MyComponent onChange={this.props.doSomething} />

// or in a stateless component:

<MyComponent onChange={props.doSomething} />

Does that make any sense?

Guia do colaborador