Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] interactive-supports-focus: add basic suggestions #1023

Conversation

lb-
Copy link
Contributor

@lb- lb- commented Oct 23, 2024

Add basic support for ESlint rule suggestions for the interactive-supports-focus for tabIndex values when elements are interactive but do not have implicit focusable browser behaviour. These are intentionally not auto-fix but simply optional suggestions to help developers resolve their issue.

Fixes #952
See also #951

Implementation as per ESlint documentation https://eslint.org/docs/latest/extend/custom-rules#providing-suggestions
Tests added as per ESlint documentation https://eslint.org/docs/latest/integrate/nodejs-api#testing-suggestions

Screenshots of editor suggestions (npm link testing)

Screenshot 2024-10-23 at 12 10 35 PM
Screenshot 2024-10-23 at 12 10 15 PM

Before

<div onClick={(event) => console.log(event)} role="menu">Click</div>

After

<div tabIndex={-1} onClick={(event) => console.log(event)} role="menu">Click</div>

Add basic support for ESlint rule suggestions for the `interactive-supports-focus` for tabIndex values when elements are interactive but do not have implicit focusable browser behaviour.
These are intentionally not auto-fix but simply optional suggestions to help developers resolve their issue.

Fixes jsx-eslint#952
See also jsx-eslint#951
@lb- lb- force-pushed the feature/952-interactive-supports-focus-tab-index-suggestion branch from 118498e to 46e4203 Compare October 23, 2024 02:23
@lb-
Copy link
Contributor Author

lb- commented Oct 23, 2024

Checking all tests pass & fixing if there are issues. After that I will mark as ready for review.

@lb- lb- marked this pull request as ready for review October 23, 2024 03:18
@lb-
Copy link
Contributor Author

lb- commented Oct 23, 2024

Ready for review.

Copy link

@ckundo ckundo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@lb- lb- force-pushed the feature/952-interactive-supports-focus-tab-index-suggestion branch from 46e4203 to fc028b4 Compare October 25, 2024 23:52
@ljharb ljharb force-pushed the feature/952-interactive-supports-focus-tab-index-suggestion branch from fc028b4 to 068608b Compare October 26, 2024 04:47
@ljharb ljharb changed the title [new] Add basic suggestions for interactive-supports-focus [New] interactive-supports-focus: add basic suggestions Oct 26, 2024
@ljharb ljharb merged commit 068608b into jsx-eslint:main Oct 26, 2024
112 checks passed
@lb- lb- deleted the feature/952-interactive-supports-focus-tab-index-suggestion branch October 26, 2024 13:08
@lb-
Copy link
Contributor Author

lb- commented Oct 26, 2024

Thank you for reviewing. @ljharb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] suggest tabindex 0 or -1 for interactive-supports-focus
3 participants