Skip to main content
interlace
Plugin: react-featuresRules

jsx-no-script-url

Prevent javascript: URLs in JSX. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Prevent javascript: URLs in JSX. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Quick Summary

AspectDetails
SeverityError (security)
Auto-Fix❌ No auto-fix
CategoryReact Security
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForAll React/JSX projects

Rule Details

Using javascript: URLs is a security risk and can lead to XSS vulnerabilities.

Examples

❌ Incorrect

<a href="javascript:void(0)">Click</a>

<a href="javascript:alert('XSS')">Click</a>

✅ Correct

<a href="#" onClick={handleClick}>Click</a>

<button onClick={handleClick}>Click</button>

What is checked

  • Props: href, src, action, formAction, data, poster, background and SVG's xlink:href, plus the component props named by the options.
  • Values: a string in any letter case, after the leading control characters and the embedded tab / newline characters the URL parser strips; braced ({'javascript:…'}); a template whose text before the first placeholder is the scheme; either branch of a conditional. A dynamic value is not judged.

Options

{
  rules: {
    'react-features/jsx-no-script-url': ['error',
      // Component props to check, in addition to the URL props above
      [{ name: 'Link', props: ['to'] }],
      // Also read `settings.linkComponents` (eslint-plugin-react's shared setting:
      // `'Hyperlink'` checks its `href`; `{ name: 'Link', linkAttribute: 'to' }`
      // or `linkAttribute: ['to', 'href']` checks the named props)
      { includeFromSettings: true },
    ],
  },
}

Use this rule

npm install -D oxlint-plugin-react-features
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-react-features"],  "rules": {    "react-features/jsx-no-script-url": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-react-features'],    rules: {      'react-features/jsx-no-script-url': 'error',    },  },});

oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.