Skip to content

chore: configure eslint plugin jsx a11y #20060

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

riddhybansal
Copy link
Contributor

@riddhybansal riddhybansal commented Jul 31, 2025

Closes #19013
Closes #19005

Add eslint-plugin-jsx-a11y for accessibility linting
Installed eslint-plugin-react-hooks

Changelog

New

  • Added eslint-plugin-jsx-a11y plugin for React accessibility linting
  • Installed eslint-plugin-react-hooks

Changed

  • Updated ESLint configuration to include accessibility checks
  • Updated ESLint configuration to include react-hooks

Testing / Reviewing

  • Verify jsx-a11y rules trigger errors for accessibility violations:
    -Create a test file with <img src="test.jpg" /> (missing alt) - should error
    • Create a test file with <div tabIndex="3"> (positive tabIndex) - should error
    • Create a test file with <div onClick={() => {}}> (missing keyboard handler) - should error

export default TestComponent;

Screenshots of my local testing

Screenshot 2025-07-31 at 1 02 14 PM Screenshot 2025-07-31 at 1 13 15 PM

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • Updated documentation and storybook examples
  • Wrote passing tests that cover this change
  • Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

More details can be found in the pull request guide

@riddhybansal riddhybansal requested review from a team as code owners July 31, 2025 07:58
Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit c03fd6b
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/688b22418a37f3000822cac4
😎 Deploy Preview https://deploy-preview-20060--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@riddhybansal
Copy link
Contributor Author

Hey @tay1orjones
I've successfully added jsx-a11y for accessibility linting, and it's working great for .js and .jsx files. However, I noticed that our current ESLint config ignores all TypeScript files (**/*.{ts,tsx}).

Question: Should I include removing these TypeScript ignores as part of this PR?

Considerations:
This could potentially surface a lot of existing accessibility issues in TypeScript files
Might be better to tackle in a separate PR to keep this focused
Or we could add the ignores removal but temporarily disable specific rules that are too noisy

My recommendation: Keep this PR focused on just adding jsx-a11y, then tackle TypeScript file linting in a follow-up PR where we can address any issues that surface more systematically.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit c03fd6b
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/688b224158f78400084e8c49
😎 Deploy Preview https://deploy-preview-20060--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.39%. Comparing base (2dd1055) to head (3292061).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20060      +/-   ##
==========================================
+ Coverage   91.28%   91.39%   +0.10%     
==========================================
  Files         481      485       +4     
  Lines       30569    31370     +801     
  Branches     5423     5478      +55     
==========================================
+ Hits        27906    28670     +764     
- Misses       2509     2547      +38     
+ Partials      154      153       -1     
Flag Coverage Δ
main-packages 84.93% <ø> (ø)
web-components 97.16% <ø> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c03fd6b
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/688b2241aca9570008b352db
😎 Deploy Preview https://deploy-preview-20060--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 3292061
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/688be2f73fab3e00083ccdb1
😎 Deploy Preview https://deploy-preview-20060--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 3292061
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/688be2f76a46d100082dd926
😎 Deploy Preview https://deploy-preview-20060--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3292061
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/688be2f7a6f9890008efdfa1
😎 Deploy Preview https://deploy-preview-20060--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@riddhybansal riddhybansal force-pushed the install_eslint-plugin-jsx-a11y branch from a6979f2 to e5717ba Compare July 31, 2025 08:36
@riddhybansal
Copy link
Contributor Author

Note on additional changes: While implementing jsx-a11y, I encountered linting issues where react-hooks/rules-of-hooks was throwing "Definition for rule not found" errors. Since we already have an issue for installing eslint-plugin-react-hooks, I went ahead and resolved it in this same PR to unblock the jsx-a11y implementation.
Changes made for react-hooks:

Installed eslint-plugin-react-hooks
Added it to the plugins configuration
Included reactHooks.configs.recommended.rules in the rules setup

@riddhybansal
Copy link
Contributor Author

I have intentionally removed the react hook disable for reviewers to review that lint fails and our config works. . Will add back once I get reviews.

@tay1orjones
Copy link
Member

Should I include removing these TypeScript ignores as part of this PR?

No, I think that should probably be a separate PR. @adamalston I remembered you mentioning it in #19658, did you have any work in progress for enabling processing on typescript files?

If not, I can open a new issue with some ideas. It's possible we could

  1. Open the issue
  2. Enable typescript file processing
  3. Put ignore comments on each failure and include a comment with the issue url. As granular as possible:
    • Rule-specific ignores instead of global/wildcard ignores
    • Prefer single-line ignores over multi-line/range ignores
    • Entire file ignores as an absolute last resort
  4. Submit this in a PR
  5. Open a new issue for removing all the ignores and chew away at them over time by searching for the original/parent issue url.
    • As we chew away at them, we remove the issue url and so treat this as a sort of checklist

This aims for benefits of:

  • Gaining immediate lint coverage for all the .ts/.tsx code that doesn't get ignores applied
  • Iterative, non-blocking work that can be put into small, more reviewable PRs instead of a long running branch with huge PR(s)
  • Not having to manually sync an issue checklist with each ignore item that remains. We just issue PR after PR that can branch/stack as needed.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

LGTM! Does need yarn dedupe ran and the changes pushed up though

@tay1orjones
Copy link
Member

I went ahead and opened #20071 just so we don't lose track of enabling typescript

@adamalston
Copy link
Contributor

adamalston commented Jul 31, 2025

No, I think that should probably be a separate PR. @adamalston I remembered you mentioning it in #19658, did you have any work in progress for enabling processing on typescript files?

Yea, I worked on it. I stashed the changes locally to focus on some internal commitments. I was hoping to get back to it soon, but I can't commit to a specific timeline. So if it's urgent, someone else is welcome to pick it up.

@riddhybansal riddhybansal added this pull request to the merge queue Aug 1, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 1, 2025
@riddhybansal riddhybansal added this pull request to the merge queue Aug 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install eslint-plugin-jsx-a11y Install eslint-plugin-react-hooks
4 participants