66
77import type { JSXOpeningElement } from 'ast-types-flow' ;
88import { getProp , getPropValue , hasEveryProp , hasProp } from 'jsx-ast-utils' ;
9+ import isNodePropExpression from '../util/isNodePropExpression' ;
910import { generateObjSchema } from '../util/schemas' ;
1011import type { ESLintContext } from '../../flow/eslint' ;
1112
@@ -43,12 +44,8 @@ module.exports = {
4344 ] )
4445 ) {
4546 const handlerProp = getProp ( node . attributes , 'onAccessibilityAction' ) ;
46- const handlerPropType = handlerProp . value . expression . type ;
47- // CallExpressions & Identifiers are always assumed valid
48- if (
49- handlerPropType !== 'CallExpression' &&
50- handlerPropType !== 'Identifier'
51- ) {
47+ const isHandlerExpression = isNodePropExpression ( handlerProp ) ;
48+ if ( ! isHandlerExpression ) {
5249 const handlerPropValue = getPropValue ( handlerProp ) ;
5350 if ( typeof handlerPropValue !== 'function' ) {
5451 error (
@@ -58,12 +55,8 @@ module.exports = {
5855 }
5956
6057 const actionsProp = getProp ( node . attributes , 'accessibilityActions' ) ;
61- const actionsPropType = actionsProp . value . expression . type ;
62- // CallExpressions & Identifiers are always assumed valid
63- if (
64- actionsPropType !== 'CallExpression' &&
65- actionsPropType !== 'Identifier'
66- ) {
58+ const isActionsExpression = isNodePropExpression ( actionsProp ) ;
59+ if ( ! isActionsExpression ) {
6760 const attrValue = getPropValue ( actionsProp ) ;
6861
6962 if ( ! Array . isArray ( attrValue ) ) {
0 commit comments