Skip to content

scriptUrls

Reports javascript: URLs that can act as a form of eval.

✅ This rule is included in the browser logical preset.

Using javascript: URLs is a form of eval. Code passed in javascript: URLs is parsed and evaluated by the browser in the same way that eval is processed. This can lead to security vulnerabilities and is generally considered bad practice.

Use event handlers or proper JavaScript functions instead of javascript: URLs.

location.href = "javascript:void(0)";
const url = "javascript:alert('XSS')";
const link = `javascript:void(0)`;
window.location = "javascript:doSomething()";

If your project is internal-facing only and already uses javascript: URLs as a core design pattern, it might be difficult to enable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.