Skip to content

Commit

Permalink
feat(prefer-user-event): add support for React Native events
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Drozdov committed Nov 7, 2024
1 parent 657ed01 commit 6707e14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/rules/prefer-user-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ The following table lists all the possible equivalents from the low-level API `f
| `pointerOut` | <ul><li>`unhover`</li></ul> |
| `pointerOver` | <ul><li>`hover`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> |
| `pointerUp` | <ul><li>`click`</li><li>`dblClick`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> |
| `press` | <ul><li>`press`</li></ul> |
| `scroll` | <ul><li>`scrollTo`</li></ul> |
| `type` | <ul><li>`type`</li></ul> |
5 changes: 5 additions & 0 deletions lib/rules/prefer-user-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const UserEventMethods = [
'hover',
'unhover',
'paste',
'press',
'scrollTo',
] as const;
type UserEventMethodsType = (typeof UserEventMethods)[number];

Expand Down Expand Up @@ -51,6 +53,9 @@ export const MAPPING_TO_USER_EVENT: Record<string, UserEventMethodsType[]> = {
pointerOut: ['unhover'],
pointerOver: ['hover', 'selectOptions', 'deselectOptions'],
pointerUp: ['click', 'dblClick', 'selectOptions', 'deselectOptions'],
press: ['press'],
scroll: ['scrollTo'],
type: ['type'],
};

function buildErrorMessage(fireEventMethod: string) {
Expand Down

0 comments on commit 6707e14

Please sign in to comment.