@@ -43,9 +43,10 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({
43
43
44
44
create ( context , [ options ] ) {
45
45
const { renderFunctions } = options ;
46
- let containerName = '' ;
47
- let renderWrapperName = '' ;
48
46
let hasPropertyContainer = false ;
47
+ let containerName : string = null ;
48
+ let renderWrapperName : string = null ;
49
+ const destructuredContainerPropNames : string [ ] = [ ] ;
49
50
50
51
return {
51
52
VariableDeclarator ( node ) {
@@ -59,7 +60,17 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({
59
60
) ;
60
61
const nodeValue =
61
62
containerIndex !== - 1 && node . id . properties [ containerIndex ] . value ;
62
- containerName = isIdentifier ( nodeValue ) && nodeValue . name ;
63
+ if ( isIdentifier ( nodeValue ) ) {
64
+ containerName = nodeValue . name ;
65
+ } else {
66
+ isObjectPattern ( nodeValue ) &&
67
+ nodeValue . properties . forEach (
68
+ property =>
69
+ isProperty ( property ) &&
70
+ isIdentifier ( property . key ) &&
71
+ destructuredContainerPropNames . push ( property . key . name )
72
+ ) ;
73
+ }
63
74
} else {
64
75
renderWrapperName = isIdentifier ( node . id ) && node . id . name ;
65
76
}
@@ -83,7 +94,7 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({
83
94
84
95
if ( isContainerName || hasPropertyContainer ) {
85
96
context . report ( {
86
- node,
97
+ node : innerNode ,
87
98
messageId : 'noContainer' ,
88
99
} ) ;
89
100
}
@@ -95,6 +106,12 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({
95
106
}
96
107
if ( isMemberExpression ( node . callee ) ) {
97
108
showErrorForChainedContainerMethod ( node . callee ) ;
109
+ } else if ( isIdentifier ( node . callee ) ) {
110
+ destructuredContainerPropNames . includes ( node . callee . name ) &&
111
+ context . report ( {
112
+ node,
113
+ messageId : 'noContainer' ,
114
+ } ) ;
98
115
}
99
116
} ,
100
117
} ;
0 commit comments