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

Extend initial a11y config for eslint #2459

Merged
merged 4 commits into from
Feb 6, 2025
Merged

Extend initial a11y config for eslint #2459

merged 4 commits into from
Feb 6, 2025

Conversation

beaesguerra
Copy link
Member

Summary:

This work is part of the implementation of ADR#781 Enabling more lint rules for accessibility

These changes includes:

  • Updated dev dependency: @khanacademy/eslint-config
  • Extending @khanacademy/eslint-config/a11y config in project's eslint config
    • Currently, the a11y config enables the aphrodite-add-style-variable-name rule from @khanacademy/eslint-plugin. This is the first step to adding more a11y linting rules so that the naming convention for html elements is more predictable for custom component mapping for eslint-plugin-jsx-a11y (see rule docs for more details).
    • @khanacademy/eslint-config/a11y will be updated in another PR to include config for eslint-plugin-jsx-a11y
  • Addressing lint errors from the aphrodite-add-style-variable-name rule

Issue: FEI-6050

Implementation Plan:

  • Create eslint config for a11y wonder-stuff#1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name
  • (includes this PR) Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule
  • Update the a11y.js config with the config based on the accessibility linting rules ADR
  • Use the updated config in projects and address existing errors by disabling the rules per line. Teams can address existing errors as they work in the area and new errors can be prevented with these lint rules!

Test plan:

  • Run pnpm lint and make sure there are no linting errors.
  • Some variables were renamed internally, there should be no functional changes

@beaesguerra beaesguerra self-assigned this Feb 5, 2025
Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 65a281f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-clickable Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-core Patch
@khanacademy/wonder-blocks-form Patch
@khanacademy/wonder-blocks-icon Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-cell Patch
@khanacademy/wonder-blocks-pill Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-data Patch
@khanacademy/wonder-blocks-grid Patch
@khanacademy/wonder-blocks-labeled-field Patch
@khanacademy/wonder-blocks-layout Patch
@khanacademy/wonder-blocks-progress-spinner Patch
@khanacademy/wonder-blocks-switch Patch
@khanacademy/wonder-blocks-testing Patch
@khanacademy/wonder-blocks-toolbar Patch
@khanacademy/wonder-blocks-tooltip Patch
@khanacademy/wonder-blocks-typography Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Size Change: -20 B (-0.02%)

Total Size: 97.4 kB

Filename Size Change
packages/wonder-blocks-accordion/dist/es/index.js 3.53 kB -8 B (-0.23%)
packages/wonder-blocks-breadcrumbs/dist/es/index.js 886 B -1 B (-0.11%)
packages/wonder-blocks-button/dist/es/index.js 4.3 kB -4 B (-0.09%)
packages/wonder-blocks-clickable/dist/es/index.js 3.03 kB -4 B (-0.13%)
packages/wonder-blocks-dropdown/dist/es/index.js 19 kB -2 B (-0.01%)
packages/wonder-blocks-form/dist/es/index.js 6.03 kB +2 B (+0.03%)
packages/wonder-blocks-icon-button/dist/es/index.js 3.11 kB -4 B (-0.13%)
packages/wonder-blocks-icon/dist/es/index.js 873 B +2 B (+0.23%)
packages/wonder-blocks-link/dist/es/index.js 2.27 kB -4 B (-0.18%)
packages/wonder-blocks-popover/dist/es/index.js 4.85 kB +3 B (+0.06%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-banner/dist/es/index.js 1.56 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.83 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-core/dist/es/index.js 2.97 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 1.22 kB
packages/wonder-blocks-layout/dist/es/index.js 1.81 kB
packages/wonder-blocks-modal/dist/es/index.js 5.41 kB
packages/wonder-blocks-pill/dist/es/index.js 1.4 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.33 kB
packages/wonder-blocks-switch/dist/es/index.js 2 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.73 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 679 B
packages/wonder-blocks-timing/dist/es/index.js 1.79 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.51 kB
packages/wonder-blocks-toolbar/dist/es/index.js 905 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.96 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Feb 5, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-gpqylfgtde.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 380
Tests with visual changes 0
Total stories 543
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 380

@beaesguerra
Copy link
Member Author

Note: This PR uses the pnpm-migration branch as the base so I'll land this PR after the pnpm changes are in!

@beaesguerra beaesguerra marked this pull request as ready for review February 5, 2025 18:31
@khan-actions-bot khan-actions-bot requested a review from a team February 5, 2025 18:31
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .eslintrc.js, package.json, pnpm-lock.yaml, .changeset/chatty-parents-swim.md, __docs__/components/token-table.tsx, packages/wonder-blocks-accordion/src/components/accordion.tsx, packages/wonder-blocks-breadcrumbs/src/components/breadcrumbs-item.tsx, packages/wonder-blocks-breadcrumbs/src/components/breadcrumbs.tsx, packages/wonder-blocks-button/src/components/button-core.tsx, packages/wonder-blocks-clickable/src/components/clickable.tsx, packages/wonder-blocks-core/src/util/add-styles.typestest.tsx, packages/wonder-blocks-dropdown/src/components/option-item.tsx, packages/wonder-blocks-form/src/components/text-area.tsx, packages/wonder-blocks-icon/src/components/phosphor-icon.tsx, packages/wonder-blocks-icon-button/src/components/icon-button-core.tsx, packages/wonder-blocks-link/src/components/link-core.tsx, packages/wonder-blocks-popover/src/components/popover-content.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Feb 5, 2025

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (eb50a4d) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2459"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2459

Base automatically changed from pnpm-migration to main February 5, 2025 21:49
@beaesguerra
Copy link
Member Author

The pnpm changes are in main now and I've fixed the merge conflicts!

Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Looks great! thanks for starting this work. It's going to save us a lot of dev time and improve a11y too 💯 🚀

@beaesguerra beaesguerra merged commit 969864b into main Feb 6, 2025
14 checks passed
@beaesguerra beaesguerra deleted the fei-6050 branch February 6, 2025 16:37
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (bb2a026) to head (65a281f).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #2459   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb2a026...65a281f. Read the comment docs.

beaesguerra added a commit to Khan/wonder-stuff that referenced this pull request Feb 11, 2025
…nfig/a11y` (#1118)

## Summary:
This work is part of the implementation of [ADR#781 Enabling more lint rules for accessibility](https://khanacademy.atlassian.net/wiki/x/IoBVyg)

These changes includes:
- Updating the `eslint-plugin-jsx-a11y` dependency
- Configuring rules and settings (including custom component mapping, attribute mapping, polymorphic components) for `eslint-plugin-jsx-a11y` based on the [proposed rules and settings in the ADR](https://khanacademy.atlassian.net/wiki/spaces/ENG/pages/3394600994/ADR+781+Enabling+more+lint+rules+for+accessibility#Proposed-customization-and-overrides-for-the-plugin) and the [POC](https://github.com/Khan/webapp/pull/26840/files#diff-20e55c78ab86b0eb87c6f756500b87f451b52fab251d6f327ce572ec88e8ae3b)
- Updating the README to include instructions for using `@khanacademy/eslint-config/a11y`

Issue: FEI-1133

Implementation Plan:
- #1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name 
- Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule
  - Khan/wonder-blocks#2459
  - Khan/perseus#2193
  - Khan/webapp#29212
- (this PR) Update the a11y.js config with the config based on the accessibility linting rules ADR
- Use the updated config in projects and address existing errors by disabling the rules per line. Teams can address existing errors as they work in the area and new errors can be prevented with these lint rules!

## Test plan:
Testing the new config locally:
- Run yarn pack in `packages/eslint-config-khan`. This will create a `.tgz` file in the directory
- In another project, install the package: ex: `yarn add -D -W /Users/beaesguerra/khan/wonder-stuff/packages/eslint-config-khan/khanacademy-eslint-config-v5.1.0.tgz`
  - Note: you might need to remove the node_modules first to make sure it installed the correct package. You can check by checking `node_modules/@khanacademy/eslint-config/a11y.js` in the project to see if the new config is there
- Make sure the project already extends `@khanacademy/eslint-config/a11y` in the project's eslint config file
- Run `yarn lint`/`pnpm lint` in the project and restart the ESLint server. It should show errors from the `jsx-a11y` plugin

Note: Before merging and releasing these changes, I'll test these changes locally with the different projects and evaluate the errors to make sure the config changes are still relevant and helpful!

Author: beaesguerra

Reviewers: beaesguerra, marcysutton, kevinb-khan

Required Reviewers:

Approved By: marcysutton, kevinb-khan

Checks: ✅ codecov/project, ✅ Test (macos-latest, 20.x), ✅ CodeQL, ✅ Lint, typecheck, and coverage check (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Analyze (javascript), ✅ gerald, ⏭️  dependabot

Pull Request URL: #1118
beaesguerra added a commit that referenced this pull request Feb 12, 2025
## Summary:
This work is part of the implementation of [ADR#781 Enabling more lint rules for accessibility](https://khanacademy.atlassian.net/wiki/x/IoBVyg)

These changes include:
- Updating `@khanacademy/eslint-config` to the latest version to include new jsx-a11y configuration and settings
- Addressed existing errors by adding `eslint-disable-next-line`
  - View the PR commits for a breakdown of errors by rule
  - Used `npx eslint-interactive@10.8.0 .` to easily disable lint errors per rule
- New potential a11y issues can be prevented with these lint rules!

Note: In a follow up PR, I'll address the low hanging issues in WB and create tickets for more complex issues that were found

A breakdown of the existing jsx-a11y errors:

<img width="1027" alt="wb-linting-errors-before" src="https://github.com/user-attachments/assets/cbe4be7f-6868-48af-8474-bad0297cf8b2" />


Implementation Plan:
- Khan/wonder-stuff#1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name 
- Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule
  - #2459
  - Khan/perseus#2193
  - Khan/webapp#29212
- Khan/wonder-stuff#1118 Update the eslint-config/a11y config with the config based on the accessibility linting rules ADR
- (includes this PR) Use the updated config in projects and address existing errors by disabling the rules per line.

Issue: FEI-1133

## Test plan:
- Run `pnpm lint` and make sure there are no linting errors

Author: beaesguerra

Reviewers: beaesguerra, jandrade

Required Reviewers:

Approved By: jandrade

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2471
beaesguerra added a commit to Khan/perseus that referenced this pull request Feb 13, 2025
## Summary:
This work is part of the implementation of [ADR#781 Enabling more lint rules for accessibility](https://khanacademy.atlassian.net/wiki/x/IoBVyg)

These changes include:
- Updating `@khanacademy/eslint-config` to the latest version to include new jsx-a11y configuration and settings
- Updating `esling-plugin-jsx-a11y` to the latest version so it is up to date
- Addressed existing errors by adding `eslint-disable-next-line`
  - View the PR commits for a breakdown of errors by rule
  - Used `npx eslint-interactive@10.8.0 .` to disable lint errors per rule
- Provided custom component mapping for jsx-a11y in the eslint config since Perseus has custom components 

New potential a11y issues can be prevented with these lint rules and existing errors can be addressed over time by the team! The lint error messages have a link to the [rule docs](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/main/docs/rules) for more details!

A breakdown of the existing jsx-a11y errors:

<img width="1019" alt="perseus-linting-errors-before" src="https://github.com/user-attachments/assets/8191e551-4147-43cb-bbcf-79b0e5684c26" />

### Implementation Plan:
- Khan/wonder-stuff#1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name 
- Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule
  - Khan/wonder-blocks#2459
  - #2193
  - Khan/webapp#29212
- Khan/wonder-stuff#1118 Update the eslint-config/a11y config with the config based on the accessibility linting rules ADR
- (includes this PR) Use the updated config in projects and address existing errors by disabling the rules per line.

Issue: FEI-1133

## Test plan:
- Run `yarn lint` and make sure there are no linting errors

Author: beaesguerra

Reviewers: catandthemachines, beaesguerra, #frontend-infra-web

Required Reviewers:

Approved By: catandthemachines

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x)

Pull Request URL: #2232
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.

3 participants