react/style-prop-object
eslint-plugin-react
No autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/style-prop-object": "error",
},
},
];<div style="color: 'red'" />
<div style={true} />
<Hello style={true} />
const styles = true;
<div style={styles} />React.createElement("div", { style: "color: 'red'" });
React.createElement("div", { style: true });
React.createElement("Hello", { style: true });
const styles = true;
React.createElement("div", { style: styles });<div style={{ color: "red" }} />
<Hello style={{ color: "red" }} />
const styles = { color: "red" };
<div style={styles} />React.createElement("div", { style: { color: 'red' }});
React.createElement("Hello", { style: { color: 'red' }});
const styles = { height: '100px' };
React.createElement("div", { style: styles });Examples from the ESLint documentation.
react/style-prop-object
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/style-prop-object": "error",
},
},
];react/style-prop-object
react plugin · suspicious
{
"plugins": [
"react"
],
"rules": {
"react/style-prop-object": "error"
}
}Biome does not have this rule.
Enforce PascalCase for user-defined JSX components
Disallow using another component's propTypes
Disallow extra closing tags for components without children
Enforce shorthand or standard form for React fragments
Disallow .bind() or arrow functions in JSX props