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.

Lint rules don't allow links with javascript:void href, or any alternative.

See original GitHub issue

For 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:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

15reactions
Timercommented, Mar 12, 2018

href={null} should work.

13reactions
abegehrcommented, Jul 8, 2018

bump 👍 please get rid of this rule

Read more comments on GitHub >

github_iconTop 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 >

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