Enforces the order of keys in createModel
specification.
This rule enforces the order of the keys in the object that is the argument to createModel
. Keys are broken into three groups:
- Life Cycle: keys with a specific meaning to
createModel
such asdisplayName
andmodelDidMount
. Their order can be customized withlifeCycleProps
. - Senders/Receivers: methods used in sending/receiving messages; they should come after lifecycle methods (if there are any) and can optionally be required via
sendRecvPairs
to be in pairs likesendFooMsg
recvFooMsg
- Helpers: setters and getters that should come after lifecycle methods or senders/receivers if there are any.
Below is the .eslintrc
entry that would configure this rule to have its default behavior and which can be customized
{
"rules": {
"modulajs/createmodel-attrs-order": ["warn", {
"firstPropRequired" : false, // reports first Life Cycle prop not present
"sendRecvPairs" : false, // enforces sequential sendFoo(), recvFoo()
"mustHaveAnyProps" : false, // reports createModel() or createModel([])
"lifeCycleProps" : [ // user can specify order
"displayName",
"propTypes",
"localPropTypes",
"defaults",
"contextTypes",
"childContextTypes",
"getChildContext",
"eventTypes",
"watchEventTypes",
"watchEvent",
"delegates",
"services",
"modelDidMount",
"modelDidUpdate",
"modelWillUnmount"
]
}]
}
}