Rules
no-script-url
Disallows 'javascript:' URLs as attribute values.
Full Name in eslint-plugin-react-dom
react-dom/no-script-urlFull Name in @eslint-react/eslint-plugin
@eslint-react/dom/no-script-urlPresets
dom
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
javascript: URLs are a form of XSS attack. They allow an attacker to execute arbitrary JavaScript in the context of your website, which can be used to steal user data, deface your website, or perform other malicious actions.
Common Violations
Invalid
function MyComponent() {
return <a href="javascript:alert('Hello, world!')">Click me</a>;
// ^^^ Using a `javascript:` URL is a security risk and should be avoided.
}Valid
function MyComponent() {
return <a href="/some-page">Click me</a>;
}Resources
See Also
react-dom/no-dangerously-set-innerhtml
Disallows DOM elements from usingdangerouslySetInnerHTML.react-dom/no-unsafe-target-blank
Disallowstarget="_blank"withoutrel="noreferrer noopener".