@@ -86,7 +86,7 @@ module.exports = (file, api, options) => {
86
86
87
87
const hasNoCallsToDeprecatedAPIs = classPath => {
88
88
if ( checkDeprecatedAPICalls ( classPath ) ) {
89
- console . log (
89
+ console . warn (
90
90
file . path + ': `' + ReactUtils . getComponentName ( classPath ) + '` ' +
91
91
'was skipped because of deprecated API calls. Remove calls to ' +
92
92
DEPRECATED_APIS . join ( ', ' ) + ' in your React component and re-run ' +
@@ -103,7 +103,7 @@ module.exports = (file, api, options) => {
103
103
j ( classPath ) . find ( j . Identifier , { name : GET_INITIAL_STATE_FIELD } ) . size ( ) > 1
104
104
) ;
105
105
if ( hasInvalidCalls ) {
106
- console . log (
106
+ console . warn (
107
107
file . path + ': `' + ReactUtils . getComponentName ( classPath ) + '` ' +
108
108
'was skipped because of API calls that will be removed. Remove calls to `' +
109
109
DEFAULT_PROPS_FIELD + '` and/or `' + GET_INITIAL_STATE_FIELD +
@@ -114,6 +114,22 @@ module.exports = (file, api, options) => {
114
114
return true ;
115
115
} ;
116
116
117
+ const doesNotUseArguments = classPath => {
118
+ const hasArguments = (
119
+ j ( classPath ) . find ( j . Identifier , { name : 'arguments' } ) . size ( ) > 0
120
+ ) ;
121
+ if ( hasArguments ) {
122
+ console . warn (
123
+ file . path + ': `' + ReactUtils . getComponentName ( classPath ) + '` ' +
124
+ 'was skipped because `arguments` was found in your functions. ' +
125
+ 'Arrow functions do not expose an `arguments` object; ' +
126
+ 'consider changing to use ES6 spread operator and re-run this script.'
127
+ ) ;
128
+ return false ;
129
+ }
130
+ return true ;
131
+ } ;
132
+
117
133
const canConvertToClass = classPath => {
118
134
const specPath = ReactUtils . getReactCreateClassSpec ( classPath ) ;
119
135
const invalidProperties = specPath . properties . filter ( prop => (
@@ -133,7 +149,7 @@ module.exports = (file, api, options) => {
133
149
const invalidText = invalidProperties
134
150
. map ( prop => prop . key . name ? prop . key . name : prop . key )
135
151
. join ( ', ' ) ;
136
- console . log (
152
+ console . warn (
137
153
file . path + ': `' + ReactUtils . getComponentName ( classPath ) + '` ' +
138
154
'was skipped because of invalid field(s) `' + invalidText + '` on ' +
139
155
'the React component. Remove any right-hand-side expressions that ' +
@@ -835,7 +851,7 @@ module.exports = (file, api, options) => {
835
851
return true ;
836
852
}
837
853
}
838
- console . log (
854
+ console . warn (
839
855
file . path + ': `' + ReactUtils . getComponentName ( classPath ) + '` ' +
840
856
'was skipped because of inconvertible mixins.'
841
857
) ;
@@ -847,6 +863,7 @@ module.exports = (file, api, options) => {
847
863
. filter ( mixinsFilter )
848
864
. filter ( hasNoCallsToDeprecatedAPIs )
849
865
. filter ( hasNoCallsToAPIsThatWillBeRemoved )
866
+ . filter ( doesNotUseArguments )
850
867
. filter ( canConvertToClass )
851
868
. forEach ( classPath => updateToClass ( classPath , type ) ) ;
852
869
0 commit comments