@@ -10,13 +10,44 @@ const util = require('util');
1010const Components = require ( '../util/Components' ) ;
1111const astUtil = require ( '../util/ast' ) ;
1212
13+ const defaultConfig = {
14+ order : [
15+ 'static-methods' ,
16+ 'lifecycle' ,
17+ 'everything-else' ,
18+ 'render'
19+ ] ,
20+ groups : {
21+ lifecycle : [
22+ 'displayName' ,
23+ 'propTypes' ,
24+ 'contextTypes' ,
25+ 'childContextTypes' ,
26+ 'mixins' ,
27+ 'statics' ,
28+ 'defaultProps' ,
29+ 'constructor' ,
30+ 'getDefaultProps' ,
31+ 'state' ,
32+ 'getInitialState' ,
33+ 'getChildContext' ,
34+ 'componentWillMount' ,
35+ 'componentDidMount' ,
36+ 'componentWillReceiveProps' ,
37+ 'shouldComponentUpdate' ,
38+ 'componentWillUpdate' ,
39+ 'componentDidUpdate' ,
40+ 'componentWillUnmount'
41+ ]
42+ }
43+ } ;
44+
1345/**
1446 * Get the methods order from the default config and the user config
15- * @param {Object } defaultConfig The default configuration.
1647 * @param {Object } userConfig The user configuration.
1748 * @returns {Array } Methods order
1849 */
19- function getMethodsOrder ( defaultConfig , userConfig ) {
50+ function getMethodsOrder ( userConfig ) {
2051 userConfig = userConfig || { } ;
2152
2253 const groups = util . _extend ( defaultConfig . groups , userConfig . groups ) ;
@@ -78,37 +109,7 @@ module.exports = {
78109
79110 const MISPOSITION_MESSAGE = '{{propA}} should be placed {{position}} {{propB}}' ;
80111
81- const methodsOrder = getMethodsOrder ( {
82- order : [
83- 'static-methods' ,
84- 'lifecycle' ,
85- 'everything-else' ,
86- 'render'
87- ] ,
88- groups : {
89- lifecycle : [
90- 'displayName' ,
91- 'propTypes' ,
92- 'contextTypes' ,
93- 'childContextTypes' ,
94- 'mixins' ,
95- 'statics' ,
96- 'defaultProps' ,
97- 'constructor' ,
98- 'getDefaultProps' ,
99- 'state' ,
100- 'getInitialState' ,
101- 'getChildContext' ,
102- 'componentWillMount' ,
103- 'componentDidMount' ,
104- 'componentWillReceiveProps' ,
105- 'shouldComponentUpdate' ,
106- 'componentWillUpdate' ,
107- 'componentDidUpdate' ,
108- 'componentWillUnmount'
109- ]
110- }
111- } , context . options [ 0 ] ) ;
112+ const methodsOrder = getMethodsOrder ( context . options [ 0 ] ) ;
112113
113114 // --------------------------------------------------------------------------
114115 // Public
@@ -438,5 +439,7 @@ module.exports = {
438439 reportErrors ( ) ;
439440 }
440441 } ;
441- } )
442+ } ) ,
443+
444+ defaultConfig
442445} ;
0 commit comments