@@ -134,86 +134,71 @@ module.exports = {
134134 const methodGroupIndexes = [ ] ;
135135
136136 methodsOrder . forEach ( ( currentGroup , groupIndex ) => {
137- switch ( currentGroup ) {
138- case 'getters' : {
139- if ( method . getter ) {
140- methodGroupIndexes . push ( groupIndex ) ;
141- }
142- break ;
137+ if ( currentGroup === 'getters' ) {
138+ if ( method . getter ) {
139+ methodGroupIndexes . push ( groupIndex ) ;
143140 }
144- case 'setters' : {
145- if ( method . setter ) {
146- methodGroupIndexes . push ( groupIndex ) ;
147- }
148- break ;
141+ } else if ( currentGroup === 'setters' ) {
142+ if ( method . setter ) {
143+ methodGroupIndexes . push ( groupIndex ) ;
149144 }
150- case 'type-annotations' : {
151- if ( method . typeAnnotation ) {
152- methodGroupIndexes . push ( groupIndex ) ;
153- }
154- break ;
145+ } else if ( currentGroup === 'type-annotations' ) {
146+ if ( method . typeAnnotation ) {
147+ methodGroupIndexes . push ( groupIndex ) ;
155148 }
156- case 'static-methods' : {
157- if ( method . static ) {
158- methodGroupIndexes . push ( groupIndex ) ;
159- }
160- break ;
149+ } else if ( currentGroup === 'static-methods' ) {
150+ if ( method . static ) {
151+ methodGroupIndexes . push ( groupIndex ) ;
161152 }
162- case 'instance-variables' : {
163- if ( method . instanceVariable ) {
164- methodGroupIndexes . push ( groupIndex ) ;
165- }
166- break ;
153+ } else if ( currentGroup === 'instance-variables' ) {
154+ if ( method . instanceVariable ) {
155+ methodGroupIndexes . push ( groupIndex ) ;
167156 }
168- case 'instance-methods' : {
169- if ( method . instanceMethod ) {
170- methodGroupIndexes . push ( groupIndex ) ;
171- }
172- break ;
157+ } else if ( currentGroup === 'instance-methods' ) {
158+ if ( method . instanceMethod ) {
159+ methodGroupIndexes . push ( groupIndex ) ;
173160 }
174- case 'displayName' :
175- case 'propTypes' :
176- case 'contextTypes' :
177- case 'childContextTypes' :
178- case 'mixins' :
179- case 'statics' :
180- case 'defaultProps' :
181- case 'constructor' :
182- case 'getDefaultProps' :
183- case 'state' :
184- case 'getInitialState' :
185- case 'getChildContext' :
186- case 'getDerivedStateFromProps' :
187- case 'componentWillMount' :
188- case 'UNSAFE_componentWillMount' :
189- case 'componentDidMount' :
190- case 'componentWillReceiveProps' :
191- case 'UNSAFE_componentWillReceiveProps' :
192- case 'shouldComponentUpdate' :
193- case 'componentWillUpdate' :
194- case 'UNSAFE_componentWillUpdate' :
195- case 'getSnapshotBeforeUpdate' :
196- case 'componentDidUpdate' :
197- case 'componentDidCatch' :
198- case 'componentWillUnmount' :
199- case 'render' : {
200- if ( currentGroup === method . name ) {
201- methodGroupIndexes . push ( groupIndex ) ;
202- }
203- break ;
161+ } else if ( [
162+ 'displayName' ,
163+ 'propTypes' ,
164+ 'contextTypes' ,
165+ 'childContextTypes' ,
166+ 'mixins' ,
167+ 'statics' ,
168+ 'defaultProps' ,
169+ 'constructor' ,
170+ 'getDefaultProps' ,
171+ 'state' ,
172+ 'getInitialState' ,
173+ 'getChildContext' ,
174+ 'getDerivedStateFromProps' ,
175+ 'componentWillMount' ,
176+ 'UNSAFE_componentWillMount' ,
177+ 'componentDidMount' ,
178+ 'componentWillReceiveProps' ,
179+ 'UNSAFE_componentWillReceiveProps' ,
180+ 'shouldComponentUpdate' ,
181+ 'componentWillUpdate' ,
182+ 'UNSAFE_componentWillUpdate' ,
183+ 'getSnapshotBeforeUpdate' ,
184+ 'componentDidUpdate' ,
185+ 'componentDidCatch' ,
186+ 'componentWillUnmount' ,
187+ 'render'
188+ ] . includes ( currentGroup ) ) {
189+ if ( currentGroup === method . name ) {
190+ methodGroupIndexes . push ( groupIndex ) ;
204191 }
205- default : {
206- // Is the group a regex?
207- const isRegExp = currentGroup . match ( regExpRegExp ) ;
208- if ( isRegExp ) {
209- const isMatching = new RegExp ( isRegExp [ 1 ] , isRegExp [ 2 ] ) . test ( method . name ) ;
210- if ( isMatching ) {
211- methodGroupIndexes . push ( groupIndex ) ;
212- }
213- } else if ( currentGroup === method . name ) {
192+ } else {
193+ // Is the group a regex?
194+ const isRegExp = currentGroup . match ( regExpRegExp ) ;
195+ if ( isRegExp ) {
196+ const isMatching = new RegExp ( isRegExp [ 1 ] , isRegExp [ 2 ] ) . test ( method . name ) ;
197+ if ( isMatching ) {
214198 methodGroupIndexes . push ( groupIndex ) ;
215199 }
216- break ;
200+ } else if ( currentGroup === method . name ) {
201+ methodGroupIndexes . push ( groupIndex ) ;
217202 }
218203 }
219204 } ) ;
0 commit comments