I know class properties are not adopted into spec now, but it's already stage-3 and should be stable
In my case we designed the sort-comp rule as:
{
"order": [
"static-properties", <--
"static-methods",
"state",
"properties", <--
"lifecycle",
"everything-else",
"render"
],
"groups": {
"static-properties": [
"displayName",
"propTypes",
"contextTypes",
"childContextTypes",
"mixins",
"statics"
],
"lifecycle": [
"getDefaultProps",
"getInitialState",
"constructor",
"getChildContext",
"componentWillMount",
"componentDidMount",
"componentWillReceiveProps",
"shouldComponentUpdate",
"componentWillUpdate",
"componentDidUpdate",
"componentWillUnmount"
]
}
}
We want static properties to come before static methods, and instance properties to come with state property, however the sort-comp rule does not currently support this, it warns if a instance property appears after state and before other methods:
error chart should be placed after componentWillUnmount react/sort-comp
eslint core doesn't support them yet, but we can certainly add commented-out tests for it (and add real tests using babel-eslint).
Seems like we need (if we don't already have them) "static-properties", "instance-properties", "private-static-fields", and "private-instance-fields".
+1, this would be nice
I'm having the same problem. I use class properties, but sort-comp insists that they all be placed after componentWillUnmount.
+1
Please don't use +1 replies. There is the possibility to add a thumbs up emoji on the main post that have the same effect. Thanks 馃槃
+1
Most helpful comment
eslint core doesn't support them yet, but we can certainly add commented-out tests for it (and add real tests using babel-eslint).
Seems like we need (if we don't already have them) "static-properties", "instance-properties", "private-static-fields", and "private-instance-fields".