react/sort-prop-types
eslint-plugin-react
Safe autofix
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/sort-prop-types": "error",
},
},
];var Component = createReactClass({
propTypes: {
z: PropTypes.number,
a: PropTypes.any,
b: PropTypes.string
},
...
});type Props = {
z: number,
a: any,
b: string
}
class Component extends React.Component<Props> {
...
}class Component extends React.Component {
static propTypes = {
z: PropTypes.any,
y: PropTypes.any,
a: PropTypes.any
}
render() {
return <div />;
}
}var Component = createReactClass({
propTypes: {
a: PropTypes.number,
b: PropTypes.any,
c: PropTypes.string
},
...
});type Props = {
a: string,
b: any,
c: string,
}
class Component extends React.Component<Props> {
...
}class Component extends React.Component {
static propTypes = {
a: PropTypes.any,
b: PropTypes.any,
c: PropTypes.any
}
render() {
return <div />;
}
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
react/sort-prop-types
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/sort-prop-types": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Enforce React components to have a shouldComponentUpdate method
Disallow adjacent inline elements not separated by whitespace.
Require or prevent a new line after jsx elements and expressions.