react/no-danger
eslint-plugin-react
No autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/no-danger": "error",
},
},
];var React = require('react');
var Hello = <div dangerouslySetInnerHTML={{ __html: "Hello World" }}></div>;var React = require('react');
var Hello = <div>Hello World</div>;Examples from the ESLint documentation.
react/no-danger
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/no-danger": "error",
},
},
];react/no-danger
react plugin · restriction
{
"plugins": [
"react"
],
"rules": {
"react/no-danger": "error"
}
}security/noDangerouslySetInnerHtml
security · since 1.0.0
{
"linter": {
"rules": {
"security": {
"noDangerouslySetInnerHtml": "error"
}
}
}
}Disallow usage of Array index in keys
Disallow usage of button elements without an explicit type attribute
Disallow void DOM elements (e.g. <img />, <br />) from receiving children
Disallow unnecessary fragments
Disallow usage of referential-type variables as default param in functional component
Disallow missing props validation in a React component definition