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

ESLint problem with "Link as Button" #544

Open
tomasholub opened this issue Feb 25, 2022 · 0 comments
Open

ESLint problem with "Link as Button" #544

tomasholub opened this issue Feb 25, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@tomasholub
Copy link

Describe the Bug

When I use Link as Button in the following code:

<Link as={Button} onClick={linkOnClick}>
  {linkText}
</Link>

ESLint throws error:

error  Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid

Expected Behavior

ESLint shouldn't throw the error.

Steps to Reproduce

See the code above

Environment

  • node 16.13
  • react 17.0.2

Additional Context

It is of course possible to use ESLint directive to prevent this error:

/* eslint-disable jsx-a11y/anchor-is-valid */

I have also noticed that if a non-empty attribute href or to is specified, the error is not thrown. However, the attribute has no function there (the onClick handler is used) and it is confusing to have it there.

@tomasholub tomasholub added the bug Something isn't working label Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant