-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
Hello!
I recently started receiving errors about my static propTypes being out of order. It looks like with the grouping logic, all static variables must be in alphabetical order. This causes my prop types to be forced down.
I've gotten around this by adding the following regex to my config which will push displayName, propTypes, and defaultProps to the top while allowing all other static methods to be below them.
"react/sort-comp": [
"error",
{
order: [
'static-methods',
'lifecycle',
'everything-else',
'render'
],
groups: {
'static-methods': [
'displayName',
'propTypes',
'defaultProps',
'/^((?!propTypes|defaultProps).)*$/',
],
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'state',
'getInitialState',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount'
]
}
}
]example error:
13:3 error propTypes should be placed after determineDropdownValue react/sort-comp
``
elliotleelewis, VictorChen and ericgio
Metadata
Metadata
Assignees
Labels
No labels