question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: Anchor is valid rule used in Create React App

See original GitHub issue

From a discussion I had with @gaearon.

Currently this rule is activated in Create React App. Which does a lot of good. However, due to the reach of the CLI tool it can sometimes cause confusion for developers who want to upgrade to newer versions. Developers lacking the a11y knowledge who suddenly get confronted by new errors on the console.

For example: https://github.com/facebook/create-react-app/issues/4141

I want to make a PR proposal to update the docs and, possibly, the error message of this rule to assist these developers to easily find the information in question.

But first I want to know how you feel about such a change.

Consider the situation where a developer HAS to have a clickable thing look like an anchor due to design forced upon them, would it be OK to add a paragraph in the docs on how to style a button to look like a link? I know that ideally we would not want that but what is happening now is that developers facing this situation just suppress the rule. Where instead a button element styled as a link would be a large improvement already instead of an anchor without an href.

Also the PR would suggested to change the error message of the noHref aspect to something along the lines of: “The href attribute requires a valid value for the link to be keyboard accessible. Provide a valid, navigable address as the href value. Alternatively, change it to a <button> with appropriate styles. Learn more: <url>”

Please let me know what you think. As I said this rule is activated in every react app started with Create React App and could go a long way to help with education.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ljharbcommented, Oct 2, 2018

I think better documentation is always better, and as long as they stress very heavily that such designs are subpar (giving devs ample ability to push back on design with an authoritative reference), providing instructions of how to have proper semantic elements with the aesthetics they’re required to impose seems like a much better outcome than having them disable the rule.

2reactions
AlmeroSteyncommented, Oct 2, 2018

PR in at #486

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discussion: Anchor is valid rule used in Create React App #485
From a discussion I had with @gaearon. Currently this rule is activated in Create React App. Which does a lot of good.
Read more >
Turning eslint rule off in eslintrc.json - reactjs - Stack Overflow
This used to work before I upgraded create-react-app to version 2.0, where my eslint rule was simply "jsx-a11y/anchor-is-valid": 0 . I have read ......
Read more >
Disabling specific eslint rules - DEV Community ‍ ‍
The create react app eslint presets come with a few rules that are ... don't add an tag without a valid http address...
Read more >
How to Disable Specific ESLint Rules - Alex Sharp
Disabling specific eslint rules can be done by adding a .eslintrc.js file at your project root.
Read more >
anchor-is-valid - GitLab
The use of JavaScript frameworks and libraries, like React, has made it very easy to add or subtract functionality from the standard HTML ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found