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
``
Metadata
Metadata
Assignees
Labels
No labels