Skip to content

has-valid-accessibility-actions rule doesn't accept variables #108

Closed
@JCMartell

Description

@JCMartell

Hi,

I was fixing some lint errors and encountered this situation:

const onAccessibilityAction = (event: { nativeEvent: { actionName: any } }) => {
    switch (event.nativeEvent.actionName) {
        case "delete":
            deleteAction();
            break;
        default:
            Alert.alert("Some text);
    }
}

const accessibilityActionsList: Array<{ name: string, label: string }> = [{ name: "delete", label: "Delete" }];

<TouchableOpacity
    accessibilityActions={accessibilityActionsList}
    onAccessibilityAction={onAccessibilityAction}
>
    ...
</TouchableOpacity>

Here, the has-valid-accessibility-actions rule throws the following errors: accessibilityActions: value must be an Array and accessibilityActions: has accessibilityActions but onAccessibilityAction is not a function. However, both of my variables have the correct types. I tried putting the array and the function as is in the JSX (without putting them in a variable) and it worked fine, but I prefer having a simpler/cleaner JSX.

Do you think this is something that can be fixed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions