Skip to content

Некорректная работа правила react/button-has-type #38

Closed
reme3d2y opened this issue Mar 23, 2020 · 1 comment
Closed

Comments

@reme3d2y
Copy link
Contributor

Данное правило не позволяет задавать аттрибут type динамически.

export const Button: React.FC<{
    type?: 'button' | 'reset' | 'submit';
}> = ({ type = 'button' }) => {
    return <button type={type}>Кнопка</button>;
};

Этот код дает вот такую ошибку:
type is an invalid value for button type attribute
eslint(react/button-has-type)

Обсуждение правила

@Heymdall
Copy link
Member

Heymdall commented Jul 6, 2020

Кажется, подобные штуки лучше всего решать через disable коменты. Само по себе правила зла не несет, но реализация у него действительно хромает. Тем не менее, в общем случае, правило хорошее.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants