From eadd70cb1d0478c24538ee7604cf5493a96c0715 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 11 Aug 2023 15:10:27 -0700 Subject: [PATCH] [patch] `mouse-events-have-key-events`: rport the attribute, not the node This has the side benefit of making the error message ordering consistent, since when both were on the JSXOpeningElement, since eslint/node combinations ordered the errors inconsistently --- __tests__/src/rules/mouse-events-have-key-events-test.js | 8 ++++---- src/rules/mouse-events-have-key-events.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/__tests__/src/rules/mouse-events-have-key-events-test.js b/__tests__/src/rules/mouse-events-have-key-events-test.js index 4c1f41b44..638c9a51b 100644 --- a/__tests__/src/rules/mouse-events-have-key-events-test.js +++ b/__tests__/src/rules/mouse-events-have-key-events-test.js @@ -20,19 +20,19 @@ const ruleTester = new RuleTester(); const mouseOverError = { message: 'onMouseOver must be accompanied by onFocus for accessibility.', - type: 'JSXOpeningElement', + type: 'JSXAttribute', }; const pointerEnterError = { message: 'onPointerEnter must be accompanied by onFocus for accessibility.', - type: 'JSXOpeningElement', + type: 'JSXAttribute', }; const mouseOutError = { message: 'onMouseOut must be accompanied by onBlur for accessibility.', - type: 'JSXOpeningElement', + type: 'JSXAttribute', }; const pointerLeaveError = { message: 'onPointerLeave must be accompanied by onBlur for accessibility.', - type: 'JSXOpeningElement', + type: 'JSXAttribute', }; ruleTester.run('mouse-events-have-key-events', rule, { diff --git a/src/rules/mouse-events-have-key-events.js b/src/rules/mouse-events-have-key-events.js index ce30d6025..386c99870 100644 --- a/src/rules/mouse-events-have-key-events.js +++ b/src/rules/mouse-events-have-key-events.js @@ -67,7 +67,7 @@ export default ({ if (hasOnFocus === false || onFocusValue === null || onFocusValue === undefined) { context.report({ - node, + node: getProp(attributes, firstHoverInHandlerWithValue), message: `${firstHoverInHandlerWithValue} must be accompanied by onFocus for accessibility.`, }); } @@ -86,7 +86,7 @@ export default ({ if (hasOnBlur === false || onBlurValue === null || onBlurValue === undefined) { context.report({ - node, + node: getProp(attributes, firstHoverOutHandlerWithValue), message: `${firstHoverOutHandlerWithValue} must be accompanied by onBlur for accessibility.`, }); }