10
10
'use strict' ;
11
11
12
12
const docsUrl = require ( '../util/docsUrl' ) ;
13
- const ast = require ( '../util/ast' ) ;
13
+ const astUtil = require ( '../util/ast' ) ;
14
14
const componentUtil = require ( '../util/componentUtil' ) ;
15
15
const report = require ( '../util/report' ) ;
16
16
const getScope = require ( '../util/eslint' ) . getScope ;
@@ -44,7 +44,7 @@ function getName(node) {
44
44
}
45
45
46
46
function isThisExpression ( node ) {
47
- return ast . unwrapTSAsExpression ( uncast ( node ) ) . type === 'ThisExpression' ;
47
+ return astUtil . unwrapTSAsExpression ( uncast ( node ) ) . type === 'ThisExpression' ;
48
48
}
49
49
50
50
function getInitialClassInfo ( ) {
@@ -65,7 +65,7 @@ function getInitialClassInfo() {
65
65
}
66
66
67
67
function isSetStateCall ( node ) {
68
- const unwrappedCalleeNode = ast . unwrapTSAsExpression ( node . callee ) ;
68
+ const unwrappedCalleeNode = astUtil . unwrapTSAsExpression ( node . callee ) ;
69
69
70
70
return (
71
71
unwrappedCalleeNode . type === 'MemberExpression'
@@ -189,7 +189,7 @@ module.exports = {
189
189
// Used to record used state fields and new aliases for both
190
190
// AssignmentExpressions and VariableDeclarators.
191
191
function handleAssignment ( left , right ) {
192
- const unwrappedRight = ast . unwrapTSAsExpression ( right ) ;
192
+ const unwrappedRight = astUtil . unwrapTSAsExpression ( right ) ;
193
193
194
194
switch ( left . type ) {
195
195
case 'Identifier' :
@@ -292,8 +292,8 @@ module.exports = {
292
292
return ;
293
293
}
294
294
295
- const unwrappedNode = ast . unwrapTSAsExpression ( node ) ;
296
- const unwrappedArgumentNode = ast . unwrapTSAsExpression ( unwrappedNode . arguments [ 0 ] ) ;
295
+ const unwrappedNode = astUtil . unwrapTSAsExpression ( node ) ;
296
+ const unwrappedArgumentNode = astUtil . unwrapTSAsExpression ( unwrappedNode . arguments [ 0 ] ) ;
297
297
298
298
// If we're looking at a `this.setState({})` invocation, record all the
299
299
// properties as state fields.
@@ -308,7 +308,7 @@ module.exports = {
308
308
&& unwrappedNode . arguments . length > 0
309
309
&& unwrappedArgumentNode . type === 'ArrowFunctionExpression'
310
310
) {
311
- const unwrappedBodyNode = ast . unwrapTSAsExpression ( unwrappedArgumentNode . body ) ;
311
+ const unwrappedBodyNode = astUtil . unwrapTSAsExpression ( unwrappedArgumentNode . body ) ;
312
312
313
313
if ( unwrappedBodyNode . type === 'ObjectExpression' ) {
314
314
addStateFields ( unwrappedBodyNode ) ;
@@ -330,7 +330,7 @@ module.exports = {
330
330
}
331
331
// If we see state being assigned as a class property using an object
332
332
// expression, record all the fields of that object as state fields.
333
- const unwrappedValueNode = ast . unwrapTSAsExpression ( node . value ) ;
333
+ const unwrappedValueNode = astUtil . unwrapTSAsExpression ( node . value ) ;
334
334
335
335
const name = getName ( node . key ) ;
336
336
if (
@@ -452,8 +452,8 @@ module.exports = {
452
452
return ;
453
453
}
454
454
455
- const unwrappedLeft = ast . unwrapTSAsExpression ( node . left ) ;
456
- const unwrappedRight = ast . unwrapTSAsExpression ( node . right ) ;
455
+ const unwrappedLeft = astUtil . unwrapTSAsExpression ( node . left ) ;
456
+ const unwrappedRight = astUtil . unwrapTSAsExpression ( node . right ) ;
457
457
458
458
// Check for assignments like `this.state = {}`
459
459
if (
@@ -493,7 +493,7 @@ module.exports = {
493
493
if ( ! classInfo ) {
494
494
return ;
495
495
}
496
- if ( isStateReference ( ast . unwrapTSAsExpression ( node . object ) ) ) {
496
+ if ( isStateReference ( astUtil . unwrapTSAsExpression ( node . object ) ) ) {
497
497
// If we see this.state[foo] access, give up.
498
498
if ( node . computed && node . property . type !== 'Literal' ) {
499
499
classInfo = null ;
0 commit comments