@@ -38,37 +38,40 @@ const checkDefault = () => {
3838 * - objectMethod => object: 'Object', property: 'fromEntries', etc.
3939 */
4040const checkCallExpression = ( node , astInfo ) => {
41- // Must be `CallExpression`
4241 if ( node . type !== 'CallExpression' ) return false ;
43-
44- // We might check if node.callee is a MemberExpression, e.g. array.includes(...)
45- // or if node.callee is an Identifier, e.g. Symbol(...).
4642 if ( node . callee . type === 'MemberExpression' ) {
4743 const { object, property } = astInfo ;
48- // e.g. object: 'Object', property: 'entries'
49- // => node.callee.object.name === 'Object' && node.callee.property.name === 'entries'
50- if ( object ) {
51- if (
52- ! node . callee . object ||
53- node . callee . object . type !== 'Identifier' ||
54- node . callee . object . name !== object
55- ) {
56- return false ;
44+
45+ if ( object || property ) {
46+
47+ if ( object ) {
48+ if (
49+ ! node . callee . object ||
50+ node . callee . object . type !== 'Identifier' ||
51+ node . callee . object . name !== object
52+ ) {
53+ return false ;
54+ }
5755 }
58- }
59- if ( property ) {
60- // e.g. property: 'includes'
61- if ( ! node . callee . property || node . callee . property . name !== property ) {
62- return false ;
56+
57+ if ( property ) {
58+ if (
59+ ! node . callee . property ||
60+ node . callee . property . type !== 'Identifier' ||
61+ node . callee . property . name !== property
62+ ) {
63+ return false ;
64+ }
6365 }
66+ return true ;
6467 }
65- return true ;
66- } else if ( node . callee . type === 'Identifier' ) {
67- // e.g. Symbol("desc")
68+ return false ;
69+ }
70+
71+ if ( node . callee . type === 'Identifier' ) {
6872 const { callee } = astInfo ;
69- // If astInfo.callee is "Symbol", check node.callee.name
70- if ( callee && node . callee . name === callee ) {
71- return true ;
73+ if ( callee && ! astInfo . object && ! astInfo . property ) {
74+ return node . callee . name === callee ;
7275 }
7376 }
7477
0 commit comments