JS.BASE.NO.SCRIPT.URL

Disallow 'javascript:' urls

Using javascript: URLs is considered by some as a form of eval. Code passed in javascript: URLs has to be parsed and evaluated by the browser in the same way that eval is processed.

Rule Details

Examples of incorrect code for this rule:

Copy
/*eslint no-script-url: "error"*/

location.href = "javascript:void(0)";

location.href = `javascript:void(0)`;

Compatibility

  • JSHint: This rule corresponds to scripturl rule of JSHint.

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/