Lint rules don't allow links with javascript:void href, or any alternative.
See original GitHub issueFor a variety of valid reasons, you may want to have html anchors with a href that is null for a time. One way of doing this is href='javascript:void(0)'
, however this triggers:
Script URL is a form of eval no-script-url" lint error.
Another way is href='#'
. This triggers:
Links must not point to "#". Use a more descriptive href or use a button instead jsx-a11y/href-no-hash
Another way is <a href>
, This triggers:
Warning: Received 'true' for a non-boolean attribute 'href'.
Are there ways to achieve the desired effect without lint errors, otherwise can one of these be removed?
See: #808
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:21 (9 by maintainers)
Top Results From Across the Web
Which "href" value should I use for JavaScript links, "#" or ...
I use javascript:void(0) . Three reasons. Encouraging the use of # amongst a team of developers inevitably leads to some using the return...
Read more >Links should not target "#" or "javascript:void(0)"
The goal of this rule is to ban such patterns in order to support browsing with JavaScript disabled. Noncompliant Code Example. <a href="#"...
Read more >anchor-is-valid - GitLab
Case: I want navigable links. An <a> element without an href attribute no longer functions as a hyperlink. That means that it can...
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
url (string) specifies the URL at which the full documentation can be accessed (enabling code editors to provide a helpful link on highlighted...
Read more >Linter rules - Dart
Details about the Dart linter and its style rules you can choose. ... class A { StreamSubscription _subscriptionA; // LINT void init(Stream stream) ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
href={null}
should work.bump 👍 please get rid of this rule