Skip to main content
interlace
Plugin: react-featuresRules

no-danger-with-children

Prevent using children and dangerouslySetInnerHTML together. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Prevent using children and dangerouslySetInnerHTML together. This rule is part of eslint-plugin-react-features and provides LLM-optimized error messages.

Quick Summary

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

Rule Details

Using both children and dangerouslySetInnerHTML is ambiguous - React will throw an error.

Examples

❌ Incorrect

<div dangerouslySetInnerHTML={{ __html: html }}>
  Some text
</div>

<div dangerouslySetInnerHTML={{ __html: html }} children="text" />

✅ Correct

<div dangerouslySetInnerHTML={{ __html: html }} />

<div>Some text</div>
  • no-danger - Warn about dangerouslySetInnerHTML usage

Use this rule

npm install -D oxlint-plugin-react-features
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-react-features"],  "rules": {    "react-features/no-danger-with-children": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-react-features'],    rules: {      'react-features/no-danger-with-children': '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.