# sort-prop-types

Rule `react/sort-prop-types`. Enforce propTypes declarations alphabetical sorting

- Source: react
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1886 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react/sort-prop-types` | no | safe | package `eslint-plugin-react` | [docs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/sort-prop-types.md) |

## Code examples

### Incorrect: the rule reports this

```jsx
var Component = createReactClass({
  propTypes: {
    z: PropTypes.number,
    a: PropTypes.any,
    b: PropTypes.string
  },
...
});
```

```jsx
type Props = {
  z: number,
  a: any,
  b: string
}
class Component extends React.Component<Props> {
  ...
}
```

```jsx
class Component extends React.Component {
  static propTypes = {
    z: PropTypes.any,
    y: PropTypes.any,
    a: PropTypes.any
  }
  render() {
    return <div />;
  }
}
```

### Correct: the rule accepts this

```jsx
var Component = createReactClass({
  propTypes: {
    a: PropTypes.number,
    b: PropTypes.any,
    c: PropTypes.string
  },
...
});
```

```jsx
type Props = {
  a: string,
  b: any,
  c: string,
}
class Component extends React.Component<Props> {
  ...
}
```

```jsx
class Component extends React.Component {
  static propTypes = {
    a: PropTypes.any,
    b: PropTypes.any,
    c: PropTypes.any
  }
  render() {
    return <div />;
  }
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import react from "eslint-plugin-react";

export default [
  {
    plugins: { react },
    rules: {
      "react/sort-prop-types": "error",
    },
  },
];
```

## Related rules

- [react/sort-default-props](https://lintradar.dev/rules/react/sort-default-props.md): Enforce defaultProps declarations alphabetical sorting
- [react/require-optimization](https://lintradar.dev/rules/react/require-optimization.md): Enforce React components to have a shouldComponentUpdate method
- [react/prefer-read-only-props](https://lintradar.dev/rules/react/prefer-read-only-props.md): Enforce that props are read-only
- [react/no-adjacent-inline-elements](https://lintradar.dev/rules/react/no-adjacent-inline-elements.md): Disallow adjacent inline elements not separated by whitespace.
- [react/jsx-sort-props](https://lintradar.dev/rules/react/jsx-sort-props.md): Enforce props alphabetical sorting
- [react/jsx-newline](https://lintradar.dev/rules/react/jsx-newline.md): Require or prevent a new line after jsx elements and expressions.

---

Web page: https://lintradar.dev/rules/react/sort-prop-types. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
