Skip to content

Commit

Permalink
[patch] mouse-events-have-key-events: rport the attribute, not the …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
ljharb committed Aug 11, 2023
1 parent 0c278f4 commit eadd70c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions __tests__/src/rules/mouse-events-have-key-events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/mouse-events-have-key-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
});
}
Expand All @@ -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.`,
});
}
Expand Down

0 comments on commit eadd70c

Please sign in to comment.